babylon.module.d.ts 4.8 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249
  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 { Mesh } from "babylonjs/Meshes/mesh";
  9473. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  9474. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9475. import { Effect } from "babylonjs/Materials/effect";
  9476. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  9477. import "babylonjs/Shaders/shadowMap.fragment";
  9478. import "babylonjs/Shaders/shadowMap.vertex";
  9479. import "babylonjs/Shaders/depthBoxBlur.fragment";
  9480. import { Observable } from "babylonjs/Misc/observable";
  9481. /**
  9482. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9483. */
  9484. export interface ICustomShaderOptions {
  9485. /**
  9486. * Gets or sets the custom shader name to use
  9487. */
  9488. shaderName: string;
  9489. /**
  9490. * The list of attribute names used in the shader
  9491. */
  9492. attributes?: string[];
  9493. /**
  9494. * The list of unifrom names used in the shader
  9495. */
  9496. uniforms?: string[];
  9497. /**
  9498. * The list of sampler names used in the shader
  9499. */
  9500. samplers?: string[];
  9501. /**
  9502. * The list of defines used in the shader
  9503. */
  9504. defines?: string[];
  9505. }
  9506. /**
  9507. * Interface to implement to create a shadow generator compatible with BJS.
  9508. */
  9509. export interface IShadowGenerator {
  9510. /**
  9511. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9512. * @returns The render target texture if present otherwise, null
  9513. */
  9514. getShadowMap(): Nullable<RenderTargetTexture>;
  9515. /**
  9516. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9517. * @returns The render target texture if the shadow map is present otherwise, null
  9518. */
  9519. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9520. /**
  9521. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9522. * @param subMesh The submesh we want to render in the shadow map
  9523. * @param useInstances Defines wether will draw in the map using instances
  9524. * @returns true if ready otherwise, false
  9525. */
  9526. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9527. /**
  9528. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9529. * @param defines Defines of the material we want to update
  9530. * @param lightIndex Index of the light in the enabled light list of the material
  9531. */
  9532. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9533. /**
  9534. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9535. * defined in the generator but impacting the effect).
  9536. * It implies the unifroms available on the materials are the standard BJS ones.
  9537. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9538. * @param effect The effect we are binfing the information for
  9539. */
  9540. bindShadowLight(lightIndex: string, effect: Effect): void;
  9541. /**
  9542. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9543. * (eq to shadow prjection matrix * light transform matrix)
  9544. * @returns The transform matrix used to create the shadow map
  9545. */
  9546. getTransformMatrix(): Matrix;
  9547. /**
  9548. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9549. * Cube and 2D textures for instance.
  9550. */
  9551. recreateShadowMap(): void;
  9552. /**
  9553. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9554. * @param onCompiled Callback triggered at the and of the effects compilation
  9555. * @param options Sets of optional options forcing the compilation with different modes
  9556. */
  9557. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9558. useInstances: boolean;
  9559. }>): void;
  9560. /**
  9561. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9562. * @param options Sets of optional options forcing the compilation with different modes
  9563. * @returns A promise that resolves when the compilation completes
  9564. */
  9565. forceCompilationAsync(options?: Partial<{
  9566. useInstances: boolean;
  9567. }>): Promise<void>;
  9568. /**
  9569. * Serializes the shadow generator setup to a json object.
  9570. * @returns The serialized JSON object
  9571. */
  9572. serialize(): any;
  9573. /**
  9574. * Disposes the Shadow map and related Textures and effects.
  9575. */
  9576. dispose(): void;
  9577. }
  9578. /**
  9579. * Default implementation IShadowGenerator.
  9580. * This is the main object responsible of generating shadows in the framework.
  9581. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9582. */
  9583. export class ShadowGenerator implements IShadowGenerator {
  9584. /**
  9585. * Shadow generator mode None: no filtering applied.
  9586. */
  9587. static readonly FILTER_NONE: number;
  9588. /**
  9589. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9590. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9591. */
  9592. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9593. /**
  9594. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9595. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9596. */
  9597. static readonly FILTER_POISSONSAMPLING: number;
  9598. /**
  9599. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9600. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9601. */
  9602. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9603. /**
  9604. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9605. * edge artifacts on steep falloff.
  9606. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9607. */
  9608. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9609. /**
  9610. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9611. * edge artifacts on steep falloff.
  9612. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9613. */
  9614. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9615. /**
  9616. * Shadow generator mode PCF: Percentage Closer Filtering
  9617. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9618. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9619. */
  9620. static readonly FILTER_PCF: number;
  9621. /**
  9622. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9623. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9624. * Contact Hardening
  9625. */
  9626. static readonly FILTER_PCSS: number;
  9627. /**
  9628. * Reserved for PCF and PCSS
  9629. * Highest Quality.
  9630. *
  9631. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9632. *
  9633. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9634. */
  9635. static readonly QUALITY_HIGH: number;
  9636. /**
  9637. * Reserved for PCF and PCSS
  9638. * Good tradeoff for quality/perf cross devices
  9639. *
  9640. * Execute PCF on a 3*3 kernel.
  9641. *
  9642. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9643. */
  9644. static readonly QUALITY_MEDIUM: number;
  9645. /**
  9646. * Reserved for PCF and PCSS
  9647. * The lowest quality but the fastest.
  9648. *
  9649. * Execute PCF on a 1*1 kernel.
  9650. *
  9651. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9652. */
  9653. static readonly QUALITY_LOW: number;
  9654. /** Gets or sets the custom shader name to use */
  9655. customShaderOptions: ICustomShaderOptions;
  9656. /**
  9657. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9658. */
  9659. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9660. /**
  9661. * Observable triggered before a mesh is rendered in the shadow map.
  9662. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9663. */
  9664. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9665. private _bias;
  9666. /**
  9667. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9668. */
  9669. /**
  9670. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9671. */
  9672. bias: number;
  9673. private _normalBias;
  9674. /**
  9675. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9676. */
  9677. /**
  9678. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9679. */
  9680. normalBias: number;
  9681. private _blurBoxOffset;
  9682. /**
  9683. * Gets the blur box offset: offset applied during the blur pass.
  9684. * Only useful if useKernelBlur = false
  9685. */
  9686. /**
  9687. * Sets the blur box offset: offset applied during the blur pass.
  9688. * Only useful if useKernelBlur = false
  9689. */
  9690. blurBoxOffset: number;
  9691. private _blurScale;
  9692. /**
  9693. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9694. * 2 means half of the size.
  9695. */
  9696. /**
  9697. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9698. * 2 means half of the size.
  9699. */
  9700. blurScale: number;
  9701. private _blurKernel;
  9702. /**
  9703. * Gets the blur kernel: kernel size of the blur pass.
  9704. * Only useful if useKernelBlur = true
  9705. */
  9706. /**
  9707. * Sets the blur kernel: kernel size of the blur pass.
  9708. * Only useful if useKernelBlur = true
  9709. */
  9710. blurKernel: number;
  9711. private _useKernelBlur;
  9712. /**
  9713. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9714. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9715. */
  9716. /**
  9717. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9718. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9719. */
  9720. useKernelBlur: boolean;
  9721. private _depthScale;
  9722. /**
  9723. * Gets the depth scale used in ESM mode.
  9724. */
  9725. /**
  9726. * Sets the depth scale used in ESM mode.
  9727. * This can override the scale stored on the light.
  9728. */
  9729. depthScale: number;
  9730. private _filter;
  9731. /**
  9732. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9733. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9734. */
  9735. /**
  9736. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9737. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9738. */
  9739. filter: number;
  9740. /**
  9741. * Gets if the current filter is set to Poisson Sampling.
  9742. */
  9743. /**
  9744. * Sets the current filter to Poisson Sampling.
  9745. */
  9746. usePoissonSampling: boolean;
  9747. /**
  9748. * Gets if the current filter is set to ESM.
  9749. */
  9750. /**
  9751. * Sets the current filter is to ESM.
  9752. */
  9753. useExponentialShadowMap: boolean;
  9754. /**
  9755. * Gets if the current filter is set to filtered ESM.
  9756. */
  9757. /**
  9758. * Gets if the current filter is set to filtered ESM.
  9759. */
  9760. useBlurExponentialShadowMap: boolean;
  9761. /**
  9762. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9763. * exponential to prevent steep falloff artifacts).
  9764. */
  9765. /**
  9766. * Sets the current filter to "close ESM" (using the inverse of the
  9767. * exponential to prevent steep falloff artifacts).
  9768. */
  9769. useCloseExponentialShadowMap: boolean;
  9770. /**
  9771. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9772. * exponential to prevent steep falloff artifacts).
  9773. */
  9774. /**
  9775. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9776. * exponential to prevent steep falloff artifacts).
  9777. */
  9778. useBlurCloseExponentialShadowMap: boolean;
  9779. /**
  9780. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9781. */
  9782. /**
  9783. * Sets the current filter to "PCF" (percentage closer filtering).
  9784. */
  9785. usePercentageCloserFiltering: boolean;
  9786. private _filteringQuality;
  9787. /**
  9788. * Gets the PCF or PCSS Quality.
  9789. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9790. */
  9791. /**
  9792. * Sets the PCF or PCSS Quality.
  9793. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9794. */
  9795. filteringQuality: number;
  9796. /**
  9797. * Gets if the current filter is set to "PCSS" (contact hardening).
  9798. */
  9799. /**
  9800. * Sets the current filter to "PCSS" (contact hardening).
  9801. */
  9802. useContactHardeningShadow: boolean;
  9803. private _contactHardeningLightSizeUVRatio;
  9804. /**
  9805. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9806. * Using a ratio helps keeping shape stability independently of the map size.
  9807. *
  9808. * It does not account for the light projection as it was having too much
  9809. * instability during the light setup or during light position changes.
  9810. *
  9811. * Only valid if useContactHardeningShadow is true.
  9812. */
  9813. /**
  9814. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9815. * Using a ratio helps keeping shape stability independently of the map size.
  9816. *
  9817. * It does not account for the light projection as it was having too much
  9818. * instability during the light setup or during light position changes.
  9819. *
  9820. * Only valid if useContactHardeningShadow is true.
  9821. */
  9822. contactHardeningLightSizeUVRatio: number;
  9823. private _darkness;
  9824. /**
  9825. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9826. * 0 means strongest and 1 would means no shadow.
  9827. * @returns the darkness.
  9828. */
  9829. getDarkness(): number;
  9830. /**
  9831. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9832. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9833. * @returns the shadow generator allowing fluent coding.
  9834. */
  9835. setDarkness(darkness: number): ShadowGenerator;
  9836. private _transparencyShadow;
  9837. /**
  9838. * Sets the ability to have transparent shadow (boolean).
  9839. * @param transparent True if transparent else False
  9840. * @returns the shadow generator allowing fluent coding
  9841. */
  9842. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9843. private _shadowMap;
  9844. private _shadowMap2;
  9845. /**
  9846. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9847. * @returns The render target texture if present otherwise, null
  9848. */
  9849. getShadowMap(): Nullable<RenderTargetTexture>;
  9850. /**
  9851. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9852. * @returns The render target texture if the shadow map is present otherwise, null
  9853. */
  9854. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9855. /**
  9856. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9857. * @param mesh Mesh to add
  9858. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9859. * @returns the Shadow Generator itself
  9860. */
  9861. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9862. /**
  9863. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9864. * @param mesh Mesh to remove
  9865. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9866. * @returns the Shadow Generator itself
  9867. */
  9868. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9869. /**
  9870. * Controls the extent to which the shadows fade out at the edge of the frustum
  9871. * Used only by directionals and spots
  9872. */
  9873. frustumEdgeFalloff: number;
  9874. private _light;
  9875. /**
  9876. * Returns the associated light object.
  9877. * @returns the light generating the shadow
  9878. */
  9879. getLight(): IShadowLight;
  9880. /**
  9881. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  9882. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  9883. * It might on the other hand introduce peter panning.
  9884. */
  9885. forceBackFacesOnly: boolean;
  9886. private _scene;
  9887. private _lightDirection;
  9888. private _effect;
  9889. private _viewMatrix;
  9890. private _projectionMatrix;
  9891. private _transformMatrix;
  9892. private _cachedPosition;
  9893. private _cachedDirection;
  9894. private _cachedDefines;
  9895. private _currentRenderID;
  9896. private _boxBlurPostprocess;
  9897. private _kernelBlurXPostprocess;
  9898. private _kernelBlurYPostprocess;
  9899. private _blurPostProcesses;
  9900. private _mapSize;
  9901. private _currentFaceIndex;
  9902. private _currentFaceIndexCache;
  9903. private _textureType;
  9904. private _defaultTextureMatrix;
  9905. /** @hidden */
  9906. static _SceneComponentInitialization: (scene: Scene) => void;
  9907. /**
  9908. * Creates a ShadowGenerator object.
  9909. * A ShadowGenerator is the required tool to use the shadows.
  9910. * Each light casting shadows needs to use its own ShadowGenerator.
  9911. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  9912. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  9913. * @param light The light object generating the shadows.
  9914. * @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.
  9915. */
  9916. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  9917. private _initializeGenerator;
  9918. private _initializeShadowMap;
  9919. private _initializeBlurRTTAndPostProcesses;
  9920. private _renderForShadowMap;
  9921. private _renderSubMeshForShadowMap;
  9922. private _applyFilterValues;
  9923. /**
  9924. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9925. * @param onCompiled Callback triggered at the and of the effects compilation
  9926. * @param options Sets of optional options forcing the compilation with different modes
  9927. */
  9928. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9929. useInstances: boolean;
  9930. }>): void;
  9931. /**
  9932. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9933. * @param options Sets of optional options forcing the compilation with different modes
  9934. * @returns A promise that resolves when the compilation completes
  9935. */
  9936. forceCompilationAsync(options?: Partial<{
  9937. useInstances: boolean;
  9938. }>): Promise<void>;
  9939. /**
  9940. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9941. * @param subMesh The submesh we want to render in the shadow map
  9942. * @param useInstances Defines wether will draw in the map using instances
  9943. * @returns true if ready otherwise, false
  9944. */
  9945. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9946. /**
  9947. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9948. * @param defines Defines of the material we want to update
  9949. * @param lightIndex Index of the light in the enabled light list of the material
  9950. */
  9951. prepareDefines(defines: any, lightIndex: number): void;
  9952. /**
  9953. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9954. * defined in the generator but impacting the effect).
  9955. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9956. * @param effect The effect we are binfing the information for
  9957. */
  9958. bindShadowLight(lightIndex: string, effect: Effect): void;
  9959. /**
  9960. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9961. * (eq to shadow prjection matrix * light transform matrix)
  9962. * @returns The transform matrix used to create the shadow map
  9963. */
  9964. getTransformMatrix(): Matrix;
  9965. /**
  9966. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9967. * Cube and 2D textures for instance.
  9968. */
  9969. recreateShadowMap(): void;
  9970. private _disposeBlurPostProcesses;
  9971. private _disposeRTTandPostProcesses;
  9972. /**
  9973. * Disposes the ShadowGenerator.
  9974. * Returns nothing.
  9975. */
  9976. dispose(): void;
  9977. /**
  9978. * Serializes the shadow generator setup to a json object.
  9979. * @returns The serialized JSON object
  9980. */
  9981. serialize(): any;
  9982. /**
  9983. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  9984. * @param parsedShadowGenerator The JSON object to parse
  9985. * @param scene The scene to create the shadow map for
  9986. * @returns The parsed shadow generator
  9987. */
  9988. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  9989. }
  9990. }
  9991. declare module "babylonjs/Lights/light" {
  9992. import { Nullable } from "babylonjs/types";
  9993. import { Scene } from "babylonjs/scene";
  9994. import { Vector3, Color3 } from "babylonjs/Maths/math";
  9995. import { Node } from "babylonjs/node";
  9996. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9997. import { Effect } from "babylonjs/Materials/effect";
  9998. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9999. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  10000. /**
  10001. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  10002. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  10003. * 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.
  10004. */
  10005. export abstract class Light extends Node {
  10006. /**
  10007. * Falloff Default: light is falling off following the material specification:
  10008. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  10009. */
  10010. static readonly FALLOFF_DEFAULT: number;
  10011. /**
  10012. * Falloff Physical: light is falling off following the inverse squared distance law.
  10013. */
  10014. static readonly FALLOFF_PHYSICAL: number;
  10015. /**
  10016. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  10017. * to enhance interoperability with other engines.
  10018. */
  10019. static readonly FALLOFF_GLTF: number;
  10020. /**
  10021. * Falloff Standard: light is falling off like in the standard material
  10022. * to enhance interoperability with other materials.
  10023. */
  10024. static readonly FALLOFF_STANDARD: number;
  10025. /**
  10026. * If every light affecting the material is in this lightmapMode,
  10027. * material.lightmapTexture adds or multiplies
  10028. * (depends on material.useLightmapAsShadowmap)
  10029. * after every other light calculations.
  10030. */
  10031. static readonly LIGHTMAP_DEFAULT: number;
  10032. /**
  10033. * material.lightmapTexture as only diffuse lighting from this light
  10034. * adds only specular lighting from this light
  10035. * adds dynamic shadows
  10036. */
  10037. static readonly LIGHTMAP_SPECULAR: number;
  10038. /**
  10039. * material.lightmapTexture as only lighting
  10040. * no light calculation from this light
  10041. * only adds dynamic shadows from this light
  10042. */
  10043. static readonly LIGHTMAP_SHADOWSONLY: number;
  10044. /**
  10045. * Each light type uses the default quantity according to its type:
  10046. * point/spot lights use luminous intensity
  10047. * directional lights use illuminance
  10048. */
  10049. static readonly INTENSITYMODE_AUTOMATIC: number;
  10050. /**
  10051. * lumen (lm)
  10052. */
  10053. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  10054. /**
  10055. * candela (lm/sr)
  10056. */
  10057. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  10058. /**
  10059. * lux (lm/m^2)
  10060. */
  10061. static readonly INTENSITYMODE_ILLUMINANCE: number;
  10062. /**
  10063. * nit (cd/m^2)
  10064. */
  10065. static readonly INTENSITYMODE_LUMINANCE: number;
  10066. /**
  10067. * Light type const id of the point light.
  10068. */
  10069. static readonly LIGHTTYPEID_POINTLIGHT: number;
  10070. /**
  10071. * Light type const id of the directional light.
  10072. */
  10073. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  10074. /**
  10075. * Light type const id of the spot light.
  10076. */
  10077. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  10078. /**
  10079. * Light type const id of the hemispheric light.
  10080. */
  10081. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  10082. /**
  10083. * Diffuse gives the basic color to an object.
  10084. */
  10085. diffuse: Color3;
  10086. /**
  10087. * Specular produces a highlight color on an object.
  10088. * Note: This is note affecting PBR materials.
  10089. */
  10090. specular: Color3;
  10091. /**
  10092. * Defines the falloff type for this light. This lets overrriding how punctual light are
  10093. * falling off base on range or angle.
  10094. * This can be set to any values in Light.FALLOFF_x.
  10095. *
  10096. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  10097. * other types of materials.
  10098. */
  10099. falloffType: number;
  10100. /**
  10101. * Strength of the light.
  10102. * Note: By default it is define in the framework own unit.
  10103. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  10104. */
  10105. intensity: number;
  10106. private _range;
  10107. protected _inverseSquaredRange: number;
  10108. /**
  10109. * Defines how far from the source the light is impacting in scene units.
  10110. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10111. */
  10112. /**
  10113. * Defines how far from the source the light is impacting in scene units.
  10114. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10115. */
  10116. range: number;
  10117. /**
  10118. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  10119. * of light.
  10120. */
  10121. private _photometricScale;
  10122. private _intensityMode;
  10123. /**
  10124. * Gets the photometric scale used to interpret the intensity.
  10125. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10126. */
  10127. /**
  10128. * Sets the photometric scale used to interpret the intensity.
  10129. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10130. */
  10131. intensityMode: number;
  10132. private _radius;
  10133. /**
  10134. * Gets the light radius used by PBR Materials to simulate soft area lights.
  10135. */
  10136. /**
  10137. * sets the light radius used by PBR Materials to simulate soft area lights.
  10138. */
  10139. radius: number;
  10140. private _renderPriority;
  10141. /**
  10142. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  10143. * exceeding the number allowed of the materials.
  10144. */
  10145. renderPriority: number;
  10146. private _shadowEnabled;
  10147. /**
  10148. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10149. * the current shadow generator.
  10150. */
  10151. /**
  10152. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10153. * the current shadow generator.
  10154. */
  10155. shadowEnabled: boolean;
  10156. private _includedOnlyMeshes;
  10157. /**
  10158. * Gets the only meshes impacted by this light.
  10159. */
  10160. /**
  10161. * Sets the only meshes impacted by this light.
  10162. */
  10163. includedOnlyMeshes: AbstractMesh[];
  10164. private _excludedMeshes;
  10165. /**
  10166. * Gets the meshes not impacted by this light.
  10167. */
  10168. /**
  10169. * Sets the meshes not impacted by this light.
  10170. */
  10171. excludedMeshes: AbstractMesh[];
  10172. private _excludeWithLayerMask;
  10173. /**
  10174. * Gets the layer id use to find what meshes are not impacted by the light.
  10175. * Inactive if 0
  10176. */
  10177. /**
  10178. * Sets the layer id use to find what meshes are not impacted by the light.
  10179. * Inactive if 0
  10180. */
  10181. excludeWithLayerMask: number;
  10182. private _includeOnlyWithLayerMask;
  10183. /**
  10184. * Gets the layer id use to find what meshes are impacted by the light.
  10185. * Inactive if 0
  10186. */
  10187. /**
  10188. * Sets the layer id use to find what meshes are impacted by the light.
  10189. * Inactive if 0
  10190. */
  10191. includeOnlyWithLayerMask: number;
  10192. private _lightmapMode;
  10193. /**
  10194. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10195. */
  10196. /**
  10197. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10198. */
  10199. lightmapMode: number;
  10200. /**
  10201. * Shadow generator associted to the light.
  10202. * @hidden Internal use only.
  10203. */
  10204. _shadowGenerator: Nullable<IShadowGenerator>;
  10205. /**
  10206. * @hidden Internal use only.
  10207. */
  10208. _excludedMeshesIds: string[];
  10209. /**
  10210. * @hidden Internal use only.
  10211. */
  10212. _includedOnlyMeshesIds: string[];
  10213. /**
  10214. * The current light unifom buffer.
  10215. * @hidden Internal use only.
  10216. */
  10217. _uniformBuffer: UniformBuffer;
  10218. /**
  10219. * Creates a Light object in the scene.
  10220. * Documentation : https://doc.babylonjs.com/babylon101/lights
  10221. * @param name The firendly name of the light
  10222. * @param scene The scene the light belongs too
  10223. */
  10224. constructor(name: string, scene: Scene);
  10225. protected abstract _buildUniformLayout(): void;
  10226. /**
  10227. * Sets the passed Effect "effect" with the Light information.
  10228. * @param effect The effect to update
  10229. * @param lightIndex The index of the light in the effect to update
  10230. * @returns The light
  10231. */
  10232. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  10233. /**
  10234. * Returns the string "Light".
  10235. * @returns the class name
  10236. */
  10237. getClassName(): string;
  10238. /** @hidden */
  10239. readonly _isLight: boolean;
  10240. /**
  10241. * Converts the light information to a readable string for debug purpose.
  10242. * @param fullDetails Supports for multiple levels of logging within scene loading
  10243. * @returns the human readable light info
  10244. */
  10245. toString(fullDetails?: boolean): string;
  10246. /** @hidden */
  10247. protected _syncParentEnabledState(): void;
  10248. /**
  10249. * Set the enabled state of this node.
  10250. * @param value - the new enabled state
  10251. */
  10252. setEnabled(value: boolean): void;
  10253. /**
  10254. * Returns the Light associated shadow generator if any.
  10255. * @return the associated shadow generator.
  10256. */
  10257. getShadowGenerator(): Nullable<IShadowGenerator>;
  10258. /**
  10259. * Returns a Vector3, the absolute light position in the World.
  10260. * @returns the world space position of the light
  10261. */
  10262. getAbsolutePosition(): Vector3;
  10263. /**
  10264. * Specifies if the light will affect the passed mesh.
  10265. * @param mesh The mesh to test against the light
  10266. * @return true the mesh is affected otherwise, false.
  10267. */
  10268. canAffectMesh(mesh: AbstractMesh): boolean;
  10269. /**
  10270. * Sort function to order lights for rendering.
  10271. * @param a First Light object to compare to second.
  10272. * @param b Second Light object to compare first.
  10273. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10274. */
  10275. static CompareLightsPriority(a: Light, b: Light): number;
  10276. /**
  10277. * Releases resources associated with this node.
  10278. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10279. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10280. */
  10281. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10282. /**
  10283. * Returns the light type ID (integer).
  10284. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10285. */
  10286. getTypeID(): number;
  10287. /**
  10288. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10289. * @returns the scaled intensity in intensity mode unit
  10290. */
  10291. getScaledIntensity(): number;
  10292. /**
  10293. * Returns a new Light object, named "name", from the current one.
  10294. * @param name The name of the cloned light
  10295. * @returns the new created light
  10296. */
  10297. clone(name: string): Nullable<Light>;
  10298. /**
  10299. * Serializes the current light into a Serialization object.
  10300. * @returns the serialized object.
  10301. */
  10302. serialize(): any;
  10303. /**
  10304. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10305. * This new light is named "name" and added to the passed scene.
  10306. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10307. * @param name The friendly name of the light
  10308. * @param scene The scene the new light will belong to
  10309. * @returns the constructor function
  10310. */
  10311. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10312. /**
  10313. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10314. * @param parsedLight The JSON representation of the light
  10315. * @param scene The scene to create the parsed light in
  10316. * @returns the created light after parsing
  10317. */
  10318. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10319. private _hookArrayForExcluded;
  10320. private _hookArrayForIncludedOnly;
  10321. private _resyncMeshes;
  10322. /**
  10323. * Forces the meshes to update their light related information in their rendering used effects
  10324. * @hidden Internal Use Only
  10325. */
  10326. _markMeshesAsLightDirty(): void;
  10327. /**
  10328. * Recomputes the cached photometric scale if needed.
  10329. */
  10330. private _computePhotometricScale;
  10331. /**
  10332. * Returns the Photometric Scale according to the light type and intensity mode.
  10333. */
  10334. private _getPhotometricScale;
  10335. /**
  10336. * Reorder the light in the scene according to their defined priority.
  10337. * @hidden Internal Use Only
  10338. */
  10339. _reorderLightsInScene(): void;
  10340. /**
  10341. * Prepares the list of defines specific to the light type.
  10342. * @param defines the list of defines
  10343. * @param lightIndex defines the index of the light for the effect
  10344. */
  10345. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10346. }
  10347. }
  10348. declare module "babylonjs/Actions/action" {
  10349. import { Observable } from "babylonjs/Misc/observable";
  10350. import { Condition } from "babylonjs/Actions/condition";
  10351. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10352. import { ActionManager } from "babylonjs/Actions/actionManager";
  10353. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10354. /**
  10355. * Interface used to define Action
  10356. */
  10357. export interface IAction {
  10358. /**
  10359. * Trigger for the action
  10360. */
  10361. trigger: number;
  10362. /** Options of the trigger */
  10363. triggerOptions: any;
  10364. /**
  10365. * Gets the trigger parameters
  10366. * @returns the trigger parameters
  10367. */
  10368. getTriggerParameter(): any;
  10369. /**
  10370. * Internal only - executes current action event
  10371. * @hidden
  10372. */
  10373. _executeCurrent(evt?: ActionEvent): void;
  10374. /**
  10375. * Serialize placeholder for child classes
  10376. * @param parent of child
  10377. * @returns the serialized object
  10378. */
  10379. serialize(parent: any): any;
  10380. /**
  10381. * Internal only
  10382. * @hidden
  10383. */
  10384. _prepare(): void;
  10385. /**
  10386. * Internal only - manager for action
  10387. * @hidden
  10388. */
  10389. _actionManager: AbstractActionManager;
  10390. }
  10391. /**
  10392. * The action to be carried out following a trigger
  10393. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10394. */
  10395. export class Action implements IAction {
  10396. /** the trigger, with or without parameters, for the action */
  10397. triggerOptions: any;
  10398. /**
  10399. * Trigger for the action
  10400. */
  10401. trigger: number;
  10402. /**
  10403. * Internal only - manager for action
  10404. * @hidden
  10405. */
  10406. _actionManager: ActionManager;
  10407. private _nextActiveAction;
  10408. private _child;
  10409. private _condition?;
  10410. private _triggerParameter;
  10411. /**
  10412. * An event triggered prior to action being executed.
  10413. */
  10414. onBeforeExecuteObservable: Observable<Action>;
  10415. /**
  10416. * Creates a new Action
  10417. * @param triggerOptions the trigger, with or without parameters, for the action
  10418. * @param condition an optional determinant of action
  10419. */
  10420. constructor(
  10421. /** the trigger, with or without parameters, for the action */
  10422. triggerOptions: any, condition?: Condition);
  10423. /**
  10424. * Internal only
  10425. * @hidden
  10426. */
  10427. _prepare(): void;
  10428. /**
  10429. * Gets the trigger parameters
  10430. * @returns the trigger parameters
  10431. */
  10432. getTriggerParameter(): any;
  10433. /**
  10434. * Internal only - executes current action event
  10435. * @hidden
  10436. */
  10437. _executeCurrent(evt?: ActionEvent): void;
  10438. /**
  10439. * Execute placeholder for child classes
  10440. * @param evt optional action event
  10441. */
  10442. execute(evt?: ActionEvent): void;
  10443. /**
  10444. * Skips to next active action
  10445. */
  10446. skipToNextActiveAction(): void;
  10447. /**
  10448. * Adds action to chain of actions, may be a DoNothingAction
  10449. * @param action defines the next action to execute
  10450. * @returns The action passed in
  10451. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10452. */
  10453. then(action: Action): Action;
  10454. /**
  10455. * Internal only
  10456. * @hidden
  10457. */
  10458. _getProperty(propertyPath: string): string;
  10459. /**
  10460. * Internal only
  10461. * @hidden
  10462. */
  10463. _getEffectiveTarget(target: any, propertyPath: string): any;
  10464. /**
  10465. * Serialize placeholder for child classes
  10466. * @param parent of child
  10467. * @returns the serialized object
  10468. */
  10469. serialize(parent: any): any;
  10470. /**
  10471. * Internal only called by serialize
  10472. * @hidden
  10473. */
  10474. protected _serialize(serializedAction: any, parent?: any): any;
  10475. /**
  10476. * Internal only
  10477. * @hidden
  10478. */
  10479. static _SerializeValueAsString: (value: any) => string;
  10480. /**
  10481. * Internal only
  10482. * @hidden
  10483. */
  10484. static _GetTargetProperty: (target: import("babylonjs/scene").Scene | import("babylonjs/node").Node) => {
  10485. name: string;
  10486. targetType: string;
  10487. value: string;
  10488. };
  10489. }
  10490. }
  10491. declare module "babylonjs/Actions/condition" {
  10492. import { ActionManager } from "babylonjs/Actions/actionManager";
  10493. /**
  10494. * A Condition applied to an Action
  10495. */
  10496. export class Condition {
  10497. /**
  10498. * Internal only - manager for action
  10499. * @hidden
  10500. */
  10501. _actionManager: ActionManager;
  10502. /**
  10503. * Internal only
  10504. * @hidden
  10505. */
  10506. _evaluationId: number;
  10507. /**
  10508. * Internal only
  10509. * @hidden
  10510. */
  10511. _currentResult: boolean;
  10512. /**
  10513. * Creates a new Condition
  10514. * @param actionManager the manager of the action the condition is applied to
  10515. */
  10516. constructor(actionManager: ActionManager);
  10517. /**
  10518. * Check if the current condition is valid
  10519. * @returns a boolean
  10520. */
  10521. isValid(): boolean;
  10522. /**
  10523. * Internal only
  10524. * @hidden
  10525. */
  10526. _getProperty(propertyPath: string): string;
  10527. /**
  10528. * Internal only
  10529. * @hidden
  10530. */
  10531. _getEffectiveTarget(target: any, propertyPath: string): any;
  10532. /**
  10533. * Serialize placeholder for child classes
  10534. * @returns the serialized object
  10535. */
  10536. serialize(): any;
  10537. /**
  10538. * Internal only
  10539. * @hidden
  10540. */
  10541. protected _serialize(serializedCondition: any): any;
  10542. }
  10543. /**
  10544. * Defines specific conditional operators as extensions of Condition
  10545. */
  10546. export class ValueCondition extends Condition {
  10547. /** path to specify the property of the target the conditional operator uses */
  10548. propertyPath: string;
  10549. /** the value compared by the conditional operator against the current value of the property */
  10550. value: any;
  10551. /** the conditional operator, default ValueCondition.IsEqual */
  10552. operator: number;
  10553. /**
  10554. * Internal only
  10555. * @hidden
  10556. */
  10557. private static _IsEqual;
  10558. /**
  10559. * Internal only
  10560. * @hidden
  10561. */
  10562. private static _IsDifferent;
  10563. /**
  10564. * Internal only
  10565. * @hidden
  10566. */
  10567. private static _IsGreater;
  10568. /**
  10569. * Internal only
  10570. * @hidden
  10571. */
  10572. private static _IsLesser;
  10573. /**
  10574. * returns the number for IsEqual
  10575. */
  10576. static readonly IsEqual: number;
  10577. /**
  10578. * Returns the number for IsDifferent
  10579. */
  10580. static readonly IsDifferent: number;
  10581. /**
  10582. * Returns the number for IsGreater
  10583. */
  10584. static readonly IsGreater: number;
  10585. /**
  10586. * Returns the number for IsLesser
  10587. */
  10588. static readonly IsLesser: number;
  10589. /**
  10590. * Internal only The action manager for the condition
  10591. * @hidden
  10592. */
  10593. _actionManager: ActionManager;
  10594. /**
  10595. * Internal only
  10596. * @hidden
  10597. */
  10598. private _target;
  10599. /**
  10600. * Internal only
  10601. * @hidden
  10602. */
  10603. private _effectiveTarget;
  10604. /**
  10605. * Internal only
  10606. * @hidden
  10607. */
  10608. private _property;
  10609. /**
  10610. * Creates a new ValueCondition
  10611. * @param actionManager manager for the action the condition applies to
  10612. * @param target for the action
  10613. * @param propertyPath path to specify the property of the target the conditional operator uses
  10614. * @param value the value compared by the conditional operator against the current value of the property
  10615. * @param operator the conditional operator, default ValueCondition.IsEqual
  10616. */
  10617. constructor(actionManager: ActionManager, target: any,
  10618. /** path to specify the property of the target the conditional operator uses */
  10619. propertyPath: string,
  10620. /** the value compared by the conditional operator against the current value of the property */
  10621. value: any,
  10622. /** the conditional operator, default ValueCondition.IsEqual */
  10623. operator?: number);
  10624. /**
  10625. * Compares the given value with the property value for the specified conditional operator
  10626. * @returns the result of the comparison
  10627. */
  10628. isValid(): boolean;
  10629. /**
  10630. * Serialize the ValueCondition into a JSON compatible object
  10631. * @returns serialization object
  10632. */
  10633. serialize(): any;
  10634. /**
  10635. * Gets the name of the conditional operator for the ValueCondition
  10636. * @param operator the conditional operator
  10637. * @returns the name
  10638. */
  10639. static GetOperatorName(operator: number): string;
  10640. }
  10641. /**
  10642. * Defines a predicate condition as an extension of Condition
  10643. */
  10644. export class PredicateCondition extends Condition {
  10645. /** defines the predicate function used to validate the condition */
  10646. predicate: () => boolean;
  10647. /**
  10648. * Internal only - manager for action
  10649. * @hidden
  10650. */
  10651. _actionManager: ActionManager;
  10652. /**
  10653. * Creates a new PredicateCondition
  10654. * @param actionManager manager for the action the condition applies to
  10655. * @param predicate defines the predicate function used to validate the condition
  10656. */
  10657. constructor(actionManager: ActionManager,
  10658. /** defines the predicate function used to validate the condition */
  10659. predicate: () => boolean);
  10660. /**
  10661. * @returns the validity of the predicate condition
  10662. */
  10663. isValid(): boolean;
  10664. }
  10665. /**
  10666. * Defines a state condition as an extension of Condition
  10667. */
  10668. export class StateCondition extends Condition {
  10669. /** Value to compare with target state */
  10670. value: string;
  10671. /**
  10672. * Internal only - manager for action
  10673. * @hidden
  10674. */
  10675. _actionManager: ActionManager;
  10676. /**
  10677. * Internal only
  10678. * @hidden
  10679. */
  10680. private _target;
  10681. /**
  10682. * Creates a new StateCondition
  10683. * @param actionManager manager for the action the condition applies to
  10684. * @param target of the condition
  10685. * @param value to compare with target state
  10686. */
  10687. constructor(actionManager: ActionManager, target: any,
  10688. /** Value to compare with target state */
  10689. value: string);
  10690. /**
  10691. * Gets a boolean indicating if the current condition is met
  10692. * @returns the validity of the state
  10693. */
  10694. isValid(): boolean;
  10695. /**
  10696. * Serialize the StateCondition into a JSON compatible object
  10697. * @returns serialization object
  10698. */
  10699. serialize(): any;
  10700. }
  10701. }
  10702. declare module "babylonjs/Actions/directActions" {
  10703. import { Action } from "babylonjs/Actions/action";
  10704. import { Condition } from "babylonjs/Actions/condition";
  10705. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10706. /**
  10707. * This defines an action responsible to toggle a boolean once triggered.
  10708. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10709. */
  10710. export class SwitchBooleanAction extends Action {
  10711. /**
  10712. * The path to the boolean property in the target object
  10713. */
  10714. propertyPath: string;
  10715. private _target;
  10716. private _effectiveTarget;
  10717. private _property;
  10718. /**
  10719. * Instantiate the action
  10720. * @param triggerOptions defines the trigger options
  10721. * @param target defines the object containing the boolean
  10722. * @param propertyPath defines the path to the boolean property in the target object
  10723. * @param condition defines the trigger related conditions
  10724. */
  10725. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10726. /** @hidden */
  10727. _prepare(): void;
  10728. /**
  10729. * Execute the action toggle the boolean value.
  10730. */
  10731. execute(): void;
  10732. /**
  10733. * Serializes the actions and its related information.
  10734. * @param parent defines the object to serialize in
  10735. * @returns the serialized object
  10736. */
  10737. serialize(parent: any): any;
  10738. }
  10739. /**
  10740. * This defines an action responsible to set a the state field of the target
  10741. * to a desired value once triggered.
  10742. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10743. */
  10744. export class SetStateAction extends Action {
  10745. /**
  10746. * The value to store in the state field.
  10747. */
  10748. value: string;
  10749. private _target;
  10750. /**
  10751. * Instantiate the action
  10752. * @param triggerOptions defines the trigger options
  10753. * @param target defines the object containing the state property
  10754. * @param value defines the value to store in the state field
  10755. * @param condition defines the trigger related conditions
  10756. */
  10757. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10758. /**
  10759. * Execute the action and store the value on the target state property.
  10760. */
  10761. execute(): void;
  10762. /**
  10763. * Serializes the actions and its related information.
  10764. * @param parent defines the object to serialize in
  10765. * @returns the serialized object
  10766. */
  10767. serialize(parent: any): any;
  10768. }
  10769. /**
  10770. * This defines an action responsible to set a property of the target
  10771. * to a desired value once triggered.
  10772. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10773. */
  10774. export class SetValueAction extends Action {
  10775. /**
  10776. * The path of the property to set in the target.
  10777. */
  10778. propertyPath: string;
  10779. /**
  10780. * The value to set in the property
  10781. */
  10782. value: any;
  10783. private _target;
  10784. private _effectiveTarget;
  10785. private _property;
  10786. /**
  10787. * Instantiate the action
  10788. * @param triggerOptions defines the trigger options
  10789. * @param target defines the object containing the property
  10790. * @param propertyPath defines the path of the property to set in the target
  10791. * @param value defines the value to set in the property
  10792. * @param condition defines the trigger related conditions
  10793. */
  10794. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10795. /** @hidden */
  10796. _prepare(): void;
  10797. /**
  10798. * Execute the action and set the targetted property to the desired value.
  10799. */
  10800. execute(): void;
  10801. /**
  10802. * Serializes the actions and its related information.
  10803. * @param parent defines the object to serialize in
  10804. * @returns the serialized object
  10805. */
  10806. serialize(parent: any): any;
  10807. }
  10808. /**
  10809. * This defines an action responsible to increment the target value
  10810. * to a desired value once triggered.
  10811. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10812. */
  10813. export class IncrementValueAction extends Action {
  10814. /**
  10815. * The path of the property to increment in the target.
  10816. */
  10817. propertyPath: string;
  10818. /**
  10819. * The value we should increment the property by.
  10820. */
  10821. value: any;
  10822. private _target;
  10823. private _effectiveTarget;
  10824. private _property;
  10825. /**
  10826. * Instantiate the action
  10827. * @param triggerOptions defines the trigger options
  10828. * @param target defines the object containing the property
  10829. * @param propertyPath defines the path of the property to increment in the target
  10830. * @param value defines the value value we should increment the property by
  10831. * @param condition defines the trigger related conditions
  10832. */
  10833. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10834. /** @hidden */
  10835. _prepare(): void;
  10836. /**
  10837. * Execute the action and increment the target of the value amount.
  10838. */
  10839. execute(): void;
  10840. /**
  10841. * Serializes the actions and its related information.
  10842. * @param parent defines the object to serialize in
  10843. * @returns the serialized object
  10844. */
  10845. serialize(parent: any): any;
  10846. }
  10847. /**
  10848. * This defines an action responsible to start an animation once triggered.
  10849. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10850. */
  10851. export class PlayAnimationAction extends Action {
  10852. /**
  10853. * Where the animation should start (animation frame)
  10854. */
  10855. from: number;
  10856. /**
  10857. * Where the animation should stop (animation frame)
  10858. */
  10859. to: number;
  10860. /**
  10861. * Define if the animation should loop or stop after the first play.
  10862. */
  10863. loop?: boolean;
  10864. private _target;
  10865. /**
  10866. * Instantiate the action
  10867. * @param triggerOptions defines the trigger options
  10868. * @param target defines the target animation or animation name
  10869. * @param from defines from where the animation should start (animation frame)
  10870. * @param end defines where the animation should stop (animation frame)
  10871. * @param loop defines if the animation should loop or stop after the first play
  10872. * @param condition defines the trigger related conditions
  10873. */
  10874. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10875. /** @hidden */
  10876. _prepare(): void;
  10877. /**
  10878. * Execute the action and play the animation.
  10879. */
  10880. execute(): void;
  10881. /**
  10882. * Serializes the actions and its related information.
  10883. * @param parent defines the object to serialize in
  10884. * @returns the serialized object
  10885. */
  10886. serialize(parent: any): any;
  10887. }
  10888. /**
  10889. * This defines an action responsible to stop an animation once triggered.
  10890. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10891. */
  10892. export class StopAnimationAction extends Action {
  10893. private _target;
  10894. /**
  10895. * Instantiate the action
  10896. * @param triggerOptions defines the trigger options
  10897. * @param target defines the target animation or animation name
  10898. * @param condition defines the trigger related conditions
  10899. */
  10900. constructor(triggerOptions: any, target: any, condition?: Condition);
  10901. /** @hidden */
  10902. _prepare(): void;
  10903. /**
  10904. * Execute the action and stop the animation.
  10905. */
  10906. execute(): void;
  10907. /**
  10908. * Serializes the actions and its related information.
  10909. * @param parent defines the object to serialize in
  10910. * @returns the serialized object
  10911. */
  10912. serialize(parent: any): any;
  10913. }
  10914. /**
  10915. * This defines an action responsible that does nothing once triggered.
  10916. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10917. */
  10918. export class DoNothingAction extends Action {
  10919. /**
  10920. * Instantiate the action
  10921. * @param triggerOptions defines the trigger options
  10922. * @param condition defines the trigger related conditions
  10923. */
  10924. constructor(triggerOptions?: any, condition?: Condition);
  10925. /**
  10926. * Execute the action and do nothing.
  10927. */
  10928. execute(): void;
  10929. /**
  10930. * Serializes the actions and its related information.
  10931. * @param parent defines the object to serialize in
  10932. * @returns the serialized object
  10933. */
  10934. serialize(parent: any): any;
  10935. }
  10936. /**
  10937. * This defines an action responsible to trigger several actions once triggered.
  10938. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10939. */
  10940. export class CombineAction extends Action {
  10941. /**
  10942. * The list of aggregated animations to run.
  10943. */
  10944. children: Action[];
  10945. /**
  10946. * Instantiate the action
  10947. * @param triggerOptions defines the trigger options
  10948. * @param children defines the list of aggregated animations to run
  10949. * @param condition defines the trigger related conditions
  10950. */
  10951. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10952. /** @hidden */
  10953. _prepare(): void;
  10954. /**
  10955. * Execute the action and executes all the aggregated actions.
  10956. */
  10957. execute(evt: ActionEvent): void;
  10958. /**
  10959. * Serializes the actions and its related information.
  10960. * @param parent defines the object to serialize in
  10961. * @returns the serialized object
  10962. */
  10963. serialize(parent: any): any;
  10964. }
  10965. /**
  10966. * This defines an action responsible to run code (external event) once triggered.
  10967. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10968. */
  10969. export class ExecuteCodeAction extends Action {
  10970. /**
  10971. * The callback function to run.
  10972. */
  10973. func: (evt: ActionEvent) => void;
  10974. /**
  10975. * Instantiate the action
  10976. * @param triggerOptions defines the trigger options
  10977. * @param func defines the callback function to run
  10978. * @param condition defines the trigger related conditions
  10979. */
  10980. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10981. /**
  10982. * Execute the action and run the attached code.
  10983. */
  10984. execute(evt: ActionEvent): void;
  10985. }
  10986. /**
  10987. * This defines an action responsible to set the parent property of the target once triggered.
  10988. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10989. */
  10990. export class SetParentAction extends Action {
  10991. private _parent;
  10992. private _target;
  10993. /**
  10994. * Instantiate the action
  10995. * @param triggerOptions defines the trigger options
  10996. * @param target defines the target containing the parent property
  10997. * @param parent defines from where the animation should start (animation frame)
  10998. * @param condition defines the trigger related conditions
  10999. */
  11000. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  11001. /** @hidden */
  11002. _prepare(): void;
  11003. /**
  11004. * Execute the action and set the parent property.
  11005. */
  11006. execute(): void;
  11007. /**
  11008. * Serializes the actions and its related information.
  11009. * @param parent defines the object to serialize in
  11010. * @returns the serialized object
  11011. */
  11012. serialize(parent: any): any;
  11013. }
  11014. }
  11015. declare module "babylonjs/Actions/actionManager" {
  11016. import { Nullable } from "babylonjs/types";
  11017. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11018. import { Scene } from "babylonjs/scene";
  11019. import { IAction } from "babylonjs/Actions/action";
  11020. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  11021. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  11022. /**
  11023. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  11024. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  11025. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11026. */
  11027. export class ActionManager extends AbstractActionManager {
  11028. /**
  11029. * Nothing
  11030. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11031. */
  11032. static readonly NothingTrigger: number;
  11033. /**
  11034. * On pick
  11035. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11036. */
  11037. static readonly OnPickTrigger: number;
  11038. /**
  11039. * On left pick
  11040. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11041. */
  11042. static readonly OnLeftPickTrigger: number;
  11043. /**
  11044. * On right pick
  11045. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11046. */
  11047. static readonly OnRightPickTrigger: number;
  11048. /**
  11049. * On center pick
  11050. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11051. */
  11052. static readonly OnCenterPickTrigger: number;
  11053. /**
  11054. * On pick down
  11055. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11056. */
  11057. static readonly OnPickDownTrigger: number;
  11058. /**
  11059. * On double pick
  11060. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11061. */
  11062. static readonly OnDoublePickTrigger: number;
  11063. /**
  11064. * On pick up
  11065. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11066. */
  11067. static readonly OnPickUpTrigger: number;
  11068. /**
  11069. * On pick out.
  11070. * This trigger will only be raised if you also declared a OnPickDown
  11071. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11072. */
  11073. static readonly OnPickOutTrigger: number;
  11074. /**
  11075. * On long press
  11076. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11077. */
  11078. static readonly OnLongPressTrigger: number;
  11079. /**
  11080. * On pointer over
  11081. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11082. */
  11083. static readonly OnPointerOverTrigger: number;
  11084. /**
  11085. * On pointer out
  11086. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11087. */
  11088. static readonly OnPointerOutTrigger: number;
  11089. /**
  11090. * On every frame
  11091. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11092. */
  11093. static readonly OnEveryFrameTrigger: number;
  11094. /**
  11095. * On intersection enter
  11096. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11097. */
  11098. static readonly OnIntersectionEnterTrigger: number;
  11099. /**
  11100. * On intersection exit
  11101. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11102. */
  11103. static readonly OnIntersectionExitTrigger: number;
  11104. /**
  11105. * On key down
  11106. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11107. */
  11108. static readonly OnKeyDownTrigger: number;
  11109. /**
  11110. * On key up
  11111. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11112. */
  11113. static readonly OnKeyUpTrigger: number;
  11114. private _scene;
  11115. /**
  11116. * Creates a new action manager
  11117. * @param scene defines the hosting scene
  11118. */
  11119. constructor(scene: Scene);
  11120. /**
  11121. * Releases all associated resources
  11122. */
  11123. dispose(): void;
  11124. /**
  11125. * Gets hosting scene
  11126. * @returns the hosting scene
  11127. */
  11128. getScene(): Scene;
  11129. /**
  11130. * Does this action manager handles actions of any of the given triggers
  11131. * @param triggers defines the triggers to be tested
  11132. * @return a boolean indicating whether one (or more) of the triggers is handled
  11133. */
  11134. hasSpecificTriggers(triggers: number[]): boolean;
  11135. /**
  11136. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  11137. * speed.
  11138. * @param triggerA defines the trigger to be tested
  11139. * @param triggerB defines the trigger to be tested
  11140. * @return a boolean indicating whether one (or more) of the triggers is handled
  11141. */
  11142. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  11143. /**
  11144. * Does this action manager handles actions of a given trigger
  11145. * @param trigger defines the trigger to be tested
  11146. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  11147. * @return whether the trigger is handled
  11148. */
  11149. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  11150. /**
  11151. * Does this action manager has pointer triggers
  11152. */
  11153. readonly hasPointerTriggers: boolean;
  11154. /**
  11155. * Does this action manager has pick triggers
  11156. */
  11157. readonly hasPickTriggers: boolean;
  11158. /**
  11159. * Registers an action to this action manager
  11160. * @param action defines the action to be registered
  11161. * @return the action amended (prepared) after registration
  11162. */
  11163. registerAction(action: IAction): Nullable<IAction>;
  11164. /**
  11165. * Unregisters an action to this action manager
  11166. * @param action defines the action to be unregistered
  11167. * @return a boolean indicating whether the action has been unregistered
  11168. */
  11169. unregisterAction(action: IAction): Boolean;
  11170. /**
  11171. * Process a specific trigger
  11172. * @param trigger defines the trigger to process
  11173. * @param evt defines the event details to be processed
  11174. */
  11175. processTrigger(trigger: number, evt?: IActionEvent): void;
  11176. /** @hidden */
  11177. _getEffectiveTarget(target: any, propertyPath: string): any;
  11178. /** @hidden */
  11179. _getProperty(propertyPath: string): string;
  11180. /**
  11181. * Serialize this manager to a JSON object
  11182. * @param name defines the property name to store this manager
  11183. * @returns a JSON representation of this manager
  11184. */
  11185. serialize(name: string): any;
  11186. /**
  11187. * Creates a new ActionManager from a JSON data
  11188. * @param parsedActions defines the JSON data to read from
  11189. * @param object defines the hosting mesh
  11190. * @param scene defines the hosting scene
  11191. */
  11192. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  11193. /**
  11194. * Get a trigger name by index
  11195. * @param trigger defines the trigger index
  11196. * @returns a trigger name
  11197. */
  11198. static GetTriggerName(trigger: number): string;
  11199. }
  11200. }
  11201. declare module "babylonjs/Culling/ray" {
  11202. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  11203. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  11204. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11205. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11206. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  11207. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  11208. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  11209. /**
  11210. * Class representing a ray with position and direction
  11211. */
  11212. export class Ray {
  11213. /** origin point */
  11214. origin: Vector3;
  11215. /** direction */
  11216. direction: Vector3;
  11217. /** length of the ray */
  11218. length: number;
  11219. private static readonly TmpVector3;
  11220. private _tmpRay;
  11221. /**
  11222. * Creates a new ray
  11223. * @param origin origin point
  11224. * @param direction direction
  11225. * @param length length of the ray
  11226. */
  11227. constructor(
  11228. /** origin point */
  11229. origin: Vector3,
  11230. /** direction */
  11231. direction: Vector3,
  11232. /** length of the ray */
  11233. length?: number);
  11234. /**
  11235. * Checks if the ray intersects a box
  11236. * @param minimum bound of the box
  11237. * @param maximum bound of the box
  11238. * @param intersectionTreshold extra extend to be added to the box in all direction
  11239. * @returns if the box was hit
  11240. */
  11241. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11242. /**
  11243. * Checks if the ray intersects a box
  11244. * @param box the bounding box to check
  11245. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11246. * @returns if the box was hit
  11247. */
  11248. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11249. /**
  11250. * If the ray hits a sphere
  11251. * @param sphere the bounding sphere to check
  11252. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11253. * @returns true if it hits the sphere
  11254. */
  11255. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11256. /**
  11257. * If the ray hits a triange
  11258. * @param vertex0 triangle vertex
  11259. * @param vertex1 triangle vertex
  11260. * @param vertex2 triangle vertex
  11261. * @returns intersection information if hit
  11262. */
  11263. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11264. /**
  11265. * Checks if ray intersects a plane
  11266. * @param plane the plane to check
  11267. * @returns the distance away it was hit
  11268. */
  11269. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11270. /**
  11271. * Checks if ray intersects a mesh
  11272. * @param mesh the mesh to check
  11273. * @param fastCheck if only the bounding box should checked
  11274. * @returns picking info of the intersecton
  11275. */
  11276. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11277. /**
  11278. * Checks if ray intersects a mesh
  11279. * @param meshes the meshes to check
  11280. * @param fastCheck if only the bounding box should checked
  11281. * @param results array to store result in
  11282. * @returns Array of picking infos
  11283. */
  11284. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11285. private _comparePickingInfo;
  11286. private static smallnum;
  11287. private static rayl;
  11288. /**
  11289. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11290. * @param sega the first point of the segment to test the intersection against
  11291. * @param segb the second point of the segment to test the intersection against
  11292. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11293. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11294. */
  11295. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11296. /**
  11297. * Update the ray from viewport position
  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 this ray updated
  11306. */
  11307. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11308. /**
  11309. * Creates a ray with origin and direction of 0,0,0
  11310. * @returns the new ray
  11311. */
  11312. static Zero(): Ray;
  11313. /**
  11314. * Creates a new ray from screen space and viewport
  11315. * @param x position
  11316. * @param y y position
  11317. * @param viewportWidth viewport width
  11318. * @param viewportHeight viewport height
  11319. * @param world world matrix
  11320. * @param view view matrix
  11321. * @param projection projection matrix
  11322. * @returns new ray
  11323. */
  11324. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11325. /**
  11326. * 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
  11327. * transformed to the given world matrix.
  11328. * @param origin The origin point
  11329. * @param end The end point
  11330. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11331. * @returns the new ray
  11332. */
  11333. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11334. /**
  11335. * Transforms a ray by a matrix
  11336. * @param ray ray to transform
  11337. * @param matrix matrix to apply
  11338. * @returns the resulting new ray
  11339. */
  11340. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11341. /**
  11342. * Transforms a ray by a matrix
  11343. * @param ray ray to transform
  11344. * @param matrix matrix to apply
  11345. * @param result ray to store result in
  11346. */
  11347. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11348. /**
  11349. * Unproject a ray from screen space to object space
  11350. * @param sourceX defines the screen space x coordinate to use
  11351. * @param sourceY defines the screen space y coordinate to use
  11352. * @param viewportWidth defines the current width of the viewport
  11353. * @param viewportHeight defines the current height of the viewport
  11354. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11355. * @param view defines the view matrix to use
  11356. * @param projection defines the projection matrix to use
  11357. */
  11358. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11359. }
  11360. /**
  11361. * Type used to define predicate used to select faces when a mesh intersection is detected
  11362. */
  11363. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11364. module "babylonjs/scene" {
  11365. interface Scene {
  11366. /** @hidden */
  11367. _tempPickingRay: Nullable<Ray>;
  11368. /** @hidden */
  11369. _cachedRayForTransform: Ray;
  11370. /** @hidden */
  11371. _pickWithRayInverseMatrix: Matrix;
  11372. /** @hidden */
  11373. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11374. /** @hidden */
  11375. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11376. }
  11377. }
  11378. }
  11379. declare module "babylonjs/sceneComponent" {
  11380. import { Scene } from "babylonjs/scene";
  11381. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11382. import { SubMesh } from "babylonjs/Meshes/subMesh";
  11383. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  11384. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  11385. import { Nullable } from "babylonjs/types";
  11386. import { Camera } from "babylonjs/Cameras/camera";
  11387. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  11388. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11389. import { AbstractScene } from "babylonjs/abstractScene";
  11390. /**
  11391. * Groups all the scene component constants in one place to ease maintenance.
  11392. * @hidden
  11393. */
  11394. export class SceneComponentConstants {
  11395. static readonly NAME_EFFECTLAYER: string;
  11396. static readonly NAME_LAYER: string;
  11397. static readonly NAME_LENSFLARESYSTEM: string;
  11398. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11399. static readonly NAME_PARTICLESYSTEM: string;
  11400. static readonly NAME_GAMEPAD: string;
  11401. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11402. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11403. static readonly NAME_DEPTHRENDERER: string;
  11404. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11405. static readonly NAME_SPRITE: string;
  11406. static readonly NAME_OUTLINERENDERER: string;
  11407. static readonly NAME_PROCEDURALTEXTURE: string;
  11408. static readonly NAME_SHADOWGENERATOR: string;
  11409. static readonly NAME_OCTREE: string;
  11410. static readonly NAME_PHYSICSENGINE: string;
  11411. static readonly NAME_AUDIO: string;
  11412. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11413. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11414. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11415. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11416. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11417. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11418. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11419. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11420. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11421. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11422. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11423. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11424. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11425. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11426. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11427. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11428. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11429. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11430. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11431. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11432. static readonly STEP_AFTERRENDER_AUDIO: number;
  11433. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11434. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11435. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11436. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11437. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11438. static readonly STEP_POINTERMOVE_SPRITE: number;
  11439. static readonly STEP_POINTERDOWN_SPRITE: number;
  11440. static readonly STEP_POINTERUP_SPRITE: number;
  11441. }
  11442. /**
  11443. * This represents a scene component.
  11444. *
  11445. * This is used to decouple the dependency the scene is having on the different workloads like
  11446. * layers, post processes...
  11447. */
  11448. export interface ISceneComponent {
  11449. /**
  11450. * The name of the component. Each component must have a unique name.
  11451. */
  11452. name: string;
  11453. /**
  11454. * The scene the component belongs to.
  11455. */
  11456. scene: Scene;
  11457. /**
  11458. * Register the component to one instance of a scene.
  11459. */
  11460. register(): void;
  11461. /**
  11462. * Rebuilds the elements related to this component in case of
  11463. * context lost for instance.
  11464. */
  11465. rebuild(): void;
  11466. /**
  11467. * Disposes the component and the associated ressources.
  11468. */
  11469. dispose(): void;
  11470. }
  11471. /**
  11472. * This represents a SERIALIZABLE scene component.
  11473. *
  11474. * This extends Scene Component to add Serialization methods on top.
  11475. */
  11476. export interface ISceneSerializableComponent extends ISceneComponent {
  11477. /**
  11478. * Adds all the element from the container to the scene
  11479. * @param container the container holding the elements
  11480. */
  11481. addFromContainer(container: AbstractScene): void;
  11482. /**
  11483. * Removes all the elements in the container from the scene
  11484. * @param container contains the elements to remove
  11485. */
  11486. removeFromContainer(container: AbstractScene): void;
  11487. /**
  11488. * Serializes the component data to the specified json object
  11489. * @param serializationObject The object to serialize to
  11490. */
  11491. serialize(serializationObject: any): void;
  11492. }
  11493. /**
  11494. * Strong typing of a Mesh related stage step action
  11495. */
  11496. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11497. /**
  11498. * Strong typing of a Evaluate Sub Mesh related stage step action
  11499. */
  11500. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11501. /**
  11502. * Strong typing of a Active Mesh related stage step action
  11503. */
  11504. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11505. /**
  11506. * Strong typing of a Camera related stage step action
  11507. */
  11508. export type CameraStageAction = (camera: Camera) => void;
  11509. /**
  11510. * Strong typing of a Render Target related stage step action
  11511. */
  11512. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11513. /**
  11514. * Strong typing of a RenderingGroup related stage step action
  11515. */
  11516. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11517. /**
  11518. * Strong typing of a Mesh Render related stage step action
  11519. */
  11520. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11521. /**
  11522. * Strong typing of a simple stage step action
  11523. */
  11524. export type SimpleStageAction = () => void;
  11525. /**
  11526. * Strong typing of a render target action.
  11527. */
  11528. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11529. /**
  11530. * Strong typing of a pointer move action.
  11531. */
  11532. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  11533. /**
  11534. * Strong typing of a pointer up/down action.
  11535. */
  11536. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11537. /**
  11538. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  11539. * @hidden
  11540. */
  11541. export class Stage<T extends Function> extends Array<{
  11542. index: number;
  11543. component: ISceneComponent;
  11544. action: T;
  11545. }> {
  11546. /**
  11547. * Hide ctor from the rest of the world.
  11548. * @param items The items to add.
  11549. */
  11550. private constructor();
  11551. /**
  11552. * Creates a new Stage.
  11553. * @returns A new instance of a Stage
  11554. */
  11555. static Create<T extends Function>(): Stage<T>;
  11556. /**
  11557. * Registers a step in an ordered way in the targeted stage.
  11558. * @param index Defines the position to register the step in
  11559. * @param component Defines the component attached to the step
  11560. * @param action Defines the action to launch during the step
  11561. */
  11562. registerStep(index: number, component: ISceneComponent, action: T): void;
  11563. /**
  11564. * Clears all the steps from the stage.
  11565. */
  11566. clear(): void;
  11567. }
  11568. }
  11569. declare module "babylonjs/Sprites/spriteSceneComponent" {
  11570. import { Nullable } from "babylonjs/types";
  11571. import { Observable } from "babylonjs/Misc/observable";
  11572. import { Scene } from "babylonjs/scene";
  11573. import { Sprite } from "babylonjs/Sprites/sprite";
  11574. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11575. import { Ray } from "babylonjs/Culling/ray";
  11576. import { Camera } from "babylonjs/Cameras/camera";
  11577. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11578. import { ISceneComponent } from "babylonjs/sceneComponent";
  11579. module "babylonjs/scene" {
  11580. interface Scene {
  11581. /** @hidden */
  11582. _pointerOverSprite: Nullable<Sprite>;
  11583. /** @hidden */
  11584. _pickedDownSprite: Nullable<Sprite>;
  11585. /** @hidden */
  11586. _tempSpritePickingRay: Nullable<Ray>;
  11587. /**
  11588. * All of the sprite managers added to this scene
  11589. * @see http://doc.babylonjs.com/babylon101/sprites
  11590. */
  11591. spriteManagers: Array<ISpriteManager>;
  11592. /**
  11593. * An event triggered when sprites rendering is about to start
  11594. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11595. */
  11596. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11597. /**
  11598. * An event triggered when sprites rendering is done
  11599. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11600. */
  11601. onAfterSpritesRenderingObservable: Observable<Scene>;
  11602. /** @hidden */
  11603. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11604. /** Launch a ray to try to pick a sprite in the scene
  11605. * @param x position on screen
  11606. * @param y position on screen
  11607. * @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
  11608. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11609. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11610. * @returns a PickingInfo
  11611. */
  11612. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11613. /** Use the given ray to pick a sprite in the scene
  11614. * @param ray The ray (in world space) to use to pick meshes
  11615. * @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
  11616. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11617. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11618. * @returns a PickingInfo
  11619. */
  11620. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11621. /**
  11622. * Force the sprite under the pointer
  11623. * @param sprite defines the sprite to use
  11624. */
  11625. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11626. /**
  11627. * Gets the sprite under the pointer
  11628. * @returns a Sprite or null if no sprite is under the pointer
  11629. */
  11630. getPointerOverSprite(): Nullable<Sprite>;
  11631. }
  11632. }
  11633. /**
  11634. * Defines the sprite scene component responsible to manage sprites
  11635. * in a given scene.
  11636. */
  11637. export class SpriteSceneComponent implements ISceneComponent {
  11638. /**
  11639. * The component name helpfull to identify the component in the list of scene components.
  11640. */
  11641. readonly name: string;
  11642. /**
  11643. * The scene the component belongs to.
  11644. */
  11645. scene: Scene;
  11646. /** @hidden */
  11647. private _spritePredicate;
  11648. /**
  11649. * Creates a new instance of the component for the given scene
  11650. * @param scene Defines the scene to register the component in
  11651. */
  11652. constructor(scene: Scene);
  11653. /**
  11654. * Registers the component in a given scene
  11655. */
  11656. register(): void;
  11657. /**
  11658. * Rebuilds the elements related to this component in case of
  11659. * context lost for instance.
  11660. */
  11661. rebuild(): void;
  11662. /**
  11663. * Disposes the component and the associated ressources.
  11664. */
  11665. dispose(): void;
  11666. private _pickSpriteButKeepRay;
  11667. private _pointerMove;
  11668. private _pointerDown;
  11669. private _pointerUp;
  11670. }
  11671. }
  11672. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  11673. /** @hidden */
  11674. export var fogFragmentDeclaration: {
  11675. name: string;
  11676. shader: string;
  11677. };
  11678. }
  11679. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  11680. /** @hidden */
  11681. export var fogFragment: {
  11682. name: string;
  11683. shader: string;
  11684. };
  11685. }
  11686. declare module "babylonjs/Shaders/sprites.fragment" {
  11687. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  11688. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  11689. /** @hidden */
  11690. export var spritesPixelShader: {
  11691. name: string;
  11692. shader: string;
  11693. };
  11694. }
  11695. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  11696. /** @hidden */
  11697. export var fogVertexDeclaration: {
  11698. name: string;
  11699. shader: string;
  11700. };
  11701. }
  11702. declare module "babylonjs/Shaders/sprites.vertex" {
  11703. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  11704. /** @hidden */
  11705. export var spritesVertexShader: {
  11706. name: string;
  11707. shader: string;
  11708. };
  11709. }
  11710. declare module "babylonjs/Sprites/spriteManager" {
  11711. import { IDisposable, Scene } from "babylonjs/scene";
  11712. import { Nullable } from "babylonjs/types";
  11713. import { Observable } from "babylonjs/Misc/observable";
  11714. import { Sprite } from "babylonjs/Sprites/sprite";
  11715. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11716. import { Camera } from "babylonjs/Cameras/camera";
  11717. import { Texture } from "babylonjs/Materials/Textures/texture";
  11718. import "babylonjs/Shaders/sprites.fragment";
  11719. import "babylonjs/Shaders/sprites.vertex";
  11720. import { Ray } from "babylonjs/Culling/ray";
  11721. /**
  11722. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11723. */
  11724. export interface ISpriteManager extends IDisposable {
  11725. /**
  11726. * Restricts the camera to viewing objects with the same layerMask.
  11727. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11728. */
  11729. layerMask: number;
  11730. /**
  11731. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11732. */
  11733. isPickable: boolean;
  11734. /**
  11735. * Specifies the rendering group id for this mesh (0 by default)
  11736. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11737. */
  11738. renderingGroupId: number;
  11739. /**
  11740. * Defines the list of sprites managed by the manager.
  11741. */
  11742. sprites: Array<Sprite>;
  11743. /**
  11744. * Tests the intersection of a sprite with a specific ray.
  11745. * @param ray The ray we are sending to test the collision
  11746. * @param camera The camera space we are sending rays in
  11747. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11748. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11749. * @returns picking info or null.
  11750. */
  11751. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11752. /**
  11753. * Renders the list of sprites on screen.
  11754. */
  11755. render(): void;
  11756. }
  11757. /**
  11758. * Class used to manage multiple sprites on the same spritesheet
  11759. * @see http://doc.babylonjs.com/babylon101/sprites
  11760. */
  11761. export class SpriteManager implements ISpriteManager {
  11762. /** defines the manager's name */
  11763. name: string;
  11764. /** Gets the list of sprites */
  11765. sprites: Sprite[];
  11766. /** Gets or sets the rendering group id (0 by default) */
  11767. renderingGroupId: number;
  11768. /** Gets or sets camera layer mask */
  11769. layerMask: number;
  11770. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11771. fogEnabled: boolean;
  11772. /** Gets or sets a boolean indicating if the sprites are pickable */
  11773. isPickable: boolean;
  11774. /** Defines the default width of a cell in the spritesheet */
  11775. cellWidth: number;
  11776. /** Defines the default height of a cell in the spritesheet */
  11777. cellHeight: number;
  11778. /**
  11779. * An event triggered when the manager is disposed.
  11780. */
  11781. onDisposeObservable: Observable<SpriteManager>;
  11782. private _onDisposeObserver;
  11783. /**
  11784. * Callback called when the manager is disposed
  11785. */
  11786. onDispose: () => void;
  11787. private _capacity;
  11788. private _spriteTexture;
  11789. private _epsilon;
  11790. private _scene;
  11791. private _vertexData;
  11792. private _buffer;
  11793. private _vertexBuffers;
  11794. private _indexBuffer;
  11795. private _effectBase;
  11796. private _effectFog;
  11797. /**
  11798. * Gets or sets the spritesheet texture
  11799. */
  11800. texture: Texture;
  11801. /**
  11802. * Creates a new sprite manager
  11803. * @param name defines the manager's name
  11804. * @param imgUrl defines the sprite sheet url
  11805. * @param capacity defines the maximum allowed number of sprites
  11806. * @param cellSize defines the size of a sprite cell
  11807. * @param scene defines the hosting scene
  11808. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11809. * @param samplingMode defines the smapling mode to use with spritesheet
  11810. */
  11811. constructor(
  11812. /** defines the manager's name */
  11813. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  11814. private _appendSpriteVertex;
  11815. /**
  11816. * Intersects the sprites with a ray
  11817. * @param ray defines the ray to intersect with
  11818. * @param camera defines the current active camera
  11819. * @param predicate defines a predicate used to select candidate sprites
  11820. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11821. * @returns null if no hit or a PickingInfo
  11822. */
  11823. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11824. /**
  11825. * Render all child sprites
  11826. */
  11827. render(): void;
  11828. /**
  11829. * Release associated resources
  11830. */
  11831. dispose(): void;
  11832. }
  11833. }
  11834. declare module "babylonjs/Sprites/sprite" {
  11835. import { Vector3, Color4 } from "babylonjs/Maths/math";
  11836. import { Nullable } from "babylonjs/types";
  11837. import { ActionManager } from "babylonjs/Actions/actionManager";
  11838. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11839. /**
  11840. * Class used to represent a sprite
  11841. * @see http://doc.babylonjs.com/babylon101/sprites
  11842. */
  11843. export class Sprite {
  11844. /** defines the name */
  11845. name: string;
  11846. /** Gets or sets the current world position */
  11847. position: Vector3;
  11848. /** Gets or sets the main color */
  11849. color: Color4;
  11850. /** Gets or sets the width */
  11851. width: number;
  11852. /** Gets or sets the height */
  11853. height: number;
  11854. /** Gets or sets rotation angle */
  11855. angle: number;
  11856. /** Gets or sets the cell index in the sprite sheet */
  11857. cellIndex: number;
  11858. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  11859. invertU: number;
  11860. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  11861. invertV: number;
  11862. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  11863. disposeWhenFinishedAnimating: boolean;
  11864. /** Gets the list of attached animations */
  11865. animations: Animation[];
  11866. /** Gets or sets a boolean indicating if the sprite can be picked */
  11867. isPickable: boolean;
  11868. /**
  11869. * Gets or sets the associated action manager
  11870. */
  11871. actionManager: Nullable<ActionManager>;
  11872. private _animationStarted;
  11873. private _loopAnimation;
  11874. private _fromIndex;
  11875. private _toIndex;
  11876. private _delay;
  11877. private _direction;
  11878. private _manager;
  11879. private _time;
  11880. private _onAnimationEnd;
  11881. /**
  11882. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  11883. */
  11884. isVisible: boolean;
  11885. /**
  11886. * Gets or sets the sprite size
  11887. */
  11888. size: number;
  11889. /**
  11890. * Creates a new Sprite
  11891. * @param name defines the name
  11892. * @param manager defines the manager
  11893. */
  11894. constructor(
  11895. /** defines the name */
  11896. name: string, manager: ISpriteManager);
  11897. /**
  11898. * Starts an animation
  11899. * @param from defines the initial key
  11900. * @param to defines the end key
  11901. * @param loop defines if the animation must loop
  11902. * @param delay defines the start delay (in ms)
  11903. * @param onAnimationEnd defines a callback to call when animation ends
  11904. */
  11905. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  11906. /** Stops current animation (if any) */
  11907. stopAnimation(): void;
  11908. /** @hidden */
  11909. _animate(deltaTime: number): void;
  11910. /** Release associated resources */
  11911. dispose(): void;
  11912. }
  11913. }
  11914. declare module "babylonjs/Collisions/pickingInfo" {
  11915. import { Nullable } from "babylonjs/types";
  11916. import { Vector3, Vector2 } from "babylonjs/Maths/math";
  11917. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11918. import { Sprite } from "babylonjs/Sprites/sprite";
  11919. import { Ray } from "babylonjs/Culling/ray";
  11920. /**
  11921. * Information about the result of picking within a scene
  11922. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  11923. */
  11924. export class PickingInfo {
  11925. /** @hidden */
  11926. _pickingUnavailable: boolean;
  11927. /**
  11928. * If the pick collided with an object
  11929. */
  11930. hit: boolean;
  11931. /**
  11932. * Distance away where the pick collided
  11933. */
  11934. distance: number;
  11935. /**
  11936. * The location of pick collision
  11937. */
  11938. pickedPoint: Nullable<Vector3>;
  11939. /**
  11940. * The mesh corresponding the the pick collision
  11941. */
  11942. pickedMesh: Nullable<AbstractMesh>;
  11943. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  11944. bu: number;
  11945. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  11946. bv: number;
  11947. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  11948. faceId: number;
  11949. /** Id of the the submesh that was picked */
  11950. subMeshId: number;
  11951. /** If a sprite was picked, this will be the sprite the pick collided with */
  11952. pickedSprite: Nullable<Sprite>;
  11953. /**
  11954. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  11955. */
  11956. originMesh: Nullable<AbstractMesh>;
  11957. /**
  11958. * The ray that was used to perform the picking.
  11959. */
  11960. ray: Nullable<Ray>;
  11961. /**
  11962. * Gets the normal correspodning to the face the pick collided with
  11963. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  11964. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  11965. * @returns The normal correspodning to the face the pick collided with
  11966. */
  11967. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  11968. /**
  11969. * Gets the texture coordinates of where the pick occured
  11970. * @returns the vector containing the coordnates of the texture
  11971. */
  11972. getTextureCoordinates(): Nullable<Vector2>;
  11973. }
  11974. }
  11975. declare module "babylonjs/Events/pointerEvents" {
  11976. import { Nullable } from "babylonjs/types";
  11977. import { Vector2 } from "babylonjs/Maths/math";
  11978. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11979. import { Ray } from "babylonjs/Culling/ray";
  11980. /**
  11981. * Gather the list of pointer event types as constants.
  11982. */
  11983. export class PointerEventTypes {
  11984. /**
  11985. * 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.
  11986. */
  11987. static readonly POINTERDOWN: number;
  11988. /**
  11989. * The pointerup event is fired when a pointer is no longer active.
  11990. */
  11991. static readonly POINTERUP: number;
  11992. /**
  11993. * The pointermove event is fired when a pointer changes coordinates.
  11994. */
  11995. static readonly POINTERMOVE: number;
  11996. /**
  11997. * The pointerwheel event is fired when a mouse wheel has been rotated.
  11998. */
  11999. static readonly POINTERWHEEL: number;
  12000. /**
  12001. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  12002. */
  12003. static readonly POINTERPICK: number;
  12004. /**
  12005. * The pointertap event is fired when a the object has been touched and released without drag.
  12006. */
  12007. static readonly POINTERTAP: number;
  12008. /**
  12009. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  12010. */
  12011. static readonly POINTERDOUBLETAP: number;
  12012. }
  12013. /**
  12014. * Base class of pointer info types.
  12015. */
  12016. export class PointerInfoBase {
  12017. /**
  12018. * Defines the type of event (PointerEventTypes)
  12019. */
  12020. type: number;
  12021. /**
  12022. * Defines the related dom event
  12023. */
  12024. event: PointerEvent | MouseWheelEvent;
  12025. /**
  12026. * Instantiates the base class of pointers info.
  12027. * @param type Defines the type of event (PointerEventTypes)
  12028. * @param event Defines the related dom event
  12029. */
  12030. constructor(
  12031. /**
  12032. * Defines the type of event (PointerEventTypes)
  12033. */
  12034. type: number,
  12035. /**
  12036. * Defines the related dom event
  12037. */
  12038. event: PointerEvent | MouseWheelEvent);
  12039. }
  12040. /**
  12041. * This class is used to store pointer related info for the onPrePointerObservable event.
  12042. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  12043. */
  12044. export class PointerInfoPre extends PointerInfoBase {
  12045. /**
  12046. * Ray from a pointer if availible (eg. 6dof controller)
  12047. */
  12048. ray: Nullable<Ray>;
  12049. /**
  12050. * Defines the local position of the pointer on the canvas.
  12051. */
  12052. localPosition: Vector2;
  12053. /**
  12054. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  12055. */
  12056. skipOnPointerObservable: boolean;
  12057. /**
  12058. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  12059. * @param type Defines the type of event (PointerEventTypes)
  12060. * @param event Defines the related dom event
  12061. * @param localX Defines the local x coordinates of the pointer when the event occured
  12062. * @param localY Defines the local y coordinates of the pointer when the event occured
  12063. */
  12064. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  12065. }
  12066. /**
  12067. * This type contains all the data related to a pointer event in Babylon.js.
  12068. * 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.
  12069. */
  12070. export class PointerInfo extends PointerInfoBase {
  12071. /**
  12072. * Defines the picking info associated to the info (if any)\
  12073. */
  12074. pickInfo: Nullable<PickingInfo>;
  12075. /**
  12076. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  12077. * @param type Defines the type of event (PointerEventTypes)
  12078. * @param event Defines the related dom event
  12079. * @param pickInfo Defines the picking info associated to the info (if any)\
  12080. */
  12081. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  12082. /**
  12083. * Defines the picking info associated to the info (if any)\
  12084. */
  12085. pickInfo: Nullable<PickingInfo>);
  12086. }
  12087. /**
  12088. * Data relating to a touch event on the screen.
  12089. */
  12090. export interface PointerTouch {
  12091. /**
  12092. * X coordinate of touch.
  12093. */
  12094. x: number;
  12095. /**
  12096. * Y coordinate of touch.
  12097. */
  12098. y: number;
  12099. /**
  12100. * Id of touch. Unique for each finger.
  12101. */
  12102. pointerId: number;
  12103. /**
  12104. * Event type passed from DOM.
  12105. */
  12106. type: any;
  12107. }
  12108. }
  12109. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  12110. import { Nullable } from "babylonjs/types";
  12111. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12112. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12113. /**
  12114. * Manage the mouse inputs to control the movement of a free camera.
  12115. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12116. */
  12117. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  12118. /**
  12119. * Define if touch is enabled in the mouse input
  12120. */
  12121. touchEnabled: boolean;
  12122. /**
  12123. * Defines the camera the input is attached to.
  12124. */
  12125. camera: FreeCamera;
  12126. /**
  12127. * Defines the buttons associated with the input to handle camera move.
  12128. */
  12129. buttons: number[];
  12130. /**
  12131. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  12132. */
  12133. angularSensibility: number;
  12134. private _pointerInput;
  12135. private _onMouseMove;
  12136. private _observer;
  12137. private previousPosition;
  12138. /**
  12139. * Manage the mouse inputs to control the movement of a free camera.
  12140. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12141. * @param touchEnabled Defines if touch is enabled or not
  12142. */
  12143. constructor(
  12144. /**
  12145. * Define if touch is enabled in the mouse input
  12146. */
  12147. touchEnabled?: boolean);
  12148. /**
  12149. * Attach the input controls to a specific dom element to get the input from.
  12150. * @param element Defines the element the controls should be listened from
  12151. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12152. */
  12153. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12154. /**
  12155. * Detach the current controls from the specified dom element.
  12156. * @param element Defines the element to stop listening the inputs from
  12157. */
  12158. detachControl(element: Nullable<HTMLElement>): void;
  12159. /**
  12160. * Gets the class name of the current intput.
  12161. * @returns the class name
  12162. */
  12163. getClassName(): string;
  12164. /**
  12165. * Get the friendly name associated with the input class.
  12166. * @returns the input friendly name
  12167. */
  12168. getSimpleName(): string;
  12169. }
  12170. }
  12171. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  12172. import { Nullable } from "babylonjs/types";
  12173. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12174. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12175. /**
  12176. * Manage the touch inputs to control the movement of a free camera.
  12177. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12178. */
  12179. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  12180. /**
  12181. * Defines the camera the input is attached to.
  12182. */
  12183. camera: FreeCamera;
  12184. /**
  12185. * Defines the touch sensibility for rotation.
  12186. * The higher the faster.
  12187. */
  12188. touchAngularSensibility: number;
  12189. /**
  12190. * Defines the touch sensibility for move.
  12191. * The higher the faster.
  12192. */
  12193. touchMoveSensibility: number;
  12194. private _offsetX;
  12195. private _offsetY;
  12196. private _pointerPressed;
  12197. private _pointerInput;
  12198. private _observer;
  12199. private _onLostFocus;
  12200. /**
  12201. * Attach the input controls to a specific dom element to get the input from.
  12202. * @param element Defines the element the controls should be listened from
  12203. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12204. */
  12205. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12206. /**
  12207. * Detach the current controls from the specified dom element.
  12208. * @param element Defines the element to stop listening the inputs from
  12209. */
  12210. detachControl(element: Nullable<HTMLElement>): void;
  12211. /**
  12212. * Update the current camera state depending on the inputs that have been used this frame.
  12213. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12214. */
  12215. checkInputs(): void;
  12216. /**
  12217. * Gets the class name of the current intput.
  12218. * @returns the class name
  12219. */
  12220. getClassName(): string;
  12221. /**
  12222. * Get the friendly name associated with the input class.
  12223. * @returns the input friendly name
  12224. */
  12225. getSimpleName(): string;
  12226. }
  12227. }
  12228. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  12229. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12230. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  12231. /**
  12232. * Default Inputs manager for the FreeCamera.
  12233. * It groups all the default supported inputs for ease of use.
  12234. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12235. */
  12236. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12237. /**
  12238. * Instantiates a new FreeCameraInputsManager.
  12239. * @param camera Defines the camera the inputs belong to
  12240. */
  12241. constructor(camera: FreeCamera);
  12242. /**
  12243. * Add keyboard input support to the input manager.
  12244. * @returns the current input manager
  12245. */
  12246. addKeyboard(): FreeCameraInputsManager;
  12247. /**
  12248. * Add mouse input support to the input manager.
  12249. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12250. * @returns the current input manager
  12251. */
  12252. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12253. /**
  12254. * Add touch input support to the input manager.
  12255. * @returns the current input manager
  12256. */
  12257. addTouch(): FreeCameraInputsManager;
  12258. }
  12259. }
  12260. declare module "babylonjs/Cameras/freeCamera" {
  12261. import { Vector3 } from "babylonjs/Maths/math";
  12262. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12263. import { Scene } from "babylonjs/scene";
  12264. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  12265. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  12266. /**
  12267. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12268. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12269. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12270. */
  12271. export class FreeCamera extends TargetCamera {
  12272. /**
  12273. * Define the collision ellipsoid of the camera.
  12274. * This is helpful to simulate a camera body like the player body around the camera
  12275. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12276. */
  12277. ellipsoid: Vector3;
  12278. /**
  12279. * Define an offset for the position of the ellipsoid around the camera.
  12280. * This can be helpful to determine the center of the body near the gravity center of the body
  12281. * instead of its head.
  12282. */
  12283. ellipsoidOffset: Vector3;
  12284. /**
  12285. * Enable or disable collisions of the camera with the rest of the scene objects.
  12286. */
  12287. checkCollisions: boolean;
  12288. /**
  12289. * Enable or disable gravity on the camera.
  12290. */
  12291. applyGravity: boolean;
  12292. /**
  12293. * Define the input manager associated to the camera.
  12294. */
  12295. inputs: FreeCameraInputsManager;
  12296. /**
  12297. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12298. * Higher values reduce sensitivity.
  12299. */
  12300. /**
  12301. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12302. * Higher values reduce sensitivity.
  12303. */
  12304. angularSensibility: number;
  12305. /**
  12306. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12307. */
  12308. keysUp: number[];
  12309. /**
  12310. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12311. */
  12312. keysDown: number[];
  12313. /**
  12314. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12315. */
  12316. keysLeft: number[];
  12317. /**
  12318. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12319. */
  12320. keysRight: number[];
  12321. /**
  12322. * Event raised when the camera collide with a mesh in the scene.
  12323. */
  12324. onCollide: (collidedMesh: AbstractMesh) => void;
  12325. private _collider;
  12326. private _needMoveForGravity;
  12327. private _oldPosition;
  12328. private _diffPosition;
  12329. private _newPosition;
  12330. /** @hidden */
  12331. _localDirection: Vector3;
  12332. /** @hidden */
  12333. _transformedDirection: Vector3;
  12334. /**
  12335. * Instantiates a Free Camera.
  12336. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12337. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12338. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12339. * @param name Define the name of the camera in the scene
  12340. * @param position Define the start position of the camera in the scene
  12341. * @param scene Define the scene the camera belongs to
  12342. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12343. */
  12344. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12345. /**
  12346. * Attached controls to the current camera.
  12347. * @param element Defines the element the controls should be listened from
  12348. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12349. */
  12350. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12351. /**
  12352. * Detach the current controls from the camera.
  12353. * The camera will stop reacting to inputs.
  12354. * @param element Defines the element to stop listening the inputs from
  12355. */
  12356. detachControl(element: HTMLElement): void;
  12357. private _collisionMask;
  12358. /**
  12359. * Define a collision mask to limit the list of object the camera can collide with
  12360. */
  12361. collisionMask: number;
  12362. /** @hidden */
  12363. _collideWithWorld(displacement: Vector3): void;
  12364. private _onCollisionPositionChange;
  12365. /** @hidden */
  12366. _checkInputs(): void;
  12367. /** @hidden */
  12368. _decideIfNeedsToMove(): boolean;
  12369. /** @hidden */
  12370. _updatePosition(): void;
  12371. /**
  12372. * Destroy the camera and release the current resources hold by it.
  12373. */
  12374. dispose(): void;
  12375. /**
  12376. * Gets the current object class name.
  12377. * @return the class name
  12378. */
  12379. getClassName(): string;
  12380. }
  12381. }
  12382. declare module "babylonjs/Gamepads/gamepad" {
  12383. import { Observable } from "babylonjs/Misc/observable";
  12384. /**
  12385. * Represents a gamepad control stick position
  12386. */
  12387. export class StickValues {
  12388. /**
  12389. * The x component of the control stick
  12390. */
  12391. x: number;
  12392. /**
  12393. * The y component of the control stick
  12394. */
  12395. y: number;
  12396. /**
  12397. * Initializes the gamepad x and y control stick values
  12398. * @param x The x component of the gamepad control stick value
  12399. * @param y The y component of the gamepad control stick value
  12400. */
  12401. constructor(
  12402. /**
  12403. * The x component of the control stick
  12404. */
  12405. x: number,
  12406. /**
  12407. * The y component of the control stick
  12408. */
  12409. y: number);
  12410. }
  12411. /**
  12412. * An interface which manages callbacks for gamepad button changes
  12413. */
  12414. export interface GamepadButtonChanges {
  12415. /**
  12416. * Called when a gamepad has been changed
  12417. */
  12418. changed: boolean;
  12419. /**
  12420. * Called when a gamepad press event has been triggered
  12421. */
  12422. pressChanged: boolean;
  12423. /**
  12424. * Called when a touch event has been triggered
  12425. */
  12426. touchChanged: boolean;
  12427. /**
  12428. * Called when a value has changed
  12429. */
  12430. valueChanged: boolean;
  12431. }
  12432. /**
  12433. * Represents a gamepad
  12434. */
  12435. export class Gamepad {
  12436. /**
  12437. * The id of the gamepad
  12438. */
  12439. id: string;
  12440. /**
  12441. * The index of the gamepad
  12442. */
  12443. index: number;
  12444. /**
  12445. * The browser gamepad
  12446. */
  12447. browserGamepad: any;
  12448. /**
  12449. * Specifies what type of gamepad this represents
  12450. */
  12451. type: number;
  12452. private _leftStick;
  12453. private _rightStick;
  12454. /** @hidden */
  12455. _isConnected: boolean;
  12456. private _leftStickAxisX;
  12457. private _leftStickAxisY;
  12458. private _rightStickAxisX;
  12459. private _rightStickAxisY;
  12460. /**
  12461. * Triggered when the left control stick has been changed
  12462. */
  12463. private _onleftstickchanged;
  12464. /**
  12465. * Triggered when the right control stick has been changed
  12466. */
  12467. private _onrightstickchanged;
  12468. /**
  12469. * Represents a gamepad controller
  12470. */
  12471. static GAMEPAD: number;
  12472. /**
  12473. * Represents a generic controller
  12474. */
  12475. static GENERIC: number;
  12476. /**
  12477. * Represents an XBox controller
  12478. */
  12479. static XBOX: number;
  12480. /**
  12481. * Represents a pose-enabled controller
  12482. */
  12483. static POSE_ENABLED: number;
  12484. /**
  12485. * Specifies whether the left control stick should be Y-inverted
  12486. */
  12487. protected _invertLeftStickY: boolean;
  12488. /**
  12489. * Specifies if the gamepad has been connected
  12490. */
  12491. readonly isConnected: boolean;
  12492. /**
  12493. * Initializes the gamepad
  12494. * @param id The id of the gamepad
  12495. * @param index The index of the gamepad
  12496. * @param browserGamepad The browser gamepad
  12497. * @param leftStickX The x component of the left joystick
  12498. * @param leftStickY The y component of the left joystick
  12499. * @param rightStickX The x component of the right joystick
  12500. * @param rightStickY The y component of the right joystick
  12501. */
  12502. constructor(
  12503. /**
  12504. * The id of the gamepad
  12505. */
  12506. id: string,
  12507. /**
  12508. * The index of the gamepad
  12509. */
  12510. index: number,
  12511. /**
  12512. * The browser gamepad
  12513. */
  12514. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12515. /**
  12516. * Callback triggered when the left joystick has changed
  12517. * @param callback
  12518. */
  12519. onleftstickchanged(callback: (values: StickValues) => void): void;
  12520. /**
  12521. * Callback triggered when the right joystick has changed
  12522. * @param callback
  12523. */
  12524. onrightstickchanged(callback: (values: StickValues) => void): void;
  12525. /**
  12526. * Gets the left joystick
  12527. */
  12528. /**
  12529. * Sets the left joystick values
  12530. */
  12531. leftStick: StickValues;
  12532. /**
  12533. * Gets the right joystick
  12534. */
  12535. /**
  12536. * Sets the right joystick value
  12537. */
  12538. rightStick: StickValues;
  12539. /**
  12540. * Updates the gamepad joystick positions
  12541. */
  12542. update(): void;
  12543. /**
  12544. * Disposes the gamepad
  12545. */
  12546. dispose(): void;
  12547. }
  12548. /**
  12549. * Represents a generic gamepad
  12550. */
  12551. export class GenericPad extends Gamepad {
  12552. private _buttons;
  12553. private _onbuttondown;
  12554. private _onbuttonup;
  12555. /**
  12556. * Observable triggered when a button has been pressed
  12557. */
  12558. onButtonDownObservable: Observable<number>;
  12559. /**
  12560. * Observable triggered when a button has been released
  12561. */
  12562. onButtonUpObservable: Observable<number>;
  12563. /**
  12564. * Callback triggered when a button has been pressed
  12565. * @param callback Called when a button has been pressed
  12566. */
  12567. onbuttondown(callback: (buttonPressed: number) => void): void;
  12568. /**
  12569. * Callback triggered when a button has been released
  12570. * @param callback Called when a button has been released
  12571. */
  12572. onbuttonup(callback: (buttonReleased: number) => void): void;
  12573. /**
  12574. * Initializes the generic gamepad
  12575. * @param id The id of the generic gamepad
  12576. * @param index The index of the generic gamepad
  12577. * @param browserGamepad The browser gamepad
  12578. */
  12579. constructor(id: string, index: number, browserGamepad: any);
  12580. private _setButtonValue;
  12581. /**
  12582. * Updates the generic gamepad
  12583. */
  12584. update(): void;
  12585. /**
  12586. * Disposes the generic gamepad
  12587. */
  12588. dispose(): void;
  12589. }
  12590. }
  12591. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  12592. import { Observable } from "babylonjs/Misc/observable";
  12593. import { Nullable } from "babylonjs/types";
  12594. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  12595. import { TransformNode } from "babylonjs/Meshes/transformNode";
  12596. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12597. import { Ray } from "babylonjs/Culling/ray";
  12598. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  12599. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  12600. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  12601. /**
  12602. * Defines the types of pose enabled controllers that are supported
  12603. */
  12604. export enum PoseEnabledControllerType {
  12605. /**
  12606. * HTC Vive
  12607. */
  12608. VIVE = 0,
  12609. /**
  12610. * Oculus Rift
  12611. */
  12612. OCULUS = 1,
  12613. /**
  12614. * Windows mixed reality
  12615. */
  12616. WINDOWS = 2,
  12617. /**
  12618. * Samsung gear VR
  12619. */
  12620. GEAR_VR = 3,
  12621. /**
  12622. * Google Daydream
  12623. */
  12624. DAYDREAM = 4,
  12625. /**
  12626. * Generic
  12627. */
  12628. GENERIC = 5
  12629. }
  12630. /**
  12631. * Defines the MutableGamepadButton interface for the state of a gamepad button
  12632. */
  12633. export interface MutableGamepadButton {
  12634. /**
  12635. * Value of the button/trigger
  12636. */
  12637. value: number;
  12638. /**
  12639. * If the button/trigger is currently touched
  12640. */
  12641. touched: boolean;
  12642. /**
  12643. * If the button/trigger is currently pressed
  12644. */
  12645. pressed: boolean;
  12646. }
  12647. /**
  12648. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  12649. * @hidden
  12650. */
  12651. export interface ExtendedGamepadButton extends GamepadButton {
  12652. /**
  12653. * If the button/trigger is currently pressed
  12654. */
  12655. readonly pressed: boolean;
  12656. /**
  12657. * If the button/trigger is currently touched
  12658. */
  12659. readonly touched: boolean;
  12660. /**
  12661. * Value of the button/trigger
  12662. */
  12663. readonly value: number;
  12664. }
  12665. /** @hidden */
  12666. export interface _GamePadFactory {
  12667. /**
  12668. * Returns wether or not the current gamepad can be created for this type of controller.
  12669. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  12670. * @returns true if it can be created, otherwise false
  12671. */
  12672. canCreate(gamepadInfo: any): boolean;
  12673. /**
  12674. * Creates a new instance of the Gamepad.
  12675. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  12676. * @returns the new gamepad instance
  12677. */
  12678. create(gamepadInfo: any): Gamepad;
  12679. }
  12680. /**
  12681. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  12682. */
  12683. export class PoseEnabledControllerHelper {
  12684. /** @hidden */
  12685. static _ControllerFactories: _GamePadFactory[];
  12686. /** @hidden */
  12687. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  12688. /**
  12689. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  12690. * @param vrGamepad the gamepad to initialized
  12691. * @returns a vr controller of the type the gamepad identified as
  12692. */
  12693. static InitiateController(vrGamepad: any): Gamepad;
  12694. }
  12695. /**
  12696. * Defines the PoseEnabledController object that contains state of a vr capable controller
  12697. */
  12698. export class PoseEnabledController extends Gamepad implements PoseControlled {
  12699. private _deviceRoomPosition;
  12700. private _deviceRoomRotationQuaternion;
  12701. /**
  12702. * The device position in babylon space
  12703. */
  12704. devicePosition: Vector3;
  12705. /**
  12706. * The device rotation in babylon space
  12707. */
  12708. deviceRotationQuaternion: Quaternion;
  12709. /**
  12710. * The scale factor of the device in babylon space
  12711. */
  12712. deviceScaleFactor: number;
  12713. /**
  12714. * (Likely devicePosition should be used instead) The device position in its room space
  12715. */
  12716. position: Vector3;
  12717. /**
  12718. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  12719. */
  12720. rotationQuaternion: Quaternion;
  12721. /**
  12722. * The type of controller (Eg. Windows mixed reality)
  12723. */
  12724. controllerType: PoseEnabledControllerType;
  12725. protected _calculatedPosition: Vector3;
  12726. private _calculatedRotation;
  12727. /**
  12728. * The raw pose from the device
  12729. */
  12730. rawPose: DevicePose;
  12731. private _trackPosition;
  12732. private _maxRotationDistFromHeadset;
  12733. private _draggedRoomRotation;
  12734. /**
  12735. * @hidden
  12736. */
  12737. _disableTrackPosition(fixedPosition: Vector3): void;
  12738. /**
  12739. * Internal, the mesh attached to the controller
  12740. * @hidden
  12741. */
  12742. _mesh: Nullable<AbstractMesh>;
  12743. private _poseControlledCamera;
  12744. private _leftHandSystemQuaternion;
  12745. /**
  12746. * Internal, matrix used to convert room space to babylon space
  12747. * @hidden
  12748. */
  12749. _deviceToWorld: Matrix;
  12750. /**
  12751. * Node to be used when casting a ray from the controller
  12752. * @hidden
  12753. */
  12754. _pointingPoseNode: Nullable<TransformNode>;
  12755. /**
  12756. * Name of the child mesh that can be used to cast a ray from the controller
  12757. */
  12758. static readonly POINTING_POSE: string;
  12759. /**
  12760. * Creates a new PoseEnabledController from a gamepad
  12761. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  12762. */
  12763. constructor(browserGamepad: any);
  12764. private _workingMatrix;
  12765. /**
  12766. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  12767. */
  12768. update(): void;
  12769. /**
  12770. * Updates only the pose device and mesh without doing any button event checking
  12771. */
  12772. protected _updatePoseAndMesh(): void;
  12773. /**
  12774. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  12775. * @param poseData raw pose fromthe device
  12776. */
  12777. updateFromDevice(poseData: DevicePose): void;
  12778. /**
  12779. * @hidden
  12780. */
  12781. _meshAttachedObservable: Observable<AbstractMesh>;
  12782. /**
  12783. * Attaches a mesh to the controller
  12784. * @param mesh the mesh to be attached
  12785. */
  12786. attachToMesh(mesh: AbstractMesh): void;
  12787. /**
  12788. * Attaches the controllers mesh to a camera
  12789. * @param camera the camera the mesh should be attached to
  12790. */
  12791. attachToPoseControlledCamera(camera: TargetCamera): void;
  12792. /**
  12793. * Disposes of the controller
  12794. */
  12795. dispose(): void;
  12796. /**
  12797. * The mesh that is attached to the controller
  12798. */
  12799. readonly mesh: Nullable<AbstractMesh>;
  12800. /**
  12801. * Gets the ray of the controller in the direction the controller is pointing
  12802. * @param length the length the resulting ray should be
  12803. * @returns a ray in the direction the controller is pointing
  12804. */
  12805. getForwardRay(length?: number): Ray;
  12806. }
  12807. }
  12808. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  12809. import { Observable } from "babylonjs/Misc/observable";
  12810. import { Scene } from "babylonjs/scene";
  12811. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12812. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  12813. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  12814. /**
  12815. * Defines the WebVRController object that represents controllers tracked in 3D space
  12816. */
  12817. export abstract class WebVRController extends PoseEnabledController {
  12818. /**
  12819. * Internal, the default controller model for the controller
  12820. */
  12821. protected _defaultModel: AbstractMesh;
  12822. /**
  12823. * Fired when the trigger state has changed
  12824. */
  12825. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  12826. /**
  12827. * Fired when the main button state has changed
  12828. */
  12829. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  12830. /**
  12831. * Fired when the secondary button state has changed
  12832. */
  12833. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  12834. /**
  12835. * Fired when the pad state has changed
  12836. */
  12837. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  12838. /**
  12839. * Fired when controllers stick values have changed
  12840. */
  12841. onPadValuesChangedObservable: Observable<StickValues>;
  12842. /**
  12843. * Array of button availible on the controller
  12844. */
  12845. protected _buttons: Array<MutableGamepadButton>;
  12846. private _onButtonStateChange;
  12847. /**
  12848. * Fired when a controller button's state has changed
  12849. * @param callback the callback containing the button that was modified
  12850. */
  12851. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  12852. /**
  12853. * X and Y axis corrisponding to the controllers joystick
  12854. */
  12855. pad: StickValues;
  12856. /**
  12857. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  12858. */
  12859. hand: string;
  12860. /**
  12861. * The default controller model for the controller
  12862. */
  12863. readonly defaultModel: AbstractMesh;
  12864. /**
  12865. * Creates a new WebVRController from a gamepad
  12866. * @param vrGamepad the gamepad that the WebVRController should be created from
  12867. */
  12868. constructor(vrGamepad: any);
  12869. /**
  12870. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  12871. */
  12872. update(): void;
  12873. /**
  12874. * Function to be called when a button is modified
  12875. */
  12876. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  12877. /**
  12878. * Loads a mesh and attaches it to the controller
  12879. * @param scene the scene the mesh should be added to
  12880. * @param meshLoaded callback for when the mesh has been loaded
  12881. */
  12882. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  12883. private _setButtonValue;
  12884. private _changes;
  12885. private _checkChanges;
  12886. /**
  12887. * Disposes of th webVRCOntroller
  12888. */
  12889. dispose(): void;
  12890. }
  12891. }
  12892. declare module "babylonjs/Lights/hemisphericLight" {
  12893. import { Nullable } from "babylonjs/types";
  12894. import { Scene } from "babylonjs/scene";
  12895. import { Matrix, Vector3, Color3 } from "babylonjs/Maths/math";
  12896. import { Effect } from "babylonjs/Materials/effect";
  12897. import { Light } from "babylonjs/Lights/light";
  12898. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  12899. /**
  12900. * The HemisphericLight simulates the ambient environment light,
  12901. * so the passed direction is the light reflection direction, not the incoming direction.
  12902. */
  12903. export class HemisphericLight extends Light {
  12904. /**
  12905. * The groundColor is the light in the opposite direction to the one specified during creation.
  12906. * 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.
  12907. */
  12908. groundColor: Color3;
  12909. /**
  12910. * The light reflection direction, not the incoming direction.
  12911. */
  12912. direction: Vector3;
  12913. /**
  12914. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  12915. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  12916. * The HemisphericLight can't cast shadows.
  12917. * Documentation : https://doc.babylonjs.com/babylon101/lights
  12918. * @param name The friendly name of the light
  12919. * @param direction The direction of the light reflection
  12920. * @param scene The scene the light belongs to
  12921. */
  12922. constructor(name: string, direction: Vector3, scene: Scene);
  12923. protected _buildUniformLayout(): void;
  12924. /**
  12925. * Returns the string "HemisphericLight".
  12926. * @return The class name
  12927. */
  12928. getClassName(): string;
  12929. /**
  12930. * Sets the HemisphericLight direction towards the passed target (Vector3).
  12931. * Returns the updated direction.
  12932. * @param target The target the direction should point to
  12933. * @return The computed direction
  12934. */
  12935. setDirectionToTarget(target: Vector3): Vector3;
  12936. /**
  12937. * Returns the shadow generator associated to the light.
  12938. * @returns Always null for hemispheric lights because it does not support shadows.
  12939. */
  12940. getShadowGenerator(): Nullable<IShadowGenerator>;
  12941. /**
  12942. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  12943. * @param effect The effect to update
  12944. * @param lightIndex The index of the light in the effect to update
  12945. * @returns The hemispheric light
  12946. */
  12947. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  12948. /**
  12949. * Computes the world matrix of the node
  12950. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  12951. * @param useWasUpdatedFlag defines a reserved property
  12952. * @returns the world matrix
  12953. */
  12954. computeWorldMatrix(): Matrix;
  12955. /**
  12956. * Returns the integer 3.
  12957. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  12958. */
  12959. getTypeID(): number;
  12960. /**
  12961. * Prepares the list of defines specific to the light type.
  12962. * @param defines the list of defines
  12963. * @param lightIndex defines the index of the light for the effect
  12964. */
  12965. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  12966. }
  12967. }
  12968. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  12969. declare module "babylonjs/Cameras/VR/webVRCamera" {
  12970. import { Nullable } from "babylonjs/types";
  12971. import { Observable } from "babylonjs/Misc/observable";
  12972. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12973. import { Scene } from "babylonjs/scene";
  12974. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  12975. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  12976. import { Node } from "babylonjs/node";
  12977. import { Ray } from "babylonjs/Culling/ray";
  12978. import "babylonjs/Cameras/RigModes/webVRRigMode";
  12979. /**
  12980. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  12981. * IMPORTANT!! The data is right-hand data.
  12982. * @export
  12983. * @interface DevicePose
  12984. */
  12985. export interface DevicePose {
  12986. /**
  12987. * The position of the device, values in array are [x,y,z].
  12988. */
  12989. readonly position: Nullable<Float32Array>;
  12990. /**
  12991. * The linearVelocity of the device, values in array are [x,y,z].
  12992. */
  12993. readonly linearVelocity: Nullable<Float32Array>;
  12994. /**
  12995. * The linearAcceleration of the device, values in array are [x,y,z].
  12996. */
  12997. readonly linearAcceleration: Nullable<Float32Array>;
  12998. /**
  12999. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  13000. */
  13001. readonly orientation: Nullable<Float32Array>;
  13002. /**
  13003. * The angularVelocity of the device, values in array are [x,y,z].
  13004. */
  13005. readonly angularVelocity: Nullable<Float32Array>;
  13006. /**
  13007. * The angularAcceleration of the device, values in array are [x,y,z].
  13008. */
  13009. readonly angularAcceleration: Nullable<Float32Array>;
  13010. }
  13011. /**
  13012. * Interface representing a pose controlled object in Babylon.
  13013. * A pose controlled object has both regular pose values as well as pose values
  13014. * from an external device such as a VR head mounted display
  13015. */
  13016. export interface PoseControlled {
  13017. /**
  13018. * The position of the object in babylon space.
  13019. */
  13020. position: Vector3;
  13021. /**
  13022. * The rotation quaternion of the object in babylon space.
  13023. */
  13024. rotationQuaternion: Quaternion;
  13025. /**
  13026. * The position of the device in babylon space.
  13027. */
  13028. devicePosition?: Vector3;
  13029. /**
  13030. * The rotation quaternion of the device in babylon space.
  13031. */
  13032. deviceRotationQuaternion: Quaternion;
  13033. /**
  13034. * The raw pose coming from the device.
  13035. */
  13036. rawPose: Nullable<DevicePose>;
  13037. /**
  13038. * The scale of the device to be used when translating from device space to babylon space.
  13039. */
  13040. deviceScaleFactor: number;
  13041. /**
  13042. * Updates the poseControlled values based on the input device pose.
  13043. * @param poseData the pose data to update the object with
  13044. */
  13045. updateFromDevice(poseData: DevicePose): void;
  13046. }
  13047. /**
  13048. * Set of options to customize the webVRCamera
  13049. */
  13050. export interface WebVROptions {
  13051. /**
  13052. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  13053. */
  13054. trackPosition?: boolean;
  13055. /**
  13056. * Sets the scale of the vrDevice in babylon space. (default: 1)
  13057. */
  13058. positionScale?: number;
  13059. /**
  13060. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  13061. */
  13062. displayName?: string;
  13063. /**
  13064. * Should the native controller meshes be initialized. (default: true)
  13065. */
  13066. controllerMeshes?: boolean;
  13067. /**
  13068. * Creating a default HemiLight only on controllers. (default: true)
  13069. */
  13070. defaultLightingOnControllers?: boolean;
  13071. /**
  13072. * If you don't want to use the default VR button of the helper. (default: false)
  13073. */
  13074. useCustomVRButton?: boolean;
  13075. /**
  13076. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  13077. */
  13078. customVRButton?: HTMLButtonElement;
  13079. /**
  13080. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  13081. */
  13082. rayLength?: number;
  13083. /**
  13084. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  13085. */
  13086. defaultHeight?: number;
  13087. }
  13088. /**
  13089. * This represents a WebVR camera.
  13090. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  13091. * @example http://doc.babylonjs.com/how_to/webvr_camera
  13092. */
  13093. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  13094. private webVROptions;
  13095. /**
  13096. * @hidden
  13097. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  13098. */
  13099. _vrDevice: any;
  13100. /**
  13101. * The rawPose of the vrDevice.
  13102. */
  13103. rawPose: Nullable<DevicePose>;
  13104. private _onVREnabled;
  13105. private _specsVersion;
  13106. private _attached;
  13107. private _frameData;
  13108. protected _descendants: Array<Node>;
  13109. private _deviceRoomPosition;
  13110. /** @hidden */
  13111. _deviceRoomRotationQuaternion: Quaternion;
  13112. private _standingMatrix;
  13113. /**
  13114. * Represents device position in babylon space.
  13115. */
  13116. devicePosition: Vector3;
  13117. /**
  13118. * Represents device rotation in babylon space.
  13119. */
  13120. deviceRotationQuaternion: Quaternion;
  13121. /**
  13122. * The scale of the device to be used when translating from device space to babylon space.
  13123. */
  13124. deviceScaleFactor: number;
  13125. private _deviceToWorld;
  13126. private _worldToDevice;
  13127. /**
  13128. * References to the webVR controllers for the vrDevice.
  13129. */
  13130. controllers: Array<WebVRController>;
  13131. /**
  13132. * Emits an event when a controller is attached.
  13133. */
  13134. onControllersAttachedObservable: Observable<WebVRController[]>;
  13135. /**
  13136. * Emits an event when a controller's mesh has been loaded;
  13137. */
  13138. onControllerMeshLoadedObservable: Observable<WebVRController>;
  13139. /**
  13140. * Emits an event when the HMD's pose has been updated.
  13141. */
  13142. onPoseUpdatedFromDeviceObservable: Observable<any>;
  13143. private _poseSet;
  13144. /**
  13145. * If the rig cameras be used as parent instead of this camera.
  13146. */
  13147. rigParenting: boolean;
  13148. private _lightOnControllers;
  13149. private _defaultHeight?;
  13150. /**
  13151. * Instantiates a WebVRFreeCamera.
  13152. * @param name The name of the WebVRFreeCamera
  13153. * @param position The starting anchor position for the camera
  13154. * @param scene The scene the camera belongs to
  13155. * @param webVROptions a set of customizable options for the webVRCamera
  13156. */
  13157. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  13158. /**
  13159. * Gets the device distance from the ground in meters.
  13160. * @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.
  13161. */
  13162. deviceDistanceToRoomGround(): number;
  13163. /**
  13164. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  13165. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  13166. */
  13167. useStandingMatrix(callback?: (bool: boolean) => void): void;
  13168. /**
  13169. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  13170. * @returns A promise with a boolean set to if the standing matrix is supported.
  13171. */
  13172. useStandingMatrixAsync(): Promise<boolean>;
  13173. /**
  13174. * Disposes the camera
  13175. */
  13176. dispose(): void;
  13177. /**
  13178. * Gets a vrController by name.
  13179. * @param name The name of the controller to retreive
  13180. * @returns the controller matching the name specified or null if not found
  13181. */
  13182. getControllerByName(name: string): Nullable<WebVRController>;
  13183. private _leftController;
  13184. /**
  13185. * The controller corrisponding to the users left hand.
  13186. */
  13187. readonly leftController: Nullable<WebVRController>;
  13188. private _rightController;
  13189. /**
  13190. * The controller corrisponding to the users right hand.
  13191. */
  13192. readonly rightController: Nullable<WebVRController>;
  13193. /**
  13194. * Casts a ray forward from the vrCamera's gaze.
  13195. * @param length Length of the ray (default: 100)
  13196. * @returns the ray corrisponding to the gaze
  13197. */
  13198. getForwardRay(length?: number): Ray;
  13199. /**
  13200. * @hidden
  13201. * Updates the camera based on device's frame data
  13202. */
  13203. _checkInputs(): void;
  13204. /**
  13205. * Updates the poseControlled values based on the input device pose.
  13206. * @param poseData Pose coming from the device
  13207. */
  13208. updateFromDevice(poseData: DevicePose): void;
  13209. private _htmlElementAttached;
  13210. private _detachIfAttached;
  13211. /**
  13212. * WebVR's attach control will start broadcasting frames to the device.
  13213. * Note that in certain browsers (chrome for example) this function must be called
  13214. * within a user-interaction callback. Example:
  13215. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  13216. *
  13217. * @param element html element to attach the vrDevice to
  13218. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  13219. */
  13220. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  13221. /**
  13222. * Detaches the camera from the html element and disables VR
  13223. *
  13224. * @param element html element to detach from
  13225. */
  13226. detachControl(element: HTMLElement): void;
  13227. /**
  13228. * @returns the name of this class
  13229. */
  13230. getClassName(): string;
  13231. /**
  13232. * Calls resetPose on the vrDisplay
  13233. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  13234. */
  13235. resetToCurrentRotation(): void;
  13236. /**
  13237. * @hidden
  13238. * Updates the rig cameras (left and right eye)
  13239. */
  13240. _updateRigCameras(): void;
  13241. private _workingVector;
  13242. private _oneVector;
  13243. private _workingMatrix;
  13244. private updateCacheCalled;
  13245. private _correctPositionIfNotTrackPosition;
  13246. /**
  13247. * @hidden
  13248. * Updates the cached values of the camera
  13249. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  13250. */
  13251. _updateCache(ignoreParentClass?: boolean): void;
  13252. /**
  13253. * @hidden
  13254. * Get current device position in babylon world
  13255. */
  13256. _computeDevicePosition(): void;
  13257. /**
  13258. * Updates the current device position and rotation in the babylon world
  13259. */
  13260. update(): void;
  13261. /**
  13262. * @hidden
  13263. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  13264. * @returns an identity matrix
  13265. */
  13266. _getViewMatrix(): Matrix;
  13267. private _tmpMatrix;
  13268. /**
  13269. * This function is called by the two RIG cameras.
  13270. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  13271. * @hidden
  13272. */
  13273. _getWebVRViewMatrix(): Matrix;
  13274. /** @hidden */
  13275. _getWebVRProjectionMatrix(): Matrix;
  13276. private _onGamepadConnectedObserver;
  13277. private _onGamepadDisconnectedObserver;
  13278. private _updateCacheWhenTrackingDisabledObserver;
  13279. /**
  13280. * Initializes the controllers and their meshes
  13281. */
  13282. initControllers(): void;
  13283. }
  13284. }
  13285. declare module "babylonjs/PostProcesses/postProcess" {
  13286. import { Nullable } from "babylonjs/types";
  13287. import { SmartArray } from "babylonjs/Misc/smartArray";
  13288. import { Observable } from "babylonjs/Misc/observable";
  13289. import { Color4, Vector2 } from "babylonjs/Maths/math";
  13290. import { Camera } from "babylonjs/Cameras/camera";
  13291. import { Effect } from "babylonjs/Materials/effect";
  13292. import "babylonjs/Shaders/postprocess.vertex";
  13293. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  13294. import { Engine } from "babylonjs/Engines/engine";
  13295. /**
  13296. * Size options for a post process
  13297. */
  13298. export type PostProcessOptions = {
  13299. width: number;
  13300. height: number;
  13301. };
  13302. /**
  13303. * PostProcess can be used to apply a shader to a texture after it has been rendered
  13304. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  13305. */
  13306. export class PostProcess {
  13307. /** Name of the PostProcess. */
  13308. name: string;
  13309. /**
  13310. * Gets or sets the unique id of the post process
  13311. */
  13312. uniqueId: number;
  13313. /**
  13314. * Width of the texture to apply the post process on
  13315. */
  13316. width: number;
  13317. /**
  13318. * Height of the texture to apply the post process on
  13319. */
  13320. height: number;
  13321. /**
  13322. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  13323. * @hidden
  13324. */
  13325. _outputTexture: Nullable<InternalTexture>;
  13326. /**
  13327. * Sampling mode used by the shader
  13328. * See https://doc.babylonjs.com/classes/3.1/texture
  13329. */
  13330. renderTargetSamplingMode: number;
  13331. /**
  13332. * Clear color to use when screen clearing
  13333. */
  13334. clearColor: Color4;
  13335. /**
  13336. * If the buffer needs to be cleared before applying the post process. (default: true)
  13337. * Should be set to false if shader will overwrite all previous pixels.
  13338. */
  13339. autoClear: boolean;
  13340. /**
  13341. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  13342. */
  13343. alphaMode: number;
  13344. /**
  13345. * Sets the setAlphaBlendConstants of the babylon engine
  13346. */
  13347. alphaConstants: Color4;
  13348. /**
  13349. * Animations to be used for the post processing
  13350. */
  13351. animations: import("babylonjs/Animations/animation").Animation[];
  13352. /**
  13353. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  13354. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  13355. */
  13356. enablePixelPerfectMode: boolean;
  13357. /**
  13358. * Force the postprocess to be applied without taking in account viewport
  13359. */
  13360. forceFullscreenViewport: boolean;
  13361. /**
  13362. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  13363. *
  13364. * | Value | Type | Description |
  13365. * | ----- | ----------------------------------- | ----------- |
  13366. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  13367. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  13368. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  13369. *
  13370. */
  13371. scaleMode: number;
  13372. /**
  13373. * Force textures to be a power of two (default: false)
  13374. */
  13375. alwaysForcePOT: boolean;
  13376. private _samples;
  13377. /**
  13378. * Number of sample textures (default: 1)
  13379. */
  13380. samples: number;
  13381. /**
  13382. * Modify the scale of the post process to be the same as the viewport (default: false)
  13383. */
  13384. adaptScaleToCurrentViewport: boolean;
  13385. private _camera;
  13386. private _scene;
  13387. private _engine;
  13388. private _options;
  13389. private _reusable;
  13390. private _textureType;
  13391. /**
  13392. * Smart array of input and output textures for the post process.
  13393. * @hidden
  13394. */
  13395. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  13396. /**
  13397. * The index in _textures that corresponds to the output texture.
  13398. * @hidden
  13399. */
  13400. _currentRenderTextureInd: number;
  13401. private _effect;
  13402. private _samplers;
  13403. private _fragmentUrl;
  13404. private _vertexUrl;
  13405. private _parameters;
  13406. private _scaleRatio;
  13407. protected _indexParameters: any;
  13408. private _shareOutputWithPostProcess;
  13409. private _texelSize;
  13410. private _forcedOutputTexture;
  13411. /**
  13412. * Returns the fragment url or shader name used in the post process.
  13413. * @returns the fragment url or name in the shader store.
  13414. */
  13415. getEffectName(): string;
  13416. /**
  13417. * An event triggered when the postprocess is activated.
  13418. */
  13419. onActivateObservable: Observable<Camera>;
  13420. private _onActivateObserver;
  13421. /**
  13422. * A function that is added to the onActivateObservable
  13423. */
  13424. onActivate: Nullable<(camera: Camera) => void>;
  13425. /**
  13426. * An event triggered when the postprocess changes its size.
  13427. */
  13428. onSizeChangedObservable: Observable<PostProcess>;
  13429. private _onSizeChangedObserver;
  13430. /**
  13431. * A function that is added to the onSizeChangedObservable
  13432. */
  13433. onSizeChanged: (postProcess: PostProcess) => void;
  13434. /**
  13435. * An event triggered when the postprocess applies its effect.
  13436. */
  13437. onApplyObservable: Observable<Effect>;
  13438. private _onApplyObserver;
  13439. /**
  13440. * A function that is added to the onApplyObservable
  13441. */
  13442. onApply: (effect: Effect) => void;
  13443. /**
  13444. * An event triggered before rendering the postprocess
  13445. */
  13446. onBeforeRenderObservable: Observable<Effect>;
  13447. private _onBeforeRenderObserver;
  13448. /**
  13449. * A function that is added to the onBeforeRenderObservable
  13450. */
  13451. onBeforeRender: (effect: Effect) => void;
  13452. /**
  13453. * An event triggered after rendering the postprocess
  13454. */
  13455. onAfterRenderObservable: Observable<Effect>;
  13456. private _onAfterRenderObserver;
  13457. /**
  13458. * A function that is added to the onAfterRenderObservable
  13459. */
  13460. onAfterRender: (efect: Effect) => void;
  13461. /**
  13462. * 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
  13463. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  13464. */
  13465. inputTexture: InternalTexture;
  13466. /**
  13467. * Gets the camera which post process is applied to.
  13468. * @returns The camera the post process is applied to.
  13469. */
  13470. getCamera(): Camera;
  13471. /**
  13472. * Gets the texel size of the postprocess.
  13473. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  13474. */
  13475. readonly texelSize: Vector2;
  13476. /**
  13477. * Creates a new instance PostProcess
  13478. * @param name The name of the PostProcess.
  13479. * @param fragmentUrl The url of the fragment shader to be used.
  13480. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  13481. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  13482. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  13483. * @param camera The camera to apply the render pass to.
  13484. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  13485. * @param engine The engine which the post process will be applied. (default: current engine)
  13486. * @param reusable If the post process can be reused on the same frame. (default: false)
  13487. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  13488. * @param textureType Type of textures used when performing the post process. (default: 0)
  13489. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  13490. * @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
  13491. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  13492. */
  13493. constructor(
  13494. /** Name of the PostProcess. */
  13495. 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);
  13496. /**
  13497. * Gets a string idenfifying the name of the class
  13498. * @returns "PostProcess" string
  13499. */
  13500. getClassName(): string;
  13501. /**
  13502. * Gets the engine which this post process belongs to.
  13503. * @returns The engine the post process was enabled with.
  13504. */
  13505. getEngine(): Engine;
  13506. /**
  13507. * The effect that is created when initializing the post process.
  13508. * @returns The created effect corrisponding the the postprocess.
  13509. */
  13510. getEffect(): Effect;
  13511. /**
  13512. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  13513. * @param postProcess The post process to share the output with.
  13514. * @returns This post process.
  13515. */
  13516. shareOutputWith(postProcess: PostProcess): PostProcess;
  13517. /**
  13518. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  13519. * This should be called if the post process that shares output with this post process is disabled/disposed.
  13520. */
  13521. useOwnOutput(): void;
  13522. /**
  13523. * Updates the effect with the current post process compile time values and recompiles the shader.
  13524. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  13525. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  13526. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  13527. * @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
  13528. * @param onCompiled Called when the shader has been compiled.
  13529. * @param onError Called if there is an error when compiling a shader.
  13530. */
  13531. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  13532. /**
  13533. * The post process is reusable if it can be used multiple times within one frame.
  13534. * @returns If the post process is reusable
  13535. */
  13536. isReusable(): boolean;
  13537. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  13538. markTextureDirty(): void;
  13539. /**
  13540. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  13541. * 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.
  13542. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  13543. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  13544. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  13545. * @returns The target texture that was bound to be written to.
  13546. */
  13547. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  13548. /**
  13549. * If the post process is supported.
  13550. */
  13551. readonly isSupported: boolean;
  13552. /**
  13553. * The aspect ratio of the output texture.
  13554. */
  13555. readonly aspectRatio: number;
  13556. /**
  13557. * Get a value indicating if the post-process is ready to be used
  13558. * @returns true if the post-process is ready (shader is compiled)
  13559. */
  13560. isReady(): boolean;
  13561. /**
  13562. * Binds all textures and uniforms to the shader, this will be run on every pass.
  13563. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  13564. */
  13565. apply(): Nullable<Effect>;
  13566. private _disposeTextures;
  13567. /**
  13568. * Disposes the post process.
  13569. * @param camera The camera to dispose the post process on.
  13570. */
  13571. dispose(camera?: Camera): void;
  13572. }
  13573. }
  13574. declare module "babylonjs/PostProcesses/postProcessManager" {
  13575. import { Nullable } from "babylonjs/types";
  13576. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  13577. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  13578. import { Scene } from "babylonjs/scene";
  13579. /**
  13580. * PostProcessManager is used to manage one or more post processes or post process pipelines
  13581. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  13582. */
  13583. export class PostProcessManager {
  13584. private _scene;
  13585. private _indexBuffer;
  13586. private _vertexBuffers;
  13587. /**
  13588. * Creates a new instance PostProcess
  13589. * @param scene The scene that the post process is associated with.
  13590. */
  13591. constructor(scene: Scene);
  13592. private _prepareBuffers;
  13593. private _buildIndexBuffer;
  13594. /**
  13595. * Rebuilds the vertex buffers of the manager.
  13596. * @hidden
  13597. */
  13598. _rebuild(): void;
  13599. /**
  13600. * Prepares a frame to be run through a post process.
  13601. * @param sourceTexture The input texture to the post procesess. (default: null)
  13602. * @param postProcesses An array of post processes to be run. (default: null)
  13603. * @returns True if the post processes were able to be run.
  13604. * @hidden
  13605. */
  13606. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  13607. /**
  13608. * Manually render a set of post processes to a texture.
  13609. * @param postProcesses An array of post processes to be run.
  13610. * @param targetTexture The target texture to render to.
  13611. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  13612. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  13613. * @param lodLevel defines which lod of the texture to render to
  13614. */
  13615. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  13616. /**
  13617. * Finalize the result of the output of the postprocesses.
  13618. * @param doNotPresent If true the result will not be displayed to the screen.
  13619. * @param targetTexture The target texture to render to.
  13620. * @param faceIndex The index of the face to bind the target texture to.
  13621. * @param postProcesses The array of post processes to render.
  13622. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  13623. * @hidden
  13624. */
  13625. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  13626. /**
  13627. * Disposes of the post process manager.
  13628. */
  13629. dispose(): void;
  13630. }
  13631. }
  13632. declare module "babylonjs/Layers/layerSceneComponent" {
  13633. import { Scene } from "babylonjs/scene";
  13634. import { ISceneComponent } from "babylonjs/sceneComponent";
  13635. import { Layer } from "babylonjs/Layers/layer";
  13636. module "babylonjs/abstractScene" {
  13637. interface AbstractScene {
  13638. /**
  13639. * The list of layers (background and foreground) of the scene
  13640. */
  13641. layers: Array<Layer>;
  13642. }
  13643. }
  13644. /**
  13645. * Defines the layer scene component responsible to manage any layers
  13646. * in a given scene.
  13647. */
  13648. export class LayerSceneComponent implements ISceneComponent {
  13649. /**
  13650. * The component name helpfull to identify the component in the list of scene components.
  13651. */
  13652. readonly name: string;
  13653. /**
  13654. * The scene the component belongs to.
  13655. */
  13656. scene: Scene;
  13657. private _engine;
  13658. /**
  13659. * Creates a new instance of the component for the given scene
  13660. * @param scene Defines the scene to register the component in
  13661. */
  13662. constructor(scene: Scene);
  13663. /**
  13664. * Registers the component in a given scene
  13665. */
  13666. register(): void;
  13667. /**
  13668. * Rebuilds the elements related to this component in case of
  13669. * context lost for instance.
  13670. */
  13671. rebuild(): void;
  13672. /**
  13673. * Disposes the component and the associated ressources.
  13674. */
  13675. dispose(): void;
  13676. private _draw;
  13677. private _drawCameraPredicate;
  13678. private _drawCameraBackground;
  13679. private _drawCameraForeground;
  13680. private _drawRenderTargetPredicate;
  13681. private _drawRenderTargetBackground;
  13682. private _drawRenderTargetForeground;
  13683. }
  13684. }
  13685. declare module "babylonjs/Shaders/layer.fragment" {
  13686. /** @hidden */
  13687. export var layerPixelShader: {
  13688. name: string;
  13689. shader: string;
  13690. };
  13691. }
  13692. declare module "babylonjs/Shaders/layer.vertex" {
  13693. /** @hidden */
  13694. export var layerVertexShader: {
  13695. name: string;
  13696. shader: string;
  13697. };
  13698. }
  13699. declare module "babylonjs/Layers/layer" {
  13700. import { Observable } from "babylonjs/Misc/observable";
  13701. import { Nullable } from "babylonjs/types";
  13702. import { Scene } from "babylonjs/scene";
  13703. import { Vector2, Color4 } from "babylonjs/Maths/math";
  13704. import { Texture } from "babylonjs/Materials/Textures/texture";
  13705. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  13706. import "babylonjs/Shaders/layer.fragment";
  13707. import "babylonjs/Shaders/layer.vertex";
  13708. /**
  13709. * This represents a full screen 2d layer.
  13710. * This can be useful to display a picture in the background of your scene for instance.
  13711. * @see https://www.babylonjs-playground.com/#08A2BS#1
  13712. */
  13713. export class Layer {
  13714. /**
  13715. * Define the name of the layer.
  13716. */
  13717. name: string;
  13718. /**
  13719. * Define the texture the layer should display.
  13720. */
  13721. texture: Nullable<Texture>;
  13722. /**
  13723. * Is the layer in background or foreground.
  13724. */
  13725. isBackground: boolean;
  13726. /**
  13727. * Define the color of the layer (instead of texture).
  13728. */
  13729. color: Color4;
  13730. /**
  13731. * Define the scale of the layer in order to zoom in out of the texture.
  13732. */
  13733. scale: Vector2;
  13734. /**
  13735. * Define an offset for the layer in order to shift the texture.
  13736. */
  13737. offset: Vector2;
  13738. /**
  13739. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  13740. */
  13741. alphaBlendingMode: number;
  13742. /**
  13743. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  13744. * Alpha test will not mix with the background color in case of transparency.
  13745. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  13746. */
  13747. alphaTest: boolean;
  13748. /**
  13749. * Define a mask to restrict the layer to only some of the scene cameras.
  13750. */
  13751. layerMask: number;
  13752. /**
  13753. * Define the list of render target the layer is visible into.
  13754. */
  13755. renderTargetTextures: RenderTargetTexture[];
  13756. /**
  13757. * Define if the layer is only used in renderTarget or if it also
  13758. * renders in the main frame buffer of the canvas.
  13759. */
  13760. renderOnlyInRenderTargetTextures: boolean;
  13761. private _scene;
  13762. private _vertexBuffers;
  13763. private _indexBuffer;
  13764. private _effect;
  13765. private _alphaTestEffect;
  13766. /**
  13767. * An event triggered when the layer is disposed.
  13768. */
  13769. onDisposeObservable: Observable<Layer>;
  13770. private _onDisposeObserver;
  13771. /**
  13772. * Back compatibility with callback before the onDisposeObservable existed.
  13773. * The set callback will be triggered when the layer has been disposed.
  13774. */
  13775. onDispose: () => void;
  13776. /**
  13777. * An event triggered before rendering the scene
  13778. */
  13779. onBeforeRenderObservable: Observable<Layer>;
  13780. private _onBeforeRenderObserver;
  13781. /**
  13782. * Back compatibility with callback before the onBeforeRenderObservable existed.
  13783. * The set callback will be triggered just before rendering the layer.
  13784. */
  13785. onBeforeRender: () => void;
  13786. /**
  13787. * An event triggered after rendering the scene
  13788. */
  13789. onAfterRenderObservable: Observable<Layer>;
  13790. private _onAfterRenderObserver;
  13791. /**
  13792. * Back compatibility with callback before the onAfterRenderObservable existed.
  13793. * The set callback will be triggered just after rendering the layer.
  13794. */
  13795. onAfterRender: () => void;
  13796. /**
  13797. * Instantiates a new layer.
  13798. * This represents a full screen 2d layer.
  13799. * This can be useful to display a picture in the background of your scene for instance.
  13800. * @see https://www.babylonjs-playground.com/#08A2BS#1
  13801. * @param name Define the name of the layer in the scene
  13802. * @param imgUrl Define the url of the texture to display in the layer
  13803. * @param scene Define the scene the layer belongs to
  13804. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  13805. * @param color Defines a color for the layer
  13806. */
  13807. constructor(
  13808. /**
  13809. * Define the name of the layer.
  13810. */
  13811. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  13812. private _createIndexBuffer;
  13813. /** @hidden */
  13814. _rebuild(): void;
  13815. /**
  13816. * Renders the layer in the scene.
  13817. */
  13818. render(): void;
  13819. /**
  13820. * Disposes and releases the associated ressources.
  13821. */
  13822. dispose(): void;
  13823. }
  13824. }
  13825. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  13826. import { Scene } from "babylonjs/scene";
  13827. import { ISceneComponent } from "babylonjs/sceneComponent";
  13828. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  13829. module "babylonjs/abstractScene" {
  13830. interface AbstractScene {
  13831. /**
  13832. * The list of procedural textures added to the scene
  13833. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  13834. */
  13835. proceduralTextures: Array<ProceduralTexture>;
  13836. }
  13837. }
  13838. /**
  13839. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  13840. * in a given scene.
  13841. */
  13842. export class ProceduralTextureSceneComponent implements ISceneComponent {
  13843. /**
  13844. * The component name helpfull to identify the component in the list of scene components.
  13845. */
  13846. readonly name: string;
  13847. /**
  13848. * The scene the component belongs to.
  13849. */
  13850. scene: Scene;
  13851. /**
  13852. * Creates a new instance of the component for the given scene
  13853. * @param scene Defines the scene to register the component in
  13854. */
  13855. constructor(scene: Scene);
  13856. /**
  13857. * Registers the component in a given scene
  13858. */
  13859. register(): void;
  13860. /**
  13861. * Rebuilds the elements related to this component in case of
  13862. * context lost for instance.
  13863. */
  13864. rebuild(): void;
  13865. /**
  13866. * Disposes the component and the associated ressources.
  13867. */
  13868. dispose(): void;
  13869. private _beforeClear;
  13870. }
  13871. }
  13872. declare module "babylonjs/Shaders/procedural.vertex" {
  13873. /** @hidden */
  13874. export var proceduralVertexShader: {
  13875. name: string;
  13876. shader: string;
  13877. };
  13878. }
  13879. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  13880. import { Observable } from "babylonjs/Misc/observable";
  13881. import { Nullable } from "babylonjs/types";
  13882. import { Scene } from "babylonjs/scene";
  13883. import { Matrix, Vector3, Vector2, Color3, Color4 } from "babylonjs/Maths/math";
  13884. import { Effect } from "babylonjs/Materials/effect";
  13885. import { Texture } from "babylonjs/Materials/Textures/texture";
  13886. import "babylonjs/Shaders/procedural.vertex";
  13887. /**
  13888. * 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.
  13889. * This is the base class of any Procedural texture and contains most of the shareable code.
  13890. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  13891. */
  13892. export class ProceduralTexture extends Texture {
  13893. isCube: boolean;
  13894. /**
  13895. * Define if the texture is enabled or not (disabled texture will not render)
  13896. */
  13897. isEnabled: boolean;
  13898. /**
  13899. * Define if the texture must be cleared before rendering (default is true)
  13900. */
  13901. autoClear: boolean;
  13902. /**
  13903. * Callback called when the texture is generated
  13904. */
  13905. onGenerated: () => void;
  13906. /**
  13907. * Event raised when the texture is generated
  13908. */
  13909. onGeneratedObservable: Observable<ProceduralTexture>;
  13910. /** @hidden */
  13911. _generateMipMaps: boolean;
  13912. /** @hidden **/
  13913. _effect: Effect;
  13914. /** @hidden */
  13915. _textures: {
  13916. [key: string]: Texture;
  13917. };
  13918. private _size;
  13919. private _currentRefreshId;
  13920. private _refreshRate;
  13921. private _vertexBuffers;
  13922. private _indexBuffer;
  13923. private _uniforms;
  13924. private _samplers;
  13925. private _fragment;
  13926. private _floats;
  13927. private _ints;
  13928. private _floatsArrays;
  13929. private _colors3;
  13930. private _colors4;
  13931. private _vectors2;
  13932. private _vectors3;
  13933. private _matrices;
  13934. private _fallbackTexture;
  13935. private _fallbackTextureUsed;
  13936. private _engine;
  13937. private _cachedDefines;
  13938. private _contentUpdateId;
  13939. private _contentData;
  13940. /**
  13941. * Instantiates a new procedural texture.
  13942. * 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.
  13943. * This is the base class of any Procedural texture and contains most of the shareable code.
  13944. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  13945. * @param name Define the name of the texture
  13946. * @param size Define the size of the texture to create
  13947. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  13948. * @param scene Define the scene the texture belongs to
  13949. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  13950. * @param generateMipMaps Define if the texture should creates mip maps or not
  13951. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  13952. */
  13953. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  13954. /**
  13955. * The effect that is created when initializing the post process.
  13956. * @returns The created effect corrisponding the the postprocess.
  13957. */
  13958. getEffect(): Effect;
  13959. /**
  13960. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  13961. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  13962. */
  13963. getContent(): Nullable<ArrayBufferView>;
  13964. private _createIndexBuffer;
  13965. /** @hidden */
  13966. _rebuild(): void;
  13967. /**
  13968. * Resets the texture in order to recreate its associated resources.
  13969. * This can be called in case of context loss
  13970. */
  13971. reset(): void;
  13972. protected _getDefines(): string;
  13973. /**
  13974. * Is the texture ready to be used ? (rendered at least once)
  13975. * @returns true if ready, otherwise, false.
  13976. */
  13977. isReady(): boolean;
  13978. /**
  13979. * Resets the refresh counter of the texture and start bak from scratch.
  13980. * Could be useful to regenerate the texture if it is setup to render only once.
  13981. */
  13982. resetRefreshCounter(): void;
  13983. /**
  13984. * Set the fragment shader to use in order to render the texture.
  13985. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  13986. */
  13987. setFragment(fragment: any): void;
  13988. /**
  13989. * Define the refresh rate of the texture or the rendering frequency.
  13990. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  13991. */
  13992. refreshRate: number;
  13993. /** @hidden */
  13994. _shouldRender(): boolean;
  13995. /**
  13996. * Get the size the texture is rendering at.
  13997. * @returns the size (texture is always squared)
  13998. */
  13999. getRenderSize(): number;
  14000. /**
  14001. * Resize the texture to new value.
  14002. * @param size Define the new size the texture should have
  14003. * @param generateMipMaps Define whether the new texture should create mip maps
  14004. */
  14005. resize(size: number, generateMipMaps: boolean): void;
  14006. private _checkUniform;
  14007. /**
  14008. * Set a texture in the shader program used to render.
  14009. * @param name Define the name of the uniform samplers as defined in the shader
  14010. * @param texture Define the texture to bind to this sampler
  14011. * @return the texture itself allowing "fluent" like uniform updates
  14012. */
  14013. setTexture(name: string, texture: Texture): ProceduralTexture;
  14014. /**
  14015. * Set a float in the shader.
  14016. * @param name Define the name of the uniform as defined in the shader
  14017. * @param value Define the value to give to the uniform
  14018. * @return the texture itself allowing "fluent" like uniform updates
  14019. */
  14020. setFloat(name: string, value: number): ProceduralTexture;
  14021. /**
  14022. * Set a int in the shader.
  14023. * @param name Define the name of the uniform as defined in the shader
  14024. * @param value Define the value to give to the uniform
  14025. * @return the texture itself allowing "fluent" like uniform updates
  14026. */
  14027. setInt(name: string, value: number): ProceduralTexture;
  14028. /**
  14029. * Set an array of floats in the shader.
  14030. * @param name Define the name of the uniform as defined in the shader
  14031. * @param value Define the value to give to the uniform
  14032. * @return the texture itself allowing "fluent" like uniform updates
  14033. */
  14034. setFloats(name: string, value: number[]): ProceduralTexture;
  14035. /**
  14036. * Set a vec3 in the shader from a Color3.
  14037. * @param name Define the name of the uniform as defined in the shader
  14038. * @param value Define the value to give to the uniform
  14039. * @return the texture itself allowing "fluent" like uniform updates
  14040. */
  14041. setColor3(name: string, value: Color3): ProceduralTexture;
  14042. /**
  14043. * Set a vec4 in the shader from a Color4.
  14044. * @param name Define the name of the uniform as defined in the shader
  14045. * @param value Define the value to give to the uniform
  14046. * @return the texture itself allowing "fluent" like uniform updates
  14047. */
  14048. setColor4(name: string, value: Color4): ProceduralTexture;
  14049. /**
  14050. * Set a vec2 in the shader from a Vector2.
  14051. * @param name Define the name of the uniform as defined in the shader
  14052. * @param value Define the value to give to the uniform
  14053. * @return the texture itself allowing "fluent" like uniform updates
  14054. */
  14055. setVector2(name: string, value: Vector2): ProceduralTexture;
  14056. /**
  14057. * Set a vec3 in the shader from a Vector3.
  14058. * @param name Define the name of the uniform as defined in the shader
  14059. * @param value Define the value to give to the uniform
  14060. * @return the texture itself allowing "fluent" like uniform updates
  14061. */
  14062. setVector3(name: string, value: Vector3): ProceduralTexture;
  14063. /**
  14064. * Set a mat4 in the shader from a MAtrix.
  14065. * @param name Define the name of the uniform as defined in the shader
  14066. * @param value Define the value to give to the uniform
  14067. * @return the texture itself allowing "fluent" like uniform updates
  14068. */
  14069. setMatrix(name: string, value: Matrix): ProceduralTexture;
  14070. /**
  14071. * Render the texture to its associated render target.
  14072. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  14073. */
  14074. render(useCameraPostProcess?: boolean): void;
  14075. /**
  14076. * Clone the texture.
  14077. * @returns the cloned texture
  14078. */
  14079. clone(): ProceduralTexture;
  14080. /**
  14081. * Dispose the texture and release its asoociated resources.
  14082. */
  14083. dispose(): void;
  14084. }
  14085. }
  14086. declare module "babylonjs/Particles/baseParticleSystem" {
  14087. import { Nullable } from "babylonjs/types";
  14088. import { Color4, Vector2, Vector3 } from "babylonjs/Maths/math";
  14089. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14090. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  14091. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  14092. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  14093. import { Scene } from "babylonjs/scene";
  14094. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/tools";
  14095. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  14096. import { Texture } from "babylonjs/Materials/Textures/texture";
  14097. import { Animation } from "babylonjs/Animations/animation";
  14098. /**
  14099. * This represents the base class for particle system in Babylon.
  14100. * 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.
  14101. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  14102. * @example https://doc.babylonjs.com/babylon101/particles
  14103. */
  14104. export class BaseParticleSystem {
  14105. /**
  14106. * Source color is added to the destination color without alpha affecting the result
  14107. */
  14108. static BLENDMODE_ONEONE: number;
  14109. /**
  14110. * Blend current color and particle color using particle’s alpha
  14111. */
  14112. static BLENDMODE_STANDARD: number;
  14113. /**
  14114. * Add current color and particle color multiplied by particle’s alpha
  14115. */
  14116. static BLENDMODE_ADD: number;
  14117. /**
  14118. * Multiply current color with particle color
  14119. */
  14120. static BLENDMODE_MULTIPLY: number;
  14121. /**
  14122. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  14123. */
  14124. static BLENDMODE_MULTIPLYADD: number;
  14125. /**
  14126. * List of animations used by the particle system.
  14127. */
  14128. animations: Animation[];
  14129. /**
  14130. * The id of the Particle system.
  14131. */
  14132. id: string;
  14133. /**
  14134. * The friendly name of the Particle system.
  14135. */
  14136. name: string;
  14137. /**
  14138. * The rendering group used by the Particle system to chose when to render.
  14139. */
  14140. renderingGroupId: number;
  14141. /**
  14142. * The emitter represents the Mesh or position we are attaching the particle system to.
  14143. */
  14144. emitter: Nullable<AbstractMesh | Vector3>;
  14145. /**
  14146. * The maximum number of particles to emit per frame
  14147. */
  14148. emitRate: number;
  14149. /**
  14150. * If you want to launch only a few particles at once, that can be done, as well.
  14151. */
  14152. manualEmitCount: number;
  14153. /**
  14154. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14155. */
  14156. updateSpeed: number;
  14157. /**
  14158. * The amount of time the particle system is running (depends of the overall update speed).
  14159. */
  14160. targetStopDuration: number;
  14161. /**
  14162. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14163. */
  14164. disposeOnStop: boolean;
  14165. /**
  14166. * Minimum power of emitting particles.
  14167. */
  14168. minEmitPower: number;
  14169. /**
  14170. * Maximum power of emitting particles.
  14171. */
  14172. maxEmitPower: number;
  14173. /**
  14174. * Minimum life time of emitting particles.
  14175. */
  14176. minLifeTime: number;
  14177. /**
  14178. * Maximum life time of emitting particles.
  14179. */
  14180. maxLifeTime: number;
  14181. /**
  14182. * Minimum Size of emitting particles.
  14183. */
  14184. minSize: number;
  14185. /**
  14186. * Maximum Size of emitting particles.
  14187. */
  14188. maxSize: number;
  14189. /**
  14190. * Minimum scale of emitting particles on X axis.
  14191. */
  14192. minScaleX: number;
  14193. /**
  14194. * Maximum scale of emitting particles on X axis.
  14195. */
  14196. maxScaleX: number;
  14197. /**
  14198. * Minimum scale of emitting particles on Y axis.
  14199. */
  14200. minScaleY: number;
  14201. /**
  14202. * Maximum scale of emitting particles on Y axis.
  14203. */
  14204. maxScaleY: number;
  14205. /**
  14206. * Gets or sets the minimal initial rotation in radians.
  14207. */
  14208. minInitialRotation: number;
  14209. /**
  14210. * Gets or sets the maximal initial rotation in radians.
  14211. */
  14212. maxInitialRotation: number;
  14213. /**
  14214. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14215. */
  14216. minAngularSpeed: number;
  14217. /**
  14218. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14219. */
  14220. maxAngularSpeed: number;
  14221. /**
  14222. * The texture used to render each particle. (this can be a spritesheet)
  14223. */
  14224. particleTexture: Nullable<Texture>;
  14225. /**
  14226. * The layer mask we are rendering the particles through.
  14227. */
  14228. layerMask: number;
  14229. /**
  14230. * This can help using your own shader to render the particle system.
  14231. * The according effect will be created
  14232. */
  14233. customShader: any;
  14234. /**
  14235. * By default particle system starts as soon as they are created. This prevents the
  14236. * automatic start to happen and let you decide when to start emitting particles.
  14237. */
  14238. preventAutoStart: boolean;
  14239. private _noiseTexture;
  14240. /**
  14241. * Gets or sets a texture used to add random noise to particle positions
  14242. */
  14243. noiseTexture: Nullable<ProceduralTexture>;
  14244. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14245. noiseStrength: Vector3;
  14246. /**
  14247. * Callback triggered when the particle animation is ending.
  14248. */
  14249. onAnimationEnd: Nullable<() => void>;
  14250. /**
  14251. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  14252. */
  14253. blendMode: number;
  14254. /**
  14255. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  14256. * to override the particles.
  14257. */
  14258. forceDepthWrite: boolean;
  14259. /** 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 */
  14260. preWarmCycles: number;
  14261. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  14262. preWarmStepOffset: number;
  14263. /**
  14264. * 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)
  14265. */
  14266. spriteCellChangeSpeed: number;
  14267. /**
  14268. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14269. */
  14270. startSpriteCellID: number;
  14271. /**
  14272. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14273. */
  14274. endSpriteCellID: number;
  14275. /**
  14276. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14277. */
  14278. spriteCellWidth: number;
  14279. /**
  14280. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14281. */
  14282. spriteCellHeight: number;
  14283. /**
  14284. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14285. */
  14286. spriteRandomStartCell: boolean;
  14287. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14288. translationPivot: Vector2;
  14289. /** @hidden */
  14290. protected _isAnimationSheetEnabled: boolean;
  14291. /**
  14292. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14293. */
  14294. beginAnimationOnStart: boolean;
  14295. /**
  14296. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14297. */
  14298. beginAnimationFrom: number;
  14299. /**
  14300. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14301. */
  14302. beginAnimationTo: number;
  14303. /**
  14304. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14305. */
  14306. beginAnimationLoop: boolean;
  14307. /**
  14308. * Gets or sets a world offset applied to all particles
  14309. */
  14310. worldOffset: Vector3;
  14311. /**
  14312. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  14313. */
  14314. isAnimationSheetEnabled: boolean;
  14315. /**
  14316. * Get hosting scene
  14317. * @returns the scene
  14318. */
  14319. getScene(): Scene;
  14320. /**
  14321. * You can use gravity if you want to give an orientation to your particles.
  14322. */
  14323. gravity: Vector3;
  14324. protected _colorGradients: Nullable<Array<ColorGradient>>;
  14325. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  14326. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  14327. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  14328. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  14329. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  14330. protected _dragGradients: Nullable<Array<FactorGradient>>;
  14331. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  14332. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  14333. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  14334. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  14335. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  14336. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  14337. /**
  14338. * Defines the delay in milliseconds before starting the system (0 by default)
  14339. */
  14340. startDelay: number;
  14341. /**
  14342. * Gets the current list of drag gradients.
  14343. * You must use addDragGradient and removeDragGradient to udpate this list
  14344. * @returns the list of drag gradients
  14345. */
  14346. getDragGradients(): Nullable<Array<FactorGradient>>;
  14347. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14348. limitVelocityDamping: number;
  14349. /**
  14350. * Gets the current list of limit velocity gradients.
  14351. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14352. * @returns the list of limit velocity gradients
  14353. */
  14354. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14355. /**
  14356. * Gets the current list of color gradients.
  14357. * You must use addColorGradient and removeColorGradient to udpate this list
  14358. * @returns the list of color gradients
  14359. */
  14360. getColorGradients(): Nullable<Array<ColorGradient>>;
  14361. /**
  14362. * Gets the current list of size gradients.
  14363. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14364. * @returns the list of size gradients
  14365. */
  14366. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14367. /**
  14368. * Gets the current list of color remap gradients.
  14369. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14370. * @returns the list of color remap gradients
  14371. */
  14372. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14373. /**
  14374. * Gets the current list of alpha remap gradients.
  14375. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14376. * @returns the list of alpha remap gradients
  14377. */
  14378. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14379. /**
  14380. * Gets the current list of life time gradients.
  14381. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14382. * @returns the list of life time gradients
  14383. */
  14384. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14385. /**
  14386. * Gets the current list of angular speed gradients.
  14387. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14388. * @returns the list of angular speed gradients
  14389. */
  14390. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14391. /**
  14392. * Gets the current list of velocity gradients.
  14393. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14394. * @returns the list of velocity gradients
  14395. */
  14396. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14397. /**
  14398. * Gets the current list of start size gradients.
  14399. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14400. * @returns the list of start size gradients
  14401. */
  14402. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14403. /**
  14404. * Gets the current list of emit rate gradients.
  14405. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14406. * @returns the list of emit rate gradients
  14407. */
  14408. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14409. /**
  14410. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14411. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14412. */
  14413. direction1: Vector3;
  14414. /**
  14415. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14416. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14417. */
  14418. direction2: Vector3;
  14419. /**
  14420. * 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.
  14421. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14422. */
  14423. minEmitBox: Vector3;
  14424. /**
  14425. * 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.
  14426. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14427. */
  14428. maxEmitBox: Vector3;
  14429. /**
  14430. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  14431. */
  14432. color1: Color4;
  14433. /**
  14434. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  14435. */
  14436. color2: Color4;
  14437. /**
  14438. * Color the particle will have at the end of its lifetime
  14439. */
  14440. colorDead: Color4;
  14441. /**
  14442. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  14443. */
  14444. textureMask: Color4;
  14445. /**
  14446. * The particle emitter type defines the emitter used by the particle system.
  14447. * It can be for example box, sphere, or cone...
  14448. */
  14449. particleEmitterType: IParticleEmitterType;
  14450. /** @hidden */
  14451. _isSubEmitter: boolean;
  14452. /**
  14453. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14454. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14455. */
  14456. billboardMode: number;
  14457. protected _isBillboardBased: boolean;
  14458. /**
  14459. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  14460. */
  14461. isBillboardBased: boolean;
  14462. /**
  14463. * The scene the particle system belongs to.
  14464. */
  14465. protected _scene: Scene;
  14466. /**
  14467. * Local cache of defines for image processing.
  14468. */
  14469. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  14470. /**
  14471. * Default configuration related to image processing available in the standard Material.
  14472. */
  14473. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  14474. /**
  14475. * Gets the image processing configuration used either in this material.
  14476. */
  14477. /**
  14478. * Sets the Default image processing configuration used either in the this material.
  14479. *
  14480. * If sets to null, the scene one is in use.
  14481. */
  14482. imageProcessingConfiguration: ImageProcessingConfiguration;
  14483. /**
  14484. * Attaches a new image processing configuration to the Standard Material.
  14485. * @param configuration
  14486. */
  14487. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  14488. /** @hidden */
  14489. protected _reset(): void;
  14490. /** @hidden */
  14491. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  14492. /**
  14493. * Instantiates a particle system.
  14494. * 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.
  14495. * @param name The name of the particle system
  14496. */
  14497. constructor(name: string);
  14498. /**
  14499. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  14500. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14501. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14502. * @returns the emitter
  14503. */
  14504. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  14505. /**
  14506. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  14507. * @param radius The radius of the hemisphere to emit from
  14508. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14509. * @returns the emitter
  14510. */
  14511. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  14512. /**
  14513. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  14514. * @param radius The radius of the sphere to emit from
  14515. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14516. * @returns the emitter
  14517. */
  14518. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  14519. /**
  14520. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  14521. * @param radius The radius of the sphere to emit from
  14522. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  14523. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  14524. * @returns the emitter
  14525. */
  14526. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  14527. /**
  14528. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  14529. * @param radius The radius of the emission cylinder
  14530. * @param height The height of the emission cylinder
  14531. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  14532. * @param directionRandomizer How much to randomize the particle direction [0-1]
  14533. * @returns the emitter
  14534. */
  14535. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  14536. /**
  14537. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  14538. * @param radius The radius of the cylinder to emit from
  14539. * @param height The height of the emission cylinder
  14540. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14541. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  14542. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  14543. * @returns the emitter
  14544. */
  14545. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  14546. /**
  14547. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  14548. * @param radius The radius of the cone to emit from
  14549. * @param angle The base angle of the cone
  14550. * @returns the emitter
  14551. */
  14552. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  14553. /**
  14554. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  14555. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14556. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14557. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14558. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14559. * @returns the emitter
  14560. */
  14561. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  14562. }
  14563. }
  14564. declare module "babylonjs/Particles/subEmitter" {
  14565. import { Scene } from "babylonjs/scene";
  14566. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  14567. /**
  14568. * Type of sub emitter
  14569. */
  14570. export enum SubEmitterType {
  14571. /**
  14572. * Attached to the particle over it's lifetime
  14573. */
  14574. ATTACHED = 0,
  14575. /**
  14576. * Created when the particle dies
  14577. */
  14578. END = 1
  14579. }
  14580. /**
  14581. * Sub emitter class used to emit particles from an existing particle
  14582. */
  14583. export class SubEmitter {
  14584. /**
  14585. * the particle system to be used by the sub emitter
  14586. */
  14587. particleSystem: ParticleSystem;
  14588. /**
  14589. * Type of the submitter (Default: END)
  14590. */
  14591. type: SubEmitterType;
  14592. /**
  14593. * 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)
  14594. * Note: This only is supported when using an emitter of type Mesh
  14595. */
  14596. inheritDirection: boolean;
  14597. /**
  14598. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  14599. */
  14600. inheritedVelocityAmount: number;
  14601. /**
  14602. * Creates a sub emitter
  14603. * @param particleSystem the particle system to be used by the sub emitter
  14604. */
  14605. constructor(
  14606. /**
  14607. * the particle system to be used by the sub emitter
  14608. */
  14609. particleSystem: ParticleSystem);
  14610. /**
  14611. * Clones the sub emitter
  14612. * @returns the cloned sub emitter
  14613. */
  14614. clone(): SubEmitter;
  14615. /**
  14616. * Serialize current object to a JSON object
  14617. * @returns the serialized object
  14618. */
  14619. serialize(): any;
  14620. /** @hidden */
  14621. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  14622. /**
  14623. * Creates a new SubEmitter from a serialized JSON version
  14624. * @param serializationObject defines the JSON object to read from
  14625. * @param scene defines the hosting scene
  14626. * @param rootUrl defines the rootUrl for data loading
  14627. * @returns a new SubEmitter
  14628. */
  14629. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  14630. /** Release associated resources */
  14631. dispose(): void;
  14632. }
  14633. }
  14634. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  14635. /** @hidden */
  14636. export var clipPlaneFragmentDeclaration: {
  14637. name: string;
  14638. shader: string;
  14639. };
  14640. }
  14641. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  14642. /** @hidden */
  14643. export var imageProcessingDeclaration: {
  14644. name: string;
  14645. shader: string;
  14646. };
  14647. }
  14648. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  14649. /** @hidden */
  14650. export var imageProcessingFunctions: {
  14651. name: string;
  14652. shader: string;
  14653. };
  14654. }
  14655. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  14656. /** @hidden */
  14657. export var clipPlaneFragment: {
  14658. name: string;
  14659. shader: string;
  14660. };
  14661. }
  14662. declare module "babylonjs/Shaders/particles.fragment" {
  14663. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  14664. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  14665. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  14666. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  14667. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  14668. /** @hidden */
  14669. export var particlesPixelShader: {
  14670. name: string;
  14671. shader: string;
  14672. };
  14673. }
  14674. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  14675. /** @hidden */
  14676. export var clipPlaneVertexDeclaration: {
  14677. name: string;
  14678. shader: string;
  14679. };
  14680. }
  14681. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  14682. /** @hidden */
  14683. export var clipPlaneVertex: {
  14684. name: string;
  14685. shader: string;
  14686. };
  14687. }
  14688. declare module "babylonjs/Shaders/particles.vertex" {
  14689. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  14690. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  14691. /** @hidden */
  14692. export var particlesVertexShader: {
  14693. name: string;
  14694. shader: string;
  14695. };
  14696. }
  14697. declare module "babylonjs/Particles/particleSystem" {
  14698. import { Nullable } from "babylonjs/types";
  14699. import { IAnimatable, FactorGradient, Color3Gradient } from "babylonjs/Misc/tools";
  14700. import { Observable } from "babylonjs/Misc/observable";
  14701. import { Color4, Color3, Vector3, Matrix } from "babylonjs/Maths/math";
  14702. import { Effect } from "babylonjs/Materials/effect";
  14703. import { Scene, IDisposable } from "babylonjs/scene";
  14704. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  14705. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  14706. import { Particle } from "babylonjs/Particles/particle";
  14707. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  14708. import "babylonjs/Shaders/particles.fragment";
  14709. import "babylonjs/Shaders/particles.vertex";
  14710. /**
  14711. * This represents a particle system in Babylon.
  14712. * 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.
  14713. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  14714. * @example https://doc.babylonjs.com/babylon101/particles
  14715. */
  14716. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  14717. /**
  14718. * Billboard mode will only apply to Y axis
  14719. */
  14720. static readonly BILLBOARDMODE_Y: number;
  14721. /**
  14722. * Billboard mode will apply to all axes
  14723. */
  14724. static readonly BILLBOARDMODE_ALL: number;
  14725. /**
  14726. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  14727. */
  14728. static readonly BILLBOARDMODE_STRETCHED: number;
  14729. /**
  14730. * This function can be defined to provide custom update for active particles.
  14731. * This function will be called instead of regular update (age, position, color, etc.).
  14732. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  14733. */
  14734. updateFunction: (particles: Particle[]) => void;
  14735. private _emitterWorldMatrix;
  14736. /**
  14737. * This function can be defined to specify initial direction for every new particle.
  14738. * It by default use the emitterType defined function
  14739. */
  14740. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  14741. /**
  14742. * This function can be defined to specify initial position for every new particle.
  14743. * It by default use the emitterType defined function
  14744. */
  14745. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  14746. /**
  14747. * @hidden
  14748. */
  14749. _inheritedVelocityOffset: Vector3;
  14750. /**
  14751. * An event triggered when the system is disposed
  14752. */
  14753. onDisposeObservable: Observable<ParticleSystem>;
  14754. private _onDisposeObserver;
  14755. /**
  14756. * Sets a callback that will be triggered when the system is disposed
  14757. */
  14758. onDispose: () => void;
  14759. private _particles;
  14760. private _epsilon;
  14761. private _capacity;
  14762. private _stockParticles;
  14763. private _newPartsExcess;
  14764. private _vertexData;
  14765. private _vertexBuffer;
  14766. private _vertexBuffers;
  14767. private _spriteBuffer;
  14768. private _indexBuffer;
  14769. private _effect;
  14770. private _customEffect;
  14771. private _cachedDefines;
  14772. private _scaledColorStep;
  14773. private _colorDiff;
  14774. private _scaledDirection;
  14775. private _scaledGravity;
  14776. private _currentRenderId;
  14777. private _alive;
  14778. private _useInstancing;
  14779. private _started;
  14780. private _stopped;
  14781. private _actualFrame;
  14782. private _scaledUpdateSpeed;
  14783. private _vertexBufferSize;
  14784. /** @hidden */
  14785. _currentEmitRateGradient: Nullable<FactorGradient>;
  14786. /** @hidden */
  14787. _currentEmitRate1: number;
  14788. /** @hidden */
  14789. _currentEmitRate2: number;
  14790. /** @hidden */
  14791. _currentStartSizeGradient: Nullable<FactorGradient>;
  14792. /** @hidden */
  14793. _currentStartSize1: number;
  14794. /** @hidden */
  14795. _currentStartSize2: number;
  14796. private readonly _rawTextureWidth;
  14797. private _rampGradientsTexture;
  14798. private _useRampGradients;
  14799. /** Gets or sets a boolean indicating that ramp gradients must be used
  14800. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  14801. */
  14802. useRampGradients: boolean;
  14803. /**
  14804. * 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.
  14805. * 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: [])
  14806. */
  14807. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  14808. private _subEmitters;
  14809. /**
  14810. * @hidden
  14811. * If the particle systems emitter should be disposed when the particle system is disposed
  14812. */
  14813. _disposeEmitterOnDispose: boolean;
  14814. /**
  14815. * The current active Sub-systems, this property is used by the root particle system only.
  14816. */
  14817. activeSubSystems: Array<ParticleSystem>;
  14818. private _rootParticleSystem;
  14819. /**
  14820. * Gets the current list of active particles
  14821. */
  14822. readonly particles: Particle[];
  14823. /**
  14824. * Returns the string "ParticleSystem"
  14825. * @returns a string containing the class name
  14826. */
  14827. getClassName(): string;
  14828. /**
  14829. * Instantiates a particle system.
  14830. * 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.
  14831. * @param name The name of the particle system
  14832. * @param capacity The max number of particles alive at the same time
  14833. * @param scene The scene the particle system belongs to
  14834. * @param customEffect a custom effect used to change the way particles are rendered by default
  14835. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  14836. * @param epsilon Offset used to render the particles
  14837. */
  14838. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  14839. private _addFactorGradient;
  14840. private _removeFactorGradient;
  14841. /**
  14842. * Adds a new life time gradient
  14843. * @param gradient defines the gradient to use (between 0 and 1)
  14844. * @param factor defines the life time factor to affect to the specified gradient
  14845. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14846. * @returns the current particle system
  14847. */
  14848. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14849. /**
  14850. * Remove a specific life time gradient
  14851. * @param gradient defines the gradient to remove
  14852. * @returns the current particle system
  14853. */
  14854. removeLifeTimeGradient(gradient: number): IParticleSystem;
  14855. /**
  14856. * Adds a new size gradient
  14857. * @param gradient defines the gradient to use (between 0 and 1)
  14858. * @param factor defines the size factor to affect to the specified gradient
  14859. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14860. * @returns the current particle system
  14861. */
  14862. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14863. /**
  14864. * Remove a specific size gradient
  14865. * @param gradient defines the gradient to remove
  14866. * @returns the current particle system
  14867. */
  14868. removeSizeGradient(gradient: number): IParticleSystem;
  14869. /**
  14870. * Adds a new color remap gradient
  14871. * @param gradient defines the gradient to use (between 0 and 1)
  14872. * @param min defines the color remap minimal range
  14873. * @param max defines the color remap maximal range
  14874. * @returns the current particle system
  14875. */
  14876. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14877. /**
  14878. * Remove a specific color remap gradient
  14879. * @param gradient defines the gradient to remove
  14880. * @returns the current particle system
  14881. */
  14882. removeColorRemapGradient(gradient: number): IParticleSystem;
  14883. /**
  14884. * Adds a new alpha remap gradient
  14885. * @param gradient defines the gradient to use (between 0 and 1)
  14886. * @param min defines the alpha remap minimal range
  14887. * @param max defines the alpha remap maximal range
  14888. * @returns the current particle system
  14889. */
  14890. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14891. /**
  14892. * Remove a specific alpha remap gradient
  14893. * @param gradient defines the gradient to remove
  14894. * @returns the current particle system
  14895. */
  14896. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  14897. /**
  14898. * Adds a new angular speed gradient
  14899. * @param gradient defines the gradient to use (between 0 and 1)
  14900. * @param factor defines the angular speed to affect to the specified gradient
  14901. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14902. * @returns the current particle system
  14903. */
  14904. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14905. /**
  14906. * Remove a specific angular speed gradient
  14907. * @param gradient defines the gradient to remove
  14908. * @returns the current particle system
  14909. */
  14910. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  14911. /**
  14912. * Adds a new velocity gradient
  14913. * @param gradient defines the gradient to use (between 0 and 1)
  14914. * @param factor defines the velocity to affect to the specified gradient
  14915. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14916. * @returns the current particle system
  14917. */
  14918. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14919. /**
  14920. * Remove a specific velocity gradient
  14921. * @param gradient defines the gradient to remove
  14922. * @returns the current particle system
  14923. */
  14924. removeVelocityGradient(gradient: number): IParticleSystem;
  14925. /**
  14926. * Adds a new limit velocity gradient
  14927. * @param gradient defines the gradient to use (between 0 and 1)
  14928. * @param factor defines the limit velocity value to affect to the specified gradient
  14929. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14930. * @returns the current particle system
  14931. */
  14932. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14933. /**
  14934. * Remove a specific limit velocity gradient
  14935. * @param gradient defines the gradient to remove
  14936. * @returns the current particle system
  14937. */
  14938. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  14939. /**
  14940. * Adds a new drag gradient
  14941. * @param gradient defines the gradient to use (between 0 and 1)
  14942. * @param factor defines the drag value to affect to the specified gradient
  14943. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14944. * @returns the current particle system
  14945. */
  14946. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14947. /**
  14948. * Remove a specific drag gradient
  14949. * @param gradient defines the gradient to remove
  14950. * @returns the current particle system
  14951. */
  14952. removeDragGradient(gradient: number): IParticleSystem;
  14953. /**
  14954. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  14955. * @param gradient defines the gradient to use (between 0 and 1)
  14956. * @param factor defines the emit rate value to affect to the specified gradient
  14957. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14958. * @returns the current particle system
  14959. */
  14960. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14961. /**
  14962. * Remove a specific emit rate gradient
  14963. * @param gradient defines the gradient to remove
  14964. * @returns the current particle system
  14965. */
  14966. removeEmitRateGradient(gradient: number): IParticleSystem;
  14967. /**
  14968. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  14969. * @param gradient defines the gradient to use (between 0 and 1)
  14970. * @param factor defines the start size value to affect to the specified gradient
  14971. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14972. * @returns the current particle system
  14973. */
  14974. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14975. /**
  14976. * Remove a specific start size gradient
  14977. * @param gradient defines the gradient to remove
  14978. * @returns the current particle system
  14979. */
  14980. removeStartSizeGradient(gradient: number): IParticleSystem;
  14981. private _createRampGradientTexture;
  14982. /**
  14983. * Gets the current list of ramp gradients.
  14984. * You must use addRampGradient and removeRampGradient to udpate this list
  14985. * @returns the list of ramp gradients
  14986. */
  14987. getRampGradients(): Nullable<Array<Color3Gradient>>;
  14988. /**
  14989. * Adds a new ramp gradient used to remap particle colors
  14990. * @param gradient defines the gradient to use (between 0 and 1)
  14991. * @param color defines the color to affect to the specified gradient
  14992. * @returns the current particle system
  14993. */
  14994. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  14995. /**
  14996. * Remove a specific ramp gradient
  14997. * @param gradient defines the gradient to remove
  14998. * @returns the current particle system
  14999. */
  15000. removeRampGradient(gradient: number): ParticleSystem;
  15001. /**
  15002. * Adds a new color gradient
  15003. * @param gradient defines the gradient to use (between 0 and 1)
  15004. * @param color1 defines the color to affect to the specified gradient
  15005. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  15006. * @returns this particle system
  15007. */
  15008. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  15009. /**
  15010. * Remove a specific color gradient
  15011. * @param gradient defines the gradient to remove
  15012. * @returns this particle system
  15013. */
  15014. removeColorGradient(gradient: number): IParticleSystem;
  15015. private _fetchR;
  15016. protected _reset(): void;
  15017. private _resetEffect;
  15018. private _createVertexBuffers;
  15019. private _createIndexBuffer;
  15020. /**
  15021. * Gets the maximum number of particles active at the same time.
  15022. * @returns The max number of active particles.
  15023. */
  15024. getCapacity(): number;
  15025. /**
  15026. * Gets whether there are still active particles in the system.
  15027. * @returns True if it is alive, otherwise false.
  15028. */
  15029. isAlive(): boolean;
  15030. /**
  15031. * Gets if the system has been started. (Note: this will still be true after stop is called)
  15032. * @returns True if it has been started, otherwise false.
  15033. */
  15034. isStarted(): boolean;
  15035. private _prepareSubEmitterInternalArray;
  15036. /**
  15037. * Starts the particle system and begins to emit
  15038. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  15039. */
  15040. start(delay?: number): void;
  15041. /**
  15042. * Stops the particle system.
  15043. * @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.
  15044. */
  15045. stop(stopSubEmitters?: boolean): void;
  15046. /**
  15047. * Remove all active particles
  15048. */
  15049. reset(): void;
  15050. /**
  15051. * @hidden (for internal use only)
  15052. */
  15053. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  15054. /**
  15055. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  15056. * Its lifetime will start back at 0.
  15057. */
  15058. recycleParticle: (particle: Particle) => void;
  15059. private _stopSubEmitters;
  15060. private _createParticle;
  15061. private _removeFromRoot;
  15062. private _emitFromParticle;
  15063. private _update;
  15064. /** @hidden */
  15065. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  15066. /** @hidden */
  15067. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  15068. /** @hidden */
  15069. private _getEffect;
  15070. /**
  15071. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  15072. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  15073. */
  15074. animate(preWarmOnly?: boolean): void;
  15075. private _appendParticleVertices;
  15076. /**
  15077. * Rebuilds the particle system.
  15078. */
  15079. rebuild(): void;
  15080. /**
  15081. * Is this system ready to be used/rendered
  15082. * @return true if the system is ready
  15083. */
  15084. isReady(): boolean;
  15085. private _render;
  15086. /**
  15087. * Renders the particle system in its current state.
  15088. * @returns the current number of particles
  15089. */
  15090. render(): number;
  15091. /**
  15092. * Disposes the particle system and free the associated resources
  15093. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  15094. */
  15095. dispose(disposeTexture?: boolean): void;
  15096. /**
  15097. * Clones the particle system.
  15098. * @param name The name of the cloned object
  15099. * @param newEmitter The new emitter to use
  15100. * @returns the cloned particle system
  15101. */
  15102. clone(name: string, newEmitter: any): ParticleSystem;
  15103. /**
  15104. * Serializes the particle system to a JSON object.
  15105. * @returns the JSON object
  15106. */
  15107. serialize(): any;
  15108. /** @hidden */
  15109. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  15110. /** @hidden */
  15111. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  15112. /**
  15113. * Parses a JSON object to create a particle system.
  15114. * @param parsedParticleSystem The JSON object to parse
  15115. * @param scene The scene to create the particle system in
  15116. * @param rootUrl The root url to use to load external dependencies like texture
  15117. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  15118. * @returns the Parsed particle system
  15119. */
  15120. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  15121. }
  15122. }
  15123. declare module "babylonjs/Particles/particle" {
  15124. import { Nullable } from "babylonjs/types";
  15125. import { Color4, Vector2, Vector3, Vector4 } from "babylonjs/Maths/math";
  15126. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  15127. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  15128. import { ColorGradient, FactorGradient } from "babylonjs/Misc/tools";
  15129. /**
  15130. * A particle represents one of the element emitted by a particle system.
  15131. * This is mainly define by its coordinates, direction, velocity and age.
  15132. */
  15133. export class Particle {
  15134. /**
  15135. * The particle system the particle belongs to.
  15136. */
  15137. particleSystem: ParticleSystem;
  15138. private static _Count;
  15139. /**
  15140. * Unique ID of the particle
  15141. */
  15142. id: number;
  15143. /**
  15144. * The world position of the particle in the scene.
  15145. */
  15146. position: Vector3;
  15147. /**
  15148. * The world direction of the particle in the scene.
  15149. */
  15150. direction: Vector3;
  15151. /**
  15152. * The color of the particle.
  15153. */
  15154. color: Color4;
  15155. /**
  15156. * The color change of the particle per step.
  15157. */
  15158. colorStep: Color4;
  15159. /**
  15160. * Defines how long will the life of the particle be.
  15161. */
  15162. lifeTime: number;
  15163. /**
  15164. * The current age of the particle.
  15165. */
  15166. age: number;
  15167. /**
  15168. * The current size of the particle.
  15169. */
  15170. size: number;
  15171. /**
  15172. * The current scale of the particle.
  15173. */
  15174. scale: Vector2;
  15175. /**
  15176. * The current angle of the particle.
  15177. */
  15178. angle: number;
  15179. /**
  15180. * Defines how fast is the angle changing.
  15181. */
  15182. angularSpeed: number;
  15183. /**
  15184. * Defines the cell index used by the particle to be rendered from a sprite.
  15185. */
  15186. cellIndex: number;
  15187. /**
  15188. * The information required to support color remapping
  15189. */
  15190. remapData: Vector4;
  15191. /** @hidden */
  15192. _randomCellOffset?: number;
  15193. /** @hidden */
  15194. _initialDirection: Nullable<Vector3>;
  15195. /** @hidden */
  15196. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  15197. /** @hidden */
  15198. _initialStartSpriteCellID: number;
  15199. /** @hidden */
  15200. _initialEndSpriteCellID: number;
  15201. /** @hidden */
  15202. _currentColorGradient: Nullable<ColorGradient>;
  15203. /** @hidden */
  15204. _currentColor1: Color4;
  15205. /** @hidden */
  15206. _currentColor2: Color4;
  15207. /** @hidden */
  15208. _currentSizeGradient: Nullable<FactorGradient>;
  15209. /** @hidden */
  15210. _currentSize1: number;
  15211. /** @hidden */
  15212. _currentSize2: number;
  15213. /** @hidden */
  15214. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  15215. /** @hidden */
  15216. _currentAngularSpeed1: number;
  15217. /** @hidden */
  15218. _currentAngularSpeed2: number;
  15219. /** @hidden */
  15220. _currentVelocityGradient: Nullable<FactorGradient>;
  15221. /** @hidden */
  15222. _currentVelocity1: number;
  15223. /** @hidden */
  15224. _currentVelocity2: number;
  15225. /** @hidden */
  15226. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  15227. /** @hidden */
  15228. _currentLimitVelocity1: number;
  15229. /** @hidden */
  15230. _currentLimitVelocity2: number;
  15231. /** @hidden */
  15232. _currentDragGradient: Nullable<FactorGradient>;
  15233. /** @hidden */
  15234. _currentDrag1: number;
  15235. /** @hidden */
  15236. _currentDrag2: number;
  15237. /** @hidden */
  15238. _randomNoiseCoordinates1: Vector3;
  15239. /** @hidden */
  15240. _randomNoiseCoordinates2: Vector3;
  15241. /**
  15242. * Creates a new instance Particle
  15243. * @param particleSystem the particle system the particle belongs to
  15244. */
  15245. constructor(
  15246. /**
  15247. * The particle system the particle belongs to.
  15248. */
  15249. particleSystem: ParticleSystem);
  15250. private updateCellInfoFromSystem;
  15251. /**
  15252. * Defines how the sprite cell index is updated for the particle
  15253. */
  15254. updateCellIndex(): void;
  15255. /** @hidden */
  15256. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  15257. /** @hidden */
  15258. _inheritParticleInfoToSubEmitters(): void;
  15259. /** @hidden */
  15260. _reset(): void;
  15261. /**
  15262. * Copy the properties of particle to another one.
  15263. * @param other the particle to copy the information to.
  15264. */
  15265. copyTo(other: Particle): void;
  15266. }
  15267. }
  15268. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  15269. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15270. import { Effect } from "babylonjs/Materials/effect";
  15271. import { Particle } from "babylonjs/Particles/particle";
  15272. /**
  15273. * Particle emitter represents a volume emitting particles.
  15274. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  15275. */
  15276. export interface IParticleEmitterType {
  15277. /**
  15278. * Called by the particle System when the direction is computed for the created particle.
  15279. * @param worldMatrix is the world matrix of the particle system
  15280. * @param directionToUpdate is the direction vector to update with the result
  15281. * @param particle is the particle we are computed the direction for
  15282. */
  15283. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15284. /**
  15285. * Called by the particle System when the position is computed for the created particle.
  15286. * @param worldMatrix is the world matrix of the particle system
  15287. * @param positionToUpdate is the position vector to update with the result
  15288. * @param particle is the particle we are computed the position for
  15289. */
  15290. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15291. /**
  15292. * Clones the current emitter and returns a copy of it
  15293. * @returns the new emitter
  15294. */
  15295. clone(): IParticleEmitterType;
  15296. /**
  15297. * Called by the GPUParticleSystem to setup the update shader
  15298. * @param effect defines the update shader
  15299. */
  15300. applyToShader(effect: Effect): void;
  15301. /**
  15302. * Returns a string to use to update the GPU particles update shader
  15303. * @returns the effect defines string
  15304. */
  15305. getEffectDefines(): string;
  15306. /**
  15307. * Returns a string representing the class name
  15308. * @returns a string containing the class name
  15309. */
  15310. getClassName(): string;
  15311. /**
  15312. * Serializes the particle system to a JSON object.
  15313. * @returns the JSON object
  15314. */
  15315. serialize(): any;
  15316. /**
  15317. * Parse properties from a JSON object
  15318. * @param serializationObject defines the JSON object
  15319. */
  15320. parse(serializationObject: any): void;
  15321. }
  15322. }
  15323. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  15324. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15325. import { Effect } from "babylonjs/Materials/effect";
  15326. import { Particle } from "babylonjs/Particles/particle";
  15327. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15328. /**
  15329. * Particle emitter emitting particles from the inside of a box.
  15330. * It emits the particles randomly between 2 given directions.
  15331. */
  15332. export class BoxParticleEmitter implements IParticleEmitterType {
  15333. /**
  15334. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15335. */
  15336. direction1: Vector3;
  15337. /**
  15338. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15339. */
  15340. direction2: Vector3;
  15341. /**
  15342. * 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.
  15343. */
  15344. minEmitBox: Vector3;
  15345. /**
  15346. * 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.
  15347. */
  15348. maxEmitBox: Vector3;
  15349. /**
  15350. * Creates a new instance BoxParticleEmitter
  15351. */
  15352. constructor();
  15353. /**
  15354. * Called by the particle System when the direction is computed for the created particle.
  15355. * @param worldMatrix is the world matrix of the particle system
  15356. * @param directionToUpdate is the direction vector to update with the result
  15357. * @param particle is the particle we are computed the direction for
  15358. */
  15359. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15360. /**
  15361. * Called by the particle System when the position is computed for the created particle.
  15362. * @param worldMatrix is the world matrix of the particle system
  15363. * @param positionToUpdate is the position vector to update with the result
  15364. * @param particle is the particle we are computed the position for
  15365. */
  15366. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15367. /**
  15368. * Clones the current emitter and returns a copy of it
  15369. * @returns the new emitter
  15370. */
  15371. clone(): BoxParticleEmitter;
  15372. /**
  15373. * Called by the GPUParticleSystem to setup the update shader
  15374. * @param effect defines the update shader
  15375. */
  15376. applyToShader(effect: Effect): void;
  15377. /**
  15378. * Returns a string to use to update the GPU particles update shader
  15379. * @returns a string containng the defines string
  15380. */
  15381. getEffectDefines(): string;
  15382. /**
  15383. * Returns the string "BoxParticleEmitter"
  15384. * @returns a string containing the class name
  15385. */
  15386. getClassName(): string;
  15387. /**
  15388. * Serializes the particle system to a JSON object.
  15389. * @returns the JSON object
  15390. */
  15391. serialize(): any;
  15392. /**
  15393. * Parse properties from a JSON object
  15394. * @param serializationObject defines the JSON object
  15395. */
  15396. parse(serializationObject: any): void;
  15397. }
  15398. }
  15399. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  15400. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15401. import { Effect } from "babylonjs/Materials/effect";
  15402. import { Particle } from "babylonjs/Particles/particle";
  15403. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15404. /**
  15405. * Particle emitter emitting particles from the inside of a cone.
  15406. * It emits the particles alongside the cone volume from the base to the particle.
  15407. * The emission direction might be randomized.
  15408. */
  15409. export class ConeParticleEmitter implements IParticleEmitterType {
  15410. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  15411. directionRandomizer: number;
  15412. private _radius;
  15413. private _angle;
  15414. private _height;
  15415. /**
  15416. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  15417. */
  15418. radiusRange: number;
  15419. /**
  15420. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  15421. */
  15422. heightRange: number;
  15423. /**
  15424. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  15425. */
  15426. emitFromSpawnPointOnly: boolean;
  15427. /**
  15428. * Gets or sets the radius of the emission cone
  15429. */
  15430. radius: number;
  15431. /**
  15432. * Gets or sets the angle of the emission cone
  15433. */
  15434. angle: number;
  15435. private _buildHeight;
  15436. /**
  15437. * Creates a new instance ConeParticleEmitter
  15438. * @param radius the radius of the emission cone (1 by default)
  15439. * @param angle the cone base angle (PI by default)
  15440. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  15441. */
  15442. constructor(radius?: number, angle?: number,
  15443. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  15444. directionRandomizer?: number);
  15445. /**
  15446. * Called by the particle System when the direction is computed for the created particle.
  15447. * @param worldMatrix is the world matrix of the particle system
  15448. * @param directionToUpdate is the direction vector to update with the result
  15449. * @param particle is the particle we are computed the direction for
  15450. */
  15451. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15452. /**
  15453. * Called by the particle System when the position is computed for the created particle.
  15454. * @param worldMatrix is the world matrix of the particle system
  15455. * @param positionToUpdate is the position vector to update with the result
  15456. * @param particle is the particle we are computed the position for
  15457. */
  15458. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15459. /**
  15460. * Clones the current emitter and returns a copy of it
  15461. * @returns the new emitter
  15462. */
  15463. clone(): ConeParticleEmitter;
  15464. /**
  15465. * Called by the GPUParticleSystem to setup the update shader
  15466. * @param effect defines the update shader
  15467. */
  15468. applyToShader(effect: Effect): void;
  15469. /**
  15470. * Returns a string to use to update the GPU particles update shader
  15471. * @returns a string containng the defines string
  15472. */
  15473. getEffectDefines(): string;
  15474. /**
  15475. * Returns the string "ConeParticleEmitter"
  15476. * @returns a string containing the class name
  15477. */
  15478. getClassName(): string;
  15479. /**
  15480. * Serializes the particle system to a JSON object.
  15481. * @returns the JSON object
  15482. */
  15483. serialize(): any;
  15484. /**
  15485. * Parse properties from a JSON object
  15486. * @param serializationObject defines the JSON object
  15487. */
  15488. parse(serializationObject: any): void;
  15489. }
  15490. }
  15491. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  15492. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15493. import { Effect } from "babylonjs/Materials/effect";
  15494. import { Particle } from "babylonjs/Particles/particle";
  15495. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15496. /**
  15497. * Particle emitter emitting particles from the inside of a cylinder.
  15498. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  15499. */
  15500. export class CylinderParticleEmitter implements IParticleEmitterType {
  15501. /**
  15502. * The radius of the emission cylinder.
  15503. */
  15504. radius: number;
  15505. /**
  15506. * The height of the emission cylinder.
  15507. */
  15508. height: number;
  15509. /**
  15510. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15511. */
  15512. radiusRange: number;
  15513. /**
  15514. * How much to randomize the particle direction [0-1].
  15515. */
  15516. directionRandomizer: number;
  15517. /**
  15518. * Creates a new instance CylinderParticleEmitter
  15519. * @param radius the radius of the emission cylinder (1 by default)
  15520. * @param height the height of the emission cylinder (1 by default)
  15521. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15522. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15523. */
  15524. constructor(
  15525. /**
  15526. * The radius of the emission cylinder.
  15527. */
  15528. radius?: number,
  15529. /**
  15530. * The height of the emission cylinder.
  15531. */
  15532. height?: number,
  15533. /**
  15534. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15535. */
  15536. radiusRange?: number,
  15537. /**
  15538. * How much to randomize the particle direction [0-1].
  15539. */
  15540. directionRandomizer?: number);
  15541. /**
  15542. * Called by the particle System when the direction is computed for the created particle.
  15543. * @param worldMatrix is the world matrix of the particle system
  15544. * @param directionToUpdate is the direction vector to update with the result
  15545. * @param particle is the particle we are computed the direction for
  15546. */
  15547. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15548. /**
  15549. * Called by the particle System when the position is computed for the created particle.
  15550. * @param worldMatrix is the world matrix of the particle system
  15551. * @param positionToUpdate is the position vector to update with the result
  15552. * @param particle is the particle we are computed the position for
  15553. */
  15554. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15555. /**
  15556. * Clones the current emitter and returns a copy of it
  15557. * @returns the new emitter
  15558. */
  15559. clone(): CylinderParticleEmitter;
  15560. /**
  15561. * Called by the GPUParticleSystem to setup the update shader
  15562. * @param effect defines the update shader
  15563. */
  15564. applyToShader(effect: Effect): void;
  15565. /**
  15566. * Returns a string to use to update the GPU particles update shader
  15567. * @returns a string containng the defines string
  15568. */
  15569. getEffectDefines(): string;
  15570. /**
  15571. * Returns the string "CylinderParticleEmitter"
  15572. * @returns a string containing the class name
  15573. */
  15574. getClassName(): string;
  15575. /**
  15576. * Serializes the particle system to a JSON object.
  15577. * @returns the JSON object
  15578. */
  15579. serialize(): any;
  15580. /**
  15581. * Parse properties from a JSON object
  15582. * @param serializationObject defines the JSON object
  15583. */
  15584. parse(serializationObject: any): void;
  15585. }
  15586. /**
  15587. * Particle emitter emitting particles from the inside of a cylinder.
  15588. * It emits the particles randomly between two vectors.
  15589. */
  15590. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  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. * Creates a new instance CylinderDirectedParticleEmitter
  15601. * @param radius the radius of the emission cylinder (1 by default)
  15602. * @param height the height of the emission cylinder (1 by default)
  15603. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15604. * @param direction1 the min limit of the emission direction (up vector by default)
  15605. * @param direction2 the max limit of the emission direction (up vector by default)
  15606. */
  15607. constructor(radius?: number, height?: number, radiusRange?: number,
  15608. /**
  15609. * The min limit of the emission direction.
  15610. */
  15611. direction1?: Vector3,
  15612. /**
  15613. * The max limit of the emission direction.
  15614. */
  15615. direction2?: Vector3);
  15616. /**
  15617. * Called by the particle System when the direction is computed for the created particle.
  15618. * @param worldMatrix is the world matrix of the particle system
  15619. * @param directionToUpdate is the direction vector to update with the result
  15620. * @param particle is the particle we are computed the direction for
  15621. */
  15622. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15623. /**
  15624. * Clones the current emitter and returns a copy of it
  15625. * @returns the new emitter
  15626. */
  15627. clone(): CylinderDirectedParticleEmitter;
  15628. /**
  15629. * Called by the GPUParticleSystem to setup the update shader
  15630. * @param effect defines the update shader
  15631. */
  15632. applyToShader(effect: Effect): void;
  15633. /**
  15634. * Returns a string to use to update the GPU particles update shader
  15635. * @returns a string containng the defines string
  15636. */
  15637. getEffectDefines(): string;
  15638. /**
  15639. * Returns the string "CylinderDirectedParticleEmitter"
  15640. * @returns a string containing the class name
  15641. */
  15642. getClassName(): string;
  15643. /**
  15644. * Serializes the particle system to a JSON object.
  15645. * @returns the JSON object
  15646. */
  15647. serialize(): any;
  15648. /**
  15649. * Parse properties from a JSON object
  15650. * @param serializationObject defines the JSON object
  15651. */
  15652. parse(serializationObject: any): void;
  15653. }
  15654. }
  15655. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  15656. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15657. import { Effect } from "babylonjs/Materials/effect";
  15658. import { Particle } from "babylonjs/Particles/particle";
  15659. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15660. /**
  15661. * Particle emitter emitting particles from the inside of a hemisphere.
  15662. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  15663. */
  15664. export class HemisphericParticleEmitter implements IParticleEmitterType {
  15665. /**
  15666. * The radius of the emission hemisphere.
  15667. */
  15668. radius: number;
  15669. /**
  15670. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15671. */
  15672. radiusRange: number;
  15673. /**
  15674. * How much to randomize the particle direction [0-1].
  15675. */
  15676. directionRandomizer: number;
  15677. /**
  15678. * Creates a new instance HemisphericParticleEmitter
  15679. * @param radius the radius of the emission hemisphere (1 by default)
  15680. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15681. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15682. */
  15683. constructor(
  15684. /**
  15685. * The radius of the emission hemisphere.
  15686. */
  15687. radius?: number,
  15688. /**
  15689. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15690. */
  15691. radiusRange?: number,
  15692. /**
  15693. * How much to randomize the particle direction [0-1].
  15694. */
  15695. directionRandomizer?: number);
  15696. /**
  15697. * Called by the particle System when the direction is computed for the created particle.
  15698. * @param worldMatrix is the world matrix of the particle system
  15699. * @param directionToUpdate is the direction vector to update with the result
  15700. * @param particle is the particle we are computed the direction for
  15701. */
  15702. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15703. /**
  15704. * Called by the particle System when the position is computed for the created particle.
  15705. * @param worldMatrix is the world matrix of the particle system
  15706. * @param positionToUpdate is the position vector to update with the result
  15707. * @param particle is the particle we are computed the position for
  15708. */
  15709. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15710. /**
  15711. * Clones the current emitter and returns a copy of it
  15712. * @returns the new emitter
  15713. */
  15714. clone(): HemisphericParticleEmitter;
  15715. /**
  15716. * Called by the GPUParticleSystem to setup the update shader
  15717. * @param effect defines the update shader
  15718. */
  15719. applyToShader(effect: Effect): void;
  15720. /**
  15721. * Returns a string to use to update the GPU particles update shader
  15722. * @returns a string containng the defines string
  15723. */
  15724. getEffectDefines(): string;
  15725. /**
  15726. * Returns the string "HemisphericParticleEmitter"
  15727. * @returns a string containing the class name
  15728. */
  15729. getClassName(): string;
  15730. /**
  15731. * Serializes the particle system to a JSON object.
  15732. * @returns the JSON object
  15733. */
  15734. serialize(): any;
  15735. /**
  15736. * Parse properties from a JSON object
  15737. * @param serializationObject defines the JSON object
  15738. */
  15739. parse(serializationObject: any): void;
  15740. }
  15741. }
  15742. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  15743. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15744. import { Effect } from "babylonjs/Materials/effect";
  15745. import { Particle } from "babylonjs/Particles/particle";
  15746. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15747. /**
  15748. * Particle emitter emitting particles from a point.
  15749. * It emits the particles randomly between 2 given directions.
  15750. */
  15751. export class PointParticleEmitter implements IParticleEmitterType {
  15752. /**
  15753. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15754. */
  15755. direction1: Vector3;
  15756. /**
  15757. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15758. */
  15759. direction2: Vector3;
  15760. /**
  15761. * Creates a new instance PointParticleEmitter
  15762. */
  15763. constructor();
  15764. /**
  15765. * Called by the particle System when the direction is computed for the created particle.
  15766. * @param worldMatrix is the world matrix of the particle system
  15767. * @param directionToUpdate is the direction vector to update with the result
  15768. * @param particle is the particle we are computed the direction for
  15769. */
  15770. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15771. /**
  15772. * Called by the particle System when the position is computed for the created particle.
  15773. * @param worldMatrix is the world matrix of the particle system
  15774. * @param positionToUpdate is the position vector to update with the result
  15775. * @param particle is the particle we are computed the position for
  15776. */
  15777. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15778. /**
  15779. * Clones the current emitter and returns a copy of it
  15780. * @returns the new emitter
  15781. */
  15782. clone(): PointParticleEmitter;
  15783. /**
  15784. * Called by the GPUParticleSystem to setup the update shader
  15785. * @param effect defines the update shader
  15786. */
  15787. applyToShader(effect: Effect): void;
  15788. /**
  15789. * Returns a string to use to update the GPU particles update shader
  15790. * @returns a string containng the defines string
  15791. */
  15792. getEffectDefines(): string;
  15793. /**
  15794. * Returns the string "PointParticleEmitter"
  15795. * @returns a string containing the class name
  15796. */
  15797. getClassName(): string;
  15798. /**
  15799. * Serializes the particle system to a JSON object.
  15800. * @returns the JSON object
  15801. */
  15802. serialize(): any;
  15803. /**
  15804. * Parse properties from a JSON object
  15805. * @param serializationObject defines the JSON object
  15806. */
  15807. parse(serializationObject: any): void;
  15808. }
  15809. }
  15810. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  15811. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15812. import { Effect } from "babylonjs/Materials/effect";
  15813. import { Particle } from "babylonjs/Particles/particle";
  15814. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15815. /**
  15816. * Particle emitter emitting particles from the inside of a sphere.
  15817. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  15818. */
  15819. export class SphereParticleEmitter implements IParticleEmitterType {
  15820. /**
  15821. * The radius of the emission sphere.
  15822. */
  15823. radius: number;
  15824. /**
  15825. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15826. */
  15827. radiusRange: number;
  15828. /**
  15829. * How much to randomize the particle direction [0-1].
  15830. */
  15831. directionRandomizer: number;
  15832. /**
  15833. * Creates a new instance SphereParticleEmitter
  15834. * @param radius the radius of the emission sphere (1 by default)
  15835. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15836. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15837. */
  15838. constructor(
  15839. /**
  15840. * The radius of the emission sphere.
  15841. */
  15842. radius?: number,
  15843. /**
  15844. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15845. */
  15846. radiusRange?: number,
  15847. /**
  15848. * How much to randomize the particle direction [0-1].
  15849. */
  15850. directionRandomizer?: number);
  15851. /**
  15852. * Called by the particle System when the direction is computed for the created particle.
  15853. * @param worldMatrix is the world matrix of the particle system
  15854. * @param directionToUpdate is the direction vector to update with the result
  15855. * @param particle is the particle we are computed the direction for
  15856. */
  15857. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15858. /**
  15859. * Called by the particle System when the position is computed for the created particle.
  15860. * @param worldMatrix is the world matrix of the particle system
  15861. * @param positionToUpdate is the position vector to update with the result
  15862. * @param particle is the particle we are computed the position for
  15863. */
  15864. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15865. /**
  15866. * Clones the current emitter and returns a copy of it
  15867. * @returns the new emitter
  15868. */
  15869. clone(): SphereParticleEmitter;
  15870. /**
  15871. * Called by the GPUParticleSystem to setup the update shader
  15872. * @param effect defines the update shader
  15873. */
  15874. applyToShader(effect: Effect): void;
  15875. /**
  15876. * Returns a string to use to update the GPU particles update shader
  15877. * @returns a string containng the defines string
  15878. */
  15879. getEffectDefines(): string;
  15880. /**
  15881. * Returns the string "SphereParticleEmitter"
  15882. * @returns a string containing the class name
  15883. */
  15884. getClassName(): string;
  15885. /**
  15886. * Serializes the particle system to a JSON object.
  15887. * @returns the JSON object
  15888. */
  15889. serialize(): any;
  15890. /**
  15891. * Parse properties from a JSON object
  15892. * @param serializationObject defines the JSON object
  15893. */
  15894. parse(serializationObject: any): void;
  15895. }
  15896. /**
  15897. * Particle emitter emitting particles from the inside of a sphere.
  15898. * It emits the particles randomly between two vectors.
  15899. */
  15900. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  15901. /**
  15902. * The min limit of the emission direction.
  15903. */
  15904. direction1: Vector3;
  15905. /**
  15906. * The max limit of the emission direction.
  15907. */
  15908. direction2: Vector3;
  15909. /**
  15910. * Creates a new instance SphereDirectedParticleEmitter
  15911. * @param radius the radius of the emission sphere (1 by default)
  15912. * @param direction1 the min limit of the emission direction (up vector by default)
  15913. * @param direction2 the max limit of the emission direction (up vector by default)
  15914. */
  15915. constructor(radius?: number,
  15916. /**
  15917. * The min limit of the emission direction.
  15918. */
  15919. direction1?: Vector3,
  15920. /**
  15921. * The max limit of the emission direction.
  15922. */
  15923. direction2?: Vector3);
  15924. /**
  15925. * Called by the particle System when the direction is computed for the created particle.
  15926. * @param worldMatrix is the world matrix of the particle system
  15927. * @param directionToUpdate is the direction vector to update with the result
  15928. * @param particle is the particle we are computed the direction for
  15929. */
  15930. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15931. /**
  15932. * Clones the current emitter and returns a copy of it
  15933. * @returns the new emitter
  15934. */
  15935. clone(): SphereDirectedParticleEmitter;
  15936. /**
  15937. * Called by the GPUParticleSystem to setup the update shader
  15938. * @param effect defines the update shader
  15939. */
  15940. applyToShader(effect: Effect): void;
  15941. /**
  15942. * Returns a string to use to update the GPU particles update shader
  15943. * @returns a string containng the defines string
  15944. */
  15945. getEffectDefines(): string;
  15946. /**
  15947. * Returns the string "SphereDirectedParticleEmitter"
  15948. * @returns a string containing the class name
  15949. */
  15950. getClassName(): string;
  15951. /**
  15952. * Serializes the particle system to a JSON object.
  15953. * @returns the JSON object
  15954. */
  15955. serialize(): any;
  15956. /**
  15957. * Parse properties from a JSON object
  15958. * @param serializationObject defines the JSON object
  15959. */
  15960. parse(serializationObject: any): void;
  15961. }
  15962. }
  15963. declare module "babylonjs/Particles/EmitterTypes/index" {
  15964. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  15965. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  15966. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  15967. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  15968. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15969. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  15970. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  15971. }
  15972. declare module "babylonjs/Particles/IParticleSystem" {
  15973. import { Nullable } from "babylonjs/types";
  15974. import { Color4, Color3, Vector2, Vector3 } from "babylonjs/Maths/math";
  15975. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15976. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  15977. import { Texture } from "babylonjs/Materials/Textures/texture";
  15978. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  15979. import { Scene } from "babylonjs/scene";
  15980. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/tools";
  15981. import { Animation } from "babylonjs/Animations/animation";
  15982. /**
  15983. * Interface representing a particle system in Babylon.js.
  15984. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  15985. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  15986. */
  15987. export interface IParticleSystem {
  15988. /**
  15989. * List of animations used by the particle system.
  15990. */
  15991. animations: Animation[];
  15992. /**
  15993. * The id of the Particle system.
  15994. */
  15995. id: string;
  15996. /**
  15997. * The name of the Particle system.
  15998. */
  15999. name: string;
  16000. /**
  16001. * The emitter represents the Mesh or position we are attaching the particle system to.
  16002. */
  16003. emitter: Nullable<AbstractMesh | Vector3>;
  16004. /**
  16005. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  16006. */
  16007. isBillboardBased: boolean;
  16008. /**
  16009. * The rendering group used by the Particle system to chose when to render.
  16010. */
  16011. renderingGroupId: number;
  16012. /**
  16013. * The layer mask we are rendering the particles through.
  16014. */
  16015. layerMask: number;
  16016. /**
  16017. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16018. */
  16019. updateSpeed: number;
  16020. /**
  16021. * The amount of time the particle system is running (depends of the overall update speed).
  16022. */
  16023. targetStopDuration: number;
  16024. /**
  16025. * The texture used to render each particle. (this can be a spritesheet)
  16026. */
  16027. particleTexture: Nullable<Texture>;
  16028. /**
  16029. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  16030. */
  16031. blendMode: number;
  16032. /**
  16033. * Minimum life time of emitting particles.
  16034. */
  16035. minLifeTime: number;
  16036. /**
  16037. * Maximum life time of emitting particles.
  16038. */
  16039. maxLifeTime: number;
  16040. /**
  16041. * Minimum Size of emitting particles.
  16042. */
  16043. minSize: number;
  16044. /**
  16045. * Maximum Size of emitting particles.
  16046. */
  16047. maxSize: number;
  16048. /**
  16049. * Minimum scale of emitting particles on X axis.
  16050. */
  16051. minScaleX: number;
  16052. /**
  16053. * Maximum scale of emitting particles on X axis.
  16054. */
  16055. maxScaleX: number;
  16056. /**
  16057. * Minimum scale of emitting particles on Y axis.
  16058. */
  16059. minScaleY: number;
  16060. /**
  16061. * Maximum scale of emitting particles on Y axis.
  16062. */
  16063. maxScaleY: number;
  16064. /**
  16065. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  16066. */
  16067. color1: Color4;
  16068. /**
  16069. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  16070. */
  16071. color2: Color4;
  16072. /**
  16073. * Color the particle will have at the end of its lifetime.
  16074. */
  16075. colorDead: Color4;
  16076. /**
  16077. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  16078. */
  16079. emitRate: number;
  16080. /**
  16081. * You can use gravity if you want to give an orientation to your particles.
  16082. */
  16083. gravity: Vector3;
  16084. /**
  16085. * Minimum power of emitting particles.
  16086. */
  16087. minEmitPower: number;
  16088. /**
  16089. * Maximum power of emitting particles.
  16090. */
  16091. maxEmitPower: number;
  16092. /**
  16093. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16094. */
  16095. minAngularSpeed: number;
  16096. /**
  16097. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16098. */
  16099. maxAngularSpeed: number;
  16100. /**
  16101. * Gets or sets the minimal initial rotation in radians.
  16102. */
  16103. minInitialRotation: number;
  16104. /**
  16105. * Gets or sets the maximal initial rotation in radians.
  16106. */
  16107. maxInitialRotation: number;
  16108. /**
  16109. * The particle emitter type defines the emitter used by the particle system.
  16110. * It can be for example box, sphere, or cone...
  16111. */
  16112. particleEmitterType: Nullable<IParticleEmitterType>;
  16113. /**
  16114. * Defines the delay in milliseconds before starting the system (0 by default)
  16115. */
  16116. startDelay: number;
  16117. /**
  16118. * 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
  16119. */
  16120. preWarmCycles: number;
  16121. /**
  16122. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  16123. */
  16124. preWarmStepOffset: number;
  16125. /**
  16126. * 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)
  16127. */
  16128. spriteCellChangeSpeed: number;
  16129. /**
  16130. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16131. */
  16132. startSpriteCellID: number;
  16133. /**
  16134. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16135. */
  16136. endSpriteCellID: number;
  16137. /**
  16138. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16139. */
  16140. spriteCellWidth: number;
  16141. /**
  16142. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16143. */
  16144. spriteCellHeight: number;
  16145. /**
  16146. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16147. */
  16148. spriteRandomStartCell: boolean;
  16149. /**
  16150. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  16151. */
  16152. isAnimationSheetEnabled: boolean;
  16153. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16154. translationPivot: Vector2;
  16155. /**
  16156. * Gets or sets a texture used to add random noise to particle positions
  16157. */
  16158. noiseTexture: Nullable<BaseTexture>;
  16159. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16160. noiseStrength: Vector3;
  16161. /**
  16162. * Gets or sets the billboard mode to use when isBillboardBased = true.
  16163. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  16164. */
  16165. billboardMode: number;
  16166. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  16167. limitVelocityDamping: number;
  16168. /**
  16169. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16170. */
  16171. beginAnimationOnStart: boolean;
  16172. /**
  16173. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16174. */
  16175. beginAnimationFrom: number;
  16176. /**
  16177. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16178. */
  16179. beginAnimationTo: number;
  16180. /**
  16181. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16182. */
  16183. beginAnimationLoop: boolean;
  16184. /**
  16185. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16186. */
  16187. disposeOnStop: boolean;
  16188. /**
  16189. * Gets the maximum number of particles active at the same time.
  16190. * @returns The max number of active particles.
  16191. */
  16192. getCapacity(): number;
  16193. /**
  16194. * Gets if the system has been started. (Note: this will still be true after stop is called)
  16195. * @returns True if it has been started, otherwise false.
  16196. */
  16197. isStarted(): boolean;
  16198. /**
  16199. * Animates the particle system for this frame.
  16200. */
  16201. animate(): void;
  16202. /**
  16203. * Renders the particle system in its current state.
  16204. * @returns the current number of particles
  16205. */
  16206. render(): number;
  16207. /**
  16208. * Dispose the particle system and frees its associated resources.
  16209. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  16210. */
  16211. dispose(disposeTexture?: boolean): void;
  16212. /**
  16213. * Clones the particle system.
  16214. * @param name The name of the cloned object
  16215. * @param newEmitter The new emitter to use
  16216. * @returns the cloned particle system
  16217. */
  16218. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  16219. /**
  16220. * Serializes the particle system to a JSON object.
  16221. * @returns the JSON object
  16222. */
  16223. serialize(): any;
  16224. /**
  16225. * Rebuild the particle system
  16226. */
  16227. rebuild(): void;
  16228. /**
  16229. * Starts the particle system and begins to emit
  16230. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  16231. */
  16232. start(delay?: number): void;
  16233. /**
  16234. * Stops the particle system.
  16235. */
  16236. stop(): void;
  16237. /**
  16238. * Remove all active particles
  16239. */
  16240. reset(): void;
  16241. /**
  16242. * Is this system ready to be used/rendered
  16243. * @return true if the system is ready
  16244. */
  16245. isReady(): boolean;
  16246. /**
  16247. * Adds a new color gradient
  16248. * @param gradient defines the gradient to use (between 0 and 1)
  16249. * @param color1 defines the color to affect to the specified gradient
  16250. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  16251. * @returns the current particle system
  16252. */
  16253. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  16254. /**
  16255. * Remove a specific color gradient
  16256. * @param gradient defines the gradient to remove
  16257. * @returns the current particle system
  16258. */
  16259. removeColorGradient(gradient: number): IParticleSystem;
  16260. /**
  16261. * Adds a new size gradient
  16262. * @param gradient defines the gradient to use (between 0 and 1)
  16263. * @param factor defines the size factor to affect to the specified gradient
  16264. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16265. * @returns the current particle system
  16266. */
  16267. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16268. /**
  16269. * Remove a specific size gradient
  16270. * @param gradient defines the gradient to remove
  16271. * @returns the current particle system
  16272. */
  16273. removeSizeGradient(gradient: number): IParticleSystem;
  16274. /**
  16275. * Gets the current list of color gradients.
  16276. * You must use addColorGradient and removeColorGradient to udpate this list
  16277. * @returns the list of color gradients
  16278. */
  16279. getColorGradients(): Nullable<Array<ColorGradient>>;
  16280. /**
  16281. * Gets the current list of size gradients.
  16282. * You must use addSizeGradient and removeSizeGradient to udpate this list
  16283. * @returns the list of size gradients
  16284. */
  16285. getSizeGradients(): Nullable<Array<FactorGradient>>;
  16286. /**
  16287. * Gets the current list of angular speed gradients.
  16288. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  16289. * @returns the list of angular speed gradients
  16290. */
  16291. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  16292. /**
  16293. * Adds a new angular speed gradient
  16294. * @param gradient defines the gradient to use (between 0 and 1)
  16295. * @param factor defines the angular speed to affect to the specified gradient
  16296. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16297. * @returns the current particle system
  16298. */
  16299. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16300. /**
  16301. * Remove a specific angular speed gradient
  16302. * @param gradient defines the gradient to remove
  16303. * @returns the current particle system
  16304. */
  16305. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  16306. /**
  16307. * Gets the current list of velocity gradients.
  16308. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  16309. * @returns the list of velocity gradients
  16310. */
  16311. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  16312. /**
  16313. * Adds a new velocity gradient
  16314. * @param gradient defines the gradient to use (between 0 and 1)
  16315. * @param factor defines the velocity to affect to the specified gradient
  16316. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16317. * @returns the current particle system
  16318. */
  16319. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16320. /**
  16321. * Remove a specific velocity gradient
  16322. * @param gradient defines the gradient to remove
  16323. * @returns the current particle system
  16324. */
  16325. removeVelocityGradient(gradient: number): IParticleSystem;
  16326. /**
  16327. * Gets the current list of limit velocity gradients.
  16328. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  16329. * @returns the list of limit velocity gradients
  16330. */
  16331. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  16332. /**
  16333. * Adds a new limit velocity gradient
  16334. * @param gradient defines the gradient to use (between 0 and 1)
  16335. * @param factor defines the limit velocity to affect to the specified gradient
  16336. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16337. * @returns the current particle system
  16338. */
  16339. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16340. /**
  16341. * Remove a specific limit velocity gradient
  16342. * @param gradient defines the gradient to remove
  16343. * @returns the current particle system
  16344. */
  16345. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  16346. /**
  16347. * Adds a new drag gradient
  16348. * @param gradient defines the gradient to use (between 0 and 1)
  16349. * @param factor defines the drag to affect to the specified gradient
  16350. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16351. * @returns the current particle system
  16352. */
  16353. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16354. /**
  16355. * Remove a specific drag gradient
  16356. * @param gradient defines the gradient to remove
  16357. * @returns the current particle system
  16358. */
  16359. removeDragGradient(gradient: number): IParticleSystem;
  16360. /**
  16361. * Gets the current list of drag gradients.
  16362. * You must use addDragGradient and removeDragGradient to udpate this list
  16363. * @returns the list of drag gradients
  16364. */
  16365. getDragGradients(): Nullable<Array<FactorGradient>>;
  16366. /**
  16367. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  16368. * @param gradient defines the gradient to use (between 0 and 1)
  16369. * @param factor defines the emit rate to affect to the specified gradient
  16370. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16371. * @returns the current particle system
  16372. */
  16373. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16374. /**
  16375. * Remove a specific emit rate gradient
  16376. * @param gradient defines the gradient to remove
  16377. * @returns the current particle system
  16378. */
  16379. removeEmitRateGradient(gradient: number): IParticleSystem;
  16380. /**
  16381. * Gets the current list of emit rate gradients.
  16382. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  16383. * @returns the list of emit rate gradients
  16384. */
  16385. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  16386. /**
  16387. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  16388. * @param gradient defines the gradient to use (between 0 and 1)
  16389. * @param factor defines the start size to affect to the specified gradient
  16390. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16391. * @returns the current particle system
  16392. */
  16393. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16394. /**
  16395. * Remove a specific start size gradient
  16396. * @param gradient defines the gradient to remove
  16397. * @returns the current particle system
  16398. */
  16399. removeStartSizeGradient(gradient: number): IParticleSystem;
  16400. /**
  16401. * Gets the current list of start size gradients.
  16402. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  16403. * @returns the list of start size gradients
  16404. */
  16405. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  16406. /**
  16407. * Adds a new life time gradient
  16408. * @param gradient defines the gradient to use (between 0 and 1)
  16409. * @param factor defines the life time factor to affect to the specified gradient
  16410. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16411. * @returns the current particle system
  16412. */
  16413. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16414. /**
  16415. * Remove a specific life time gradient
  16416. * @param gradient defines the gradient to remove
  16417. * @returns the current particle system
  16418. */
  16419. removeLifeTimeGradient(gradient: number): IParticleSystem;
  16420. /**
  16421. * Gets the current list of life time gradients.
  16422. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  16423. * @returns the list of life time gradients
  16424. */
  16425. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  16426. /**
  16427. * Gets the current list of color gradients.
  16428. * You must use addColorGradient and removeColorGradient to udpate this list
  16429. * @returns the list of color gradients
  16430. */
  16431. getColorGradients(): Nullable<Array<ColorGradient>>;
  16432. /**
  16433. * Adds a new ramp gradient used to remap particle colors
  16434. * @param gradient defines the gradient to use (between 0 and 1)
  16435. * @param color defines the color to affect to the specified gradient
  16436. * @returns the current particle system
  16437. */
  16438. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  16439. /**
  16440. * Gets the current list of ramp gradients.
  16441. * You must use addRampGradient and removeRampGradient to udpate this list
  16442. * @returns the list of ramp gradients
  16443. */
  16444. getRampGradients(): Nullable<Array<Color3Gradient>>;
  16445. /** Gets or sets a boolean indicating that ramp gradients must be used
  16446. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  16447. */
  16448. useRampGradients: boolean;
  16449. /**
  16450. * Adds a new color remap gradient
  16451. * @param gradient defines the gradient to use (between 0 and 1)
  16452. * @param min defines the color remap minimal range
  16453. * @param max defines the color remap maximal range
  16454. * @returns the current particle system
  16455. */
  16456. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16457. /**
  16458. * Gets the current list of color remap gradients.
  16459. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  16460. * @returns the list of color remap gradients
  16461. */
  16462. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  16463. /**
  16464. * Adds a new alpha remap gradient
  16465. * @param gradient defines the gradient to use (between 0 and 1)
  16466. * @param min defines the alpha remap minimal range
  16467. * @param max defines the alpha remap maximal range
  16468. * @returns the current particle system
  16469. */
  16470. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16471. /**
  16472. * Gets the current list of alpha remap gradients.
  16473. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  16474. * @returns the list of alpha remap gradients
  16475. */
  16476. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  16477. /**
  16478. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  16479. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16480. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16481. * @returns the emitter
  16482. */
  16483. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  16484. /**
  16485. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  16486. * @param radius The radius of the hemisphere to emit from
  16487. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16488. * @returns the emitter
  16489. */
  16490. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  16491. /**
  16492. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  16493. * @param radius The radius of the sphere to emit from
  16494. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16495. * @returns the emitter
  16496. */
  16497. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  16498. /**
  16499. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  16500. * @param radius The radius of the sphere to emit from
  16501. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  16502. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  16503. * @returns the emitter
  16504. */
  16505. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  16506. /**
  16507. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  16508. * @param radius The radius of the emission cylinder
  16509. * @param height The height of the emission cylinder
  16510. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  16511. * @param directionRandomizer How much to randomize the particle direction [0-1]
  16512. * @returns the emitter
  16513. */
  16514. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  16515. /**
  16516. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  16517. * @param radius The radius of the cylinder to emit from
  16518. * @param height The height of the emission cylinder
  16519. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16520. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  16521. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  16522. * @returns the emitter
  16523. */
  16524. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  16525. /**
  16526. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  16527. * @param radius The radius of the cone to emit from
  16528. * @param angle The base angle of the cone
  16529. * @returns the emitter
  16530. */
  16531. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  16532. /**
  16533. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  16534. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16535. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16536. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16537. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16538. * @returns the emitter
  16539. */
  16540. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  16541. /**
  16542. * Get hosting scene
  16543. * @returns the scene
  16544. */
  16545. getScene(): Scene;
  16546. }
  16547. }
  16548. declare module "babylonjs/Meshes/instancedMesh" {
  16549. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  16550. import { Vector3 } from "babylonjs/Maths/math";
  16551. import { Camera } from "babylonjs/Cameras/camera";
  16552. import { Node } from "babylonjs/node";
  16553. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16554. import { Mesh } from "babylonjs/Meshes/mesh";
  16555. import { Material } from "babylonjs/Materials/material";
  16556. import { Skeleton } from "babylonjs/Bones/skeleton";
  16557. /**
  16558. * Creates an instance based on a source mesh.
  16559. */
  16560. export class InstancedMesh extends AbstractMesh {
  16561. private _sourceMesh;
  16562. private _currentLOD;
  16563. /** @hidden */
  16564. _indexInSourceMeshInstanceArray: number;
  16565. constructor(name: string, source: Mesh);
  16566. /**
  16567. * Returns the string "InstancedMesh".
  16568. */
  16569. getClassName(): string;
  16570. /**
  16571. * If the source mesh receives shadows
  16572. */
  16573. readonly receiveShadows: boolean;
  16574. /**
  16575. * The material of the source mesh
  16576. */
  16577. readonly material: Nullable<Material>;
  16578. /**
  16579. * Visibility of the source mesh
  16580. */
  16581. readonly visibility: number;
  16582. /**
  16583. * Skeleton of the source mesh
  16584. */
  16585. readonly skeleton: Nullable<Skeleton>;
  16586. /**
  16587. * Rendering ground id of the source mesh
  16588. */
  16589. renderingGroupId: number;
  16590. /**
  16591. * Returns the total number of vertices (integer).
  16592. */
  16593. getTotalVertices(): number;
  16594. /**
  16595. * Returns a positive integer : the total number of indices in this mesh geometry.
  16596. * @returns the numner of indices or zero if the mesh has no geometry.
  16597. */
  16598. getTotalIndices(): number;
  16599. /**
  16600. * The source mesh of the instance
  16601. */
  16602. readonly sourceMesh: Mesh;
  16603. /**
  16604. * Is this node ready to be used/rendered
  16605. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  16606. * @return {boolean} is it ready
  16607. */
  16608. isReady(completeCheck?: boolean): boolean;
  16609. /**
  16610. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  16611. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  16612. * @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.
  16613. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  16614. */
  16615. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  16616. /**
  16617. * Sets the vertex data of the mesh geometry for the requested `kind`.
  16618. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  16619. * The `data` are either a numeric array either a Float32Array.
  16620. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  16621. * 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).
  16622. * Note that a new underlying VertexBuffer object is created each call.
  16623. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16624. *
  16625. * Possible `kind` values :
  16626. * - VertexBuffer.PositionKind
  16627. * - VertexBuffer.UVKind
  16628. * - VertexBuffer.UV2Kind
  16629. * - VertexBuffer.UV3Kind
  16630. * - VertexBuffer.UV4Kind
  16631. * - VertexBuffer.UV5Kind
  16632. * - VertexBuffer.UV6Kind
  16633. * - VertexBuffer.ColorKind
  16634. * - VertexBuffer.MatricesIndicesKind
  16635. * - VertexBuffer.MatricesIndicesExtraKind
  16636. * - VertexBuffer.MatricesWeightsKind
  16637. * - VertexBuffer.MatricesWeightsExtraKind
  16638. *
  16639. * Returns the Mesh.
  16640. */
  16641. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  16642. /**
  16643. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  16644. * If the mesh has no geometry, it is simply returned as it is.
  16645. * The `data` are either a numeric array either a Float32Array.
  16646. * No new underlying VertexBuffer object is created.
  16647. * 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.
  16648. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  16649. *
  16650. * Possible `kind` values :
  16651. * - VertexBuffer.PositionKind
  16652. * - VertexBuffer.UVKind
  16653. * - VertexBuffer.UV2Kind
  16654. * - VertexBuffer.UV3Kind
  16655. * - VertexBuffer.UV4Kind
  16656. * - VertexBuffer.UV5Kind
  16657. * - VertexBuffer.UV6Kind
  16658. * - VertexBuffer.ColorKind
  16659. * - VertexBuffer.MatricesIndicesKind
  16660. * - VertexBuffer.MatricesIndicesExtraKind
  16661. * - VertexBuffer.MatricesWeightsKind
  16662. * - VertexBuffer.MatricesWeightsExtraKind
  16663. *
  16664. * Returns the Mesh.
  16665. */
  16666. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  16667. /**
  16668. * Sets the mesh indices.
  16669. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  16670. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  16671. * This method creates a new index buffer each call.
  16672. * Returns the Mesh.
  16673. */
  16674. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  16675. /**
  16676. * Boolean : True if the mesh owns the requested kind of data.
  16677. */
  16678. isVerticesDataPresent(kind: string): boolean;
  16679. /**
  16680. * Returns an array of indices (IndicesArray).
  16681. */
  16682. getIndices(): Nullable<IndicesArray>;
  16683. readonly _positions: Nullable<Vector3[]>;
  16684. /**
  16685. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  16686. * This means the mesh underlying bounding box and sphere are recomputed.
  16687. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  16688. * @returns the current mesh
  16689. */
  16690. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  16691. /** @hidden */
  16692. _preActivate(): InstancedMesh;
  16693. /** @hidden */
  16694. _activate(renderId: number): InstancedMesh;
  16695. /**
  16696. * Returns the current associated LOD AbstractMesh.
  16697. */
  16698. getLOD(camera: Camera): AbstractMesh;
  16699. /** @hidden */
  16700. _syncSubMeshes(): InstancedMesh;
  16701. /** @hidden */
  16702. _generatePointsArray(): boolean;
  16703. /**
  16704. * Creates a new InstancedMesh from the current mesh.
  16705. * - name (string) : the cloned mesh name
  16706. * - newParent (optional Node) : the optional Node to parent the clone to.
  16707. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  16708. *
  16709. * Returns the clone.
  16710. */
  16711. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  16712. /**
  16713. * Disposes the InstancedMesh.
  16714. * Returns nothing.
  16715. */
  16716. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16717. }
  16718. }
  16719. declare module "babylonjs/Materials/shaderMaterial" {
  16720. import { Scene } from "babylonjs/scene";
  16721. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  16722. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16723. import { Mesh } from "babylonjs/Meshes/mesh";
  16724. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  16725. import { Texture } from "babylonjs/Materials/Textures/texture";
  16726. import { Material } from "babylonjs/Materials/material";
  16727. /**
  16728. * Defines the options associated with the creation of a shader material.
  16729. */
  16730. export interface IShaderMaterialOptions {
  16731. /**
  16732. * Does the material work in alpha blend mode
  16733. */
  16734. needAlphaBlending: boolean;
  16735. /**
  16736. * Does the material work in alpha test mode
  16737. */
  16738. needAlphaTesting: boolean;
  16739. /**
  16740. * The list of attribute names used in the shader
  16741. */
  16742. attributes: string[];
  16743. /**
  16744. * The list of unifrom names used in the shader
  16745. */
  16746. uniforms: string[];
  16747. /**
  16748. * The list of UBO names used in the shader
  16749. */
  16750. uniformBuffers: string[];
  16751. /**
  16752. * The list of sampler names used in the shader
  16753. */
  16754. samplers: string[];
  16755. /**
  16756. * The list of defines used in the shader
  16757. */
  16758. defines: string[];
  16759. }
  16760. /**
  16761. * 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.
  16762. *
  16763. * This returned material effects how the mesh will look based on the code in the shaders.
  16764. *
  16765. * @see http://doc.babylonjs.com/how_to/shader_material
  16766. */
  16767. export class ShaderMaterial extends Material {
  16768. private _shaderPath;
  16769. private _options;
  16770. private _textures;
  16771. private _textureArrays;
  16772. private _floats;
  16773. private _ints;
  16774. private _floatsArrays;
  16775. private _colors3;
  16776. private _colors3Arrays;
  16777. private _colors4;
  16778. private _vectors2;
  16779. private _vectors3;
  16780. private _vectors4;
  16781. private _matrices;
  16782. private _matrices3x3;
  16783. private _matrices2x2;
  16784. private _vectors2Arrays;
  16785. private _vectors3Arrays;
  16786. private _cachedWorldViewMatrix;
  16787. private _renderId;
  16788. /**
  16789. * Instantiate a new shader material.
  16790. * 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.
  16791. * This returned material effects how the mesh will look based on the code in the shaders.
  16792. * @see http://doc.babylonjs.com/how_to/shader_material
  16793. * @param name Define the name of the material in the scene
  16794. * @param scene Define the scene the material belongs to
  16795. * @param shaderPath Defines the route to the shader code in one of three ways:
  16796. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  16797. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  16798. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  16799. * @param options Define the options used to create the shader
  16800. */
  16801. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  16802. /**
  16803. * Gets the current class name of the material e.g. "ShaderMaterial"
  16804. * Mainly use in serialization.
  16805. * @returns the class name
  16806. */
  16807. getClassName(): string;
  16808. /**
  16809. * Specifies if the material will require alpha blending
  16810. * @returns a boolean specifying if alpha blending is needed
  16811. */
  16812. needAlphaBlending(): boolean;
  16813. /**
  16814. * Specifies if this material should be rendered in alpha test mode
  16815. * @returns a boolean specifying if an alpha test is needed.
  16816. */
  16817. needAlphaTesting(): boolean;
  16818. private _checkUniform;
  16819. /**
  16820. * Set a texture in the shader.
  16821. * @param name Define the name of the uniform samplers as defined in the shader
  16822. * @param texture Define the texture to bind to this sampler
  16823. * @return the material itself allowing "fluent" like uniform updates
  16824. */
  16825. setTexture(name: string, texture: Texture): ShaderMaterial;
  16826. /**
  16827. * Set a texture array in the shader.
  16828. * @param name Define the name of the uniform sampler array as defined in the shader
  16829. * @param textures Define the list of textures to bind to this sampler
  16830. * @return the material itself allowing "fluent" like uniform updates
  16831. */
  16832. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  16833. /**
  16834. * Set a float in the shader.
  16835. * @param name Define the name of the uniform as defined in the shader
  16836. * @param value Define the value to give to the uniform
  16837. * @return the material itself allowing "fluent" like uniform updates
  16838. */
  16839. setFloat(name: string, value: number): ShaderMaterial;
  16840. /**
  16841. * Set a int in the shader.
  16842. * @param name Define the name of the uniform as defined in the shader
  16843. * @param value Define the value to give to the uniform
  16844. * @return the material itself allowing "fluent" like uniform updates
  16845. */
  16846. setInt(name: string, value: number): ShaderMaterial;
  16847. /**
  16848. * Set an array of floats in the shader.
  16849. * @param name Define the name of the uniform as defined in the shader
  16850. * @param value Define the value to give to the uniform
  16851. * @return the material itself allowing "fluent" like uniform updates
  16852. */
  16853. setFloats(name: string, value: number[]): ShaderMaterial;
  16854. /**
  16855. * Set a vec3 in the shader from a Color3.
  16856. * @param name Define the name of the uniform as defined in the shader
  16857. * @param value Define the value to give to the uniform
  16858. * @return the material itself allowing "fluent" like uniform updates
  16859. */
  16860. setColor3(name: string, value: Color3): ShaderMaterial;
  16861. /**
  16862. * Set a vec3 array in the shader from a Color3 array.
  16863. * @param name Define the name of the uniform as defined in the shader
  16864. * @param value Define the value to give to the uniform
  16865. * @return the material itself allowing "fluent" like uniform updates
  16866. */
  16867. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  16868. /**
  16869. * Set a vec4 in the shader from a Color4.
  16870. * @param name Define the name of the uniform as defined in the shader
  16871. * @param value Define the value to give to the uniform
  16872. * @return the material itself allowing "fluent" like uniform updates
  16873. */
  16874. setColor4(name: string, value: Color4): ShaderMaterial;
  16875. /**
  16876. * Set a vec2 in the shader from a Vector2.
  16877. * @param name Define the name of the uniform as defined in the shader
  16878. * @param value Define the value to give to the uniform
  16879. * @return the material itself allowing "fluent" like uniform updates
  16880. */
  16881. setVector2(name: string, value: Vector2): ShaderMaterial;
  16882. /**
  16883. * Set a vec3 in the shader from a Vector3.
  16884. * @param name Define the name of the uniform as defined in the shader
  16885. * @param value Define the value to give to the uniform
  16886. * @return the material itself allowing "fluent" like uniform updates
  16887. */
  16888. setVector3(name: string, value: Vector3): ShaderMaterial;
  16889. /**
  16890. * Set a vec4 in the shader from a Vector4.
  16891. * @param name Define the name of the uniform as defined in the shader
  16892. * @param value Define the value to give to the uniform
  16893. * @return the material itself allowing "fluent" like uniform updates
  16894. */
  16895. setVector4(name: string, value: Vector4): ShaderMaterial;
  16896. /**
  16897. * Set a mat4 in the shader from a Matrix.
  16898. * @param name Define the name of the uniform as defined in the shader
  16899. * @param value Define the value to give to the uniform
  16900. * @return the material itself allowing "fluent" like uniform updates
  16901. */
  16902. setMatrix(name: string, value: Matrix): ShaderMaterial;
  16903. /**
  16904. * Set a mat3 in the shader from a Float32Array.
  16905. * @param name Define the name of the uniform as defined in the shader
  16906. * @param value Define the value to give to the uniform
  16907. * @return the material itself allowing "fluent" like uniform updates
  16908. */
  16909. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  16910. /**
  16911. * Set a mat2 in the shader from a Float32Array.
  16912. * @param name Define the name of the uniform as defined in the shader
  16913. * @param value Define the value to give to the uniform
  16914. * @return the material itself allowing "fluent" like uniform updates
  16915. */
  16916. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  16917. /**
  16918. * Set a vec2 array in the shader from a number array.
  16919. * @param name Define the name of the uniform as defined in the shader
  16920. * @param value Define the value to give to the uniform
  16921. * @return the material itself allowing "fluent" like uniform updates
  16922. */
  16923. setArray2(name: string, value: number[]): ShaderMaterial;
  16924. /**
  16925. * Set a vec3 array in the shader from a number array.
  16926. * @param name Define the name of the uniform as defined in the shader
  16927. * @param value Define the value to give to the uniform
  16928. * @return the material itself allowing "fluent" like uniform updates
  16929. */
  16930. setArray3(name: string, value: number[]): ShaderMaterial;
  16931. private _checkCache;
  16932. /**
  16933. * Checks if the material is ready to render the requested mesh
  16934. * @param mesh Define the mesh to render
  16935. * @param useInstances Define whether or not the material is used with instances
  16936. * @returns true if ready, otherwise false
  16937. */
  16938. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  16939. /**
  16940. * Binds the world matrix to the material
  16941. * @param world defines the world transformation matrix
  16942. */
  16943. bindOnlyWorldMatrix(world: Matrix): void;
  16944. /**
  16945. * Binds the material to the mesh
  16946. * @param world defines the world transformation matrix
  16947. * @param mesh defines the mesh to bind the material to
  16948. */
  16949. bind(world: Matrix, mesh?: Mesh): void;
  16950. /**
  16951. * Gets the active textures from the material
  16952. * @returns an array of textures
  16953. */
  16954. getActiveTextures(): BaseTexture[];
  16955. /**
  16956. * Specifies if the material uses a texture
  16957. * @param texture defines the texture to check against the material
  16958. * @returns a boolean specifying if the material uses the texture
  16959. */
  16960. hasTexture(texture: BaseTexture): boolean;
  16961. /**
  16962. * Makes a duplicate of the material, and gives it a new name
  16963. * @param name defines the new name for the duplicated material
  16964. * @returns the cloned material
  16965. */
  16966. clone(name: string): ShaderMaterial;
  16967. /**
  16968. * Disposes the material
  16969. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  16970. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  16971. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  16972. */
  16973. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  16974. /**
  16975. * Serializes this material in a JSON representation
  16976. * @returns the serialized material object
  16977. */
  16978. serialize(): any;
  16979. /**
  16980. * Creates a shader material from parsed shader material data
  16981. * @param source defines the JSON represnetation of the material
  16982. * @param scene defines the hosting scene
  16983. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16984. * @returns a new material
  16985. */
  16986. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  16987. }
  16988. }
  16989. declare module "babylonjs/Shaders/color.fragment" {
  16990. /** @hidden */
  16991. export var colorPixelShader: {
  16992. name: string;
  16993. shader: string;
  16994. };
  16995. }
  16996. declare module "babylonjs/Shaders/color.vertex" {
  16997. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  16998. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  16999. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  17000. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  17001. /** @hidden */
  17002. export var colorVertexShader: {
  17003. name: string;
  17004. shader: string;
  17005. };
  17006. }
  17007. declare module "babylonjs/Meshes/linesMesh" {
  17008. import { Nullable } from "babylonjs/types";
  17009. import { Scene } from "babylonjs/scene";
  17010. import { Color3 } from "babylonjs/Maths/math";
  17011. import { Node } from "babylonjs/node";
  17012. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17013. import { Mesh } from "babylonjs/Meshes/mesh";
  17014. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  17015. import { Effect } from "babylonjs/Materials/effect";
  17016. import { Material } from "babylonjs/Materials/material";
  17017. import "babylonjs/Shaders/color.fragment";
  17018. import "babylonjs/Shaders/color.vertex";
  17019. /**
  17020. * Line mesh
  17021. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  17022. */
  17023. export class LinesMesh extends Mesh {
  17024. /**
  17025. * If vertex color should be applied to the mesh
  17026. */
  17027. useVertexColor?: boolean | undefined;
  17028. /**
  17029. * If vertex alpha should be applied to the mesh
  17030. */
  17031. useVertexAlpha?: boolean | undefined;
  17032. /**
  17033. * Color of the line (Default: White)
  17034. */
  17035. color: Color3;
  17036. /**
  17037. * Alpha of the line (Default: 1)
  17038. */
  17039. alpha: number;
  17040. /**
  17041. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17042. * This margin is expressed in world space coordinates, so its value may vary.
  17043. * Default value is 0.1
  17044. */
  17045. intersectionThreshold: number;
  17046. private _colorShader;
  17047. /**
  17048. * Creates a new LinesMesh
  17049. * @param name defines the name
  17050. * @param scene defines the hosting scene
  17051. * @param parent defines the parent mesh if any
  17052. * @param source defines the optional source LinesMesh used to clone data from
  17053. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  17054. * When false, achieved by calling a clone(), also passing False.
  17055. * This will make creation of children, recursive.
  17056. * @param useVertexColor defines if this LinesMesh supports vertex color
  17057. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  17058. */
  17059. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  17060. /**
  17061. * If vertex color should be applied to the mesh
  17062. */
  17063. useVertexColor?: boolean | undefined,
  17064. /**
  17065. * If vertex alpha should be applied to the mesh
  17066. */
  17067. useVertexAlpha?: boolean | undefined);
  17068. /**
  17069. * Returns the string "LineMesh"
  17070. */
  17071. getClassName(): string;
  17072. /**
  17073. * @hidden
  17074. */
  17075. /**
  17076. * @hidden
  17077. */
  17078. material: Material;
  17079. /**
  17080. * @hidden
  17081. */
  17082. readonly checkCollisions: boolean;
  17083. /** @hidden */
  17084. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  17085. /** @hidden */
  17086. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  17087. /**
  17088. * Disposes of the line mesh
  17089. * @param doNotRecurse If children should be disposed
  17090. */
  17091. dispose(doNotRecurse?: boolean): void;
  17092. /**
  17093. * Returns a new LineMesh object cloned from the current one.
  17094. */
  17095. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  17096. /**
  17097. * Creates a new InstancedLinesMesh object from the mesh model.
  17098. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  17099. * @param name defines the name of the new instance
  17100. * @returns a new InstancedLinesMesh
  17101. */
  17102. createInstance(name: string): InstancedLinesMesh;
  17103. }
  17104. /**
  17105. * Creates an instance based on a source LinesMesh
  17106. */
  17107. export class InstancedLinesMesh extends InstancedMesh {
  17108. /**
  17109. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17110. * This margin is expressed in world space coordinates, so its value may vary.
  17111. * Initilized with the intersectionThreshold value of the source LinesMesh
  17112. */
  17113. intersectionThreshold: number;
  17114. constructor(name: string, source: LinesMesh);
  17115. /**
  17116. * Returns the string "InstancedLinesMesh".
  17117. */
  17118. getClassName(): string;
  17119. }
  17120. }
  17121. declare module "babylonjs/Shaders/line.fragment" {
  17122. /** @hidden */
  17123. export var linePixelShader: {
  17124. name: string;
  17125. shader: string;
  17126. };
  17127. }
  17128. declare module "babylonjs/Shaders/line.vertex" {
  17129. /** @hidden */
  17130. export var lineVertexShader: {
  17131. name: string;
  17132. shader: string;
  17133. };
  17134. }
  17135. declare module "babylonjs/Rendering/edgesRenderer" {
  17136. import { Nullable } from "babylonjs/types";
  17137. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  17138. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17139. import { Vector3 } from "babylonjs/Maths/math";
  17140. import { IDisposable } from "babylonjs/scene";
  17141. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  17142. import "babylonjs/Shaders/line.fragment";
  17143. import "babylonjs/Shaders/line.vertex";
  17144. module "babylonjs/Meshes/abstractMesh" {
  17145. interface AbstractMesh {
  17146. /**
  17147. * Disables the mesh edge rendering mode
  17148. * @returns the currentAbstractMesh
  17149. */
  17150. disableEdgesRendering(): AbstractMesh;
  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. * Gets the edgesRenderer associated with the mesh
  17162. */
  17163. edgesRenderer: Nullable<EdgesRenderer>;
  17164. }
  17165. }
  17166. module "babylonjs/Meshes/linesMesh" {
  17167. interface LinesMesh {
  17168. /**
  17169. * Enables the edge rendering mode on the mesh.
  17170. * This mode makes the mesh edges visible
  17171. * @param epsilon defines the maximal distance between two angles to detect a face
  17172. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17173. * @returns the currentAbstractMesh
  17174. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17175. */
  17176. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17177. }
  17178. }
  17179. module "babylonjs/Meshes/linesMesh" {
  17180. interface InstancedLinesMesh {
  17181. /**
  17182. * Enables the edge rendering mode on the mesh.
  17183. * This mode makes the mesh edges visible
  17184. * @param epsilon defines the maximal distance between two angles to detect a face
  17185. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17186. * @returns the current InstancedLinesMesh
  17187. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17188. */
  17189. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  17190. }
  17191. }
  17192. /**
  17193. * Defines the minimum contract an Edges renderer should follow.
  17194. */
  17195. export interface IEdgesRenderer extends IDisposable {
  17196. /**
  17197. * Gets or sets a boolean indicating if the edgesRenderer is active
  17198. */
  17199. isEnabled: boolean;
  17200. /**
  17201. * Renders the edges of the attached mesh,
  17202. */
  17203. render(): void;
  17204. /**
  17205. * Checks wether or not the edges renderer is ready to render.
  17206. * @return true if ready, otherwise false.
  17207. */
  17208. isReady(): boolean;
  17209. }
  17210. /**
  17211. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  17212. */
  17213. export class EdgesRenderer implements IEdgesRenderer {
  17214. /**
  17215. * Define the size of the edges with an orthographic camera
  17216. */
  17217. edgesWidthScalerForOrthographic: number;
  17218. /**
  17219. * Define the size of the edges with a perspective camera
  17220. */
  17221. edgesWidthScalerForPerspective: number;
  17222. protected _source: AbstractMesh;
  17223. protected _linesPositions: number[];
  17224. protected _linesNormals: number[];
  17225. protected _linesIndices: number[];
  17226. protected _epsilon: number;
  17227. protected _indicesCount: number;
  17228. protected _lineShader: ShaderMaterial;
  17229. protected _ib: WebGLBuffer;
  17230. protected _buffers: {
  17231. [key: string]: Nullable<VertexBuffer>;
  17232. };
  17233. protected _checkVerticesInsteadOfIndices: boolean;
  17234. private _meshRebuildObserver;
  17235. private _meshDisposeObserver;
  17236. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  17237. isEnabled: boolean;
  17238. /**
  17239. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  17240. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  17241. * @param source Mesh used to create edges
  17242. * @param epsilon sum of angles in adjacency to check for edge
  17243. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  17244. * @param generateEdgesLines - should generate Lines or only prepare resources.
  17245. */
  17246. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  17247. protected _prepareRessources(): void;
  17248. /** @hidden */
  17249. _rebuild(): void;
  17250. /**
  17251. * Releases the required resources for the edges renderer
  17252. */
  17253. dispose(): void;
  17254. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  17255. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  17256. /**
  17257. * Checks if the pair of p0 and p1 is en edge
  17258. * @param faceIndex
  17259. * @param edge
  17260. * @param faceNormals
  17261. * @param p0
  17262. * @param p1
  17263. * @private
  17264. */
  17265. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  17266. /**
  17267. * push line into the position, normal and index buffer
  17268. * @protected
  17269. */
  17270. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  17271. /**
  17272. * Generates lines edges from adjacencjes
  17273. * @private
  17274. */
  17275. _generateEdgesLines(): void;
  17276. /**
  17277. * Checks wether or not the edges renderer is ready to render.
  17278. * @return true if ready, otherwise false.
  17279. */
  17280. isReady(): boolean;
  17281. /**
  17282. * Renders the edges of the attached mesh,
  17283. */
  17284. render(): void;
  17285. }
  17286. /**
  17287. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  17288. */
  17289. export class LineEdgesRenderer extends EdgesRenderer {
  17290. /**
  17291. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  17292. * @param source LineMesh used to generate edges
  17293. * @param epsilon not important (specified angle for edge detection)
  17294. * @param checkVerticesInsteadOfIndices not important for LineMesh
  17295. */
  17296. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  17297. /**
  17298. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  17299. */
  17300. _generateEdgesLines(): void;
  17301. }
  17302. }
  17303. declare module "babylonjs/Rendering/renderingGroup" {
  17304. import { SmartArray } from "babylonjs/Misc/smartArray";
  17305. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17306. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17307. import { Nullable } from "babylonjs/types";
  17308. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17309. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17310. import { Material } from "babylonjs/Materials/material";
  17311. import { Scene } from "babylonjs/scene";
  17312. /**
  17313. * This represents the object necessary to create a rendering group.
  17314. * This is exclusively used and created by the rendering manager.
  17315. * To modify the behavior, you use the available helpers in your scene or meshes.
  17316. * @hidden
  17317. */
  17318. export class RenderingGroup {
  17319. index: number;
  17320. private _scene;
  17321. private _opaqueSubMeshes;
  17322. private _transparentSubMeshes;
  17323. private _alphaTestSubMeshes;
  17324. private _depthOnlySubMeshes;
  17325. private _particleSystems;
  17326. private _spriteManagers;
  17327. private _opaqueSortCompareFn;
  17328. private _alphaTestSortCompareFn;
  17329. private _transparentSortCompareFn;
  17330. private _renderOpaque;
  17331. private _renderAlphaTest;
  17332. private _renderTransparent;
  17333. private _edgesRenderers;
  17334. onBeforeTransparentRendering: () => void;
  17335. /**
  17336. * Set the opaque sort comparison function.
  17337. * If null the sub meshes will be render in the order they were created
  17338. */
  17339. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17340. /**
  17341. * Set the alpha test sort comparison function.
  17342. * If null the sub meshes will be render in the order they were created
  17343. */
  17344. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17345. /**
  17346. * Set the transparent sort comparison function.
  17347. * If null the sub meshes will be render in the order they were created
  17348. */
  17349. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17350. /**
  17351. * Creates a new rendering group.
  17352. * @param index The rendering group index
  17353. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  17354. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  17355. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  17356. */
  17357. 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>);
  17358. /**
  17359. * Render all the sub meshes contained in the group.
  17360. * @param customRenderFunction Used to override the default render behaviour of the group.
  17361. * @returns true if rendered some submeshes.
  17362. */
  17363. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  17364. /**
  17365. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  17366. * @param subMeshes The submeshes to render
  17367. */
  17368. private renderOpaqueSorted;
  17369. /**
  17370. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  17371. * @param subMeshes The submeshes to render
  17372. */
  17373. private renderAlphaTestSorted;
  17374. /**
  17375. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  17376. * @param subMeshes The submeshes to render
  17377. */
  17378. private renderTransparentSorted;
  17379. /**
  17380. * Renders the submeshes in a specified order.
  17381. * @param subMeshes The submeshes to sort before render
  17382. * @param sortCompareFn The comparison function use to sort
  17383. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  17384. * @param transparent Specifies to activate blending if true
  17385. */
  17386. private static renderSorted;
  17387. /**
  17388. * Renders the submeshes in the order they were dispatched (no sort applied).
  17389. * @param subMeshes The submeshes to render
  17390. */
  17391. private static renderUnsorted;
  17392. /**
  17393. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17394. * are rendered back to front if in the same alpha index.
  17395. *
  17396. * @param a The first submesh
  17397. * @param b The second submesh
  17398. * @returns The result of the comparison
  17399. */
  17400. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  17401. /**
  17402. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17403. * are rendered back to front.
  17404. *
  17405. * @param a The first submesh
  17406. * @param b The second submesh
  17407. * @returns The result of the comparison
  17408. */
  17409. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  17410. /**
  17411. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17412. * are rendered front to back (prevent overdraw).
  17413. *
  17414. * @param a The first submesh
  17415. * @param b The second submesh
  17416. * @returns The result of the comparison
  17417. */
  17418. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  17419. /**
  17420. * Resets the different lists of submeshes to prepare a new frame.
  17421. */
  17422. prepare(): void;
  17423. dispose(): void;
  17424. /**
  17425. * Inserts the submesh in its correct queue depending on its material.
  17426. * @param subMesh The submesh to dispatch
  17427. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17428. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17429. */
  17430. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17431. dispatchSprites(spriteManager: ISpriteManager): void;
  17432. dispatchParticles(particleSystem: IParticleSystem): void;
  17433. private _renderParticles;
  17434. private _renderSprites;
  17435. }
  17436. }
  17437. declare module "babylonjs/Rendering/renderingManager" {
  17438. import { Nullable } from "babylonjs/types";
  17439. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17440. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17441. import { SmartArray } from "babylonjs/Misc/smartArray";
  17442. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17443. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17444. import { Material } from "babylonjs/Materials/material";
  17445. import { Scene } from "babylonjs/scene";
  17446. import { Camera } from "babylonjs/Cameras/camera";
  17447. /**
  17448. * Interface describing the different options available in the rendering manager
  17449. * regarding Auto Clear between groups.
  17450. */
  17451. export interface IRenderingManagerAutoClearSetup {
  17452. /**
  17453. * Defines whether or not autoclear is enable.
  17454. */
  17455. autoClear: boolean;
  17456. /**
  17457. * Defines whether or not to autoclear the depth buffer.
  17458. */
  17459. depth: boolean;
  17460. /**
  17461. * Defines whether or not to autoclear the stencil buffer.
  17462. */
  17463. stencil: boolean;
  17464. }
  17465. /**
  17466. * This class is used by the onRenderingGroupObservable
  17467. */
  17468. export class RenderingGroupInfo {
  17469. /**
  17470. * The Scene that being rendered
  17471. */
  17472. scene: Scene;
  17473. /**
  17474. * The camera currently used for the rendering pass
  17475. */
  17476. camera: Nullable<Camera>;
  17477. /**
  17478. * The ID of the renderingGroup being processed
  17479. */
  17480. renderingGroupId: number;
  17481. }
  17482. /**
  17483. * This is the manager responsible of all the rendering for meshes sprites and particles.
  17484. * It is enable to manage the different groups as well as the different necessary sort functions.
  17485. * This should not be used directly aside of the few static configurations
  17486. */
  17487. export class RenderingManager {
  17488. /**
  17489. * The max id used for rendering groups (not included)
  17490. */
  17491. static MAX_RENDERINGGROUPS: number;
  17492. /**
  17493. * The min id used for rendering groups (included)
  17494. */
  17495. static MIN_RENDERINGGROUPS: number;
  17496. /**
  17497. * Used to globally prevent autoclearing scenes.
  17498. */
  17499. static AUTOCLEAR: boolean;
  17500. /**
  17501. * @hidden
  17502. */
  17503. _useSceneAutoClearSetup: boolean;
  17504. private _scene;
  17505. private _renderingGroups;
  17506. private _depthStencilBufferAlreadyCleaned;
  17507. private _autoClearDepthStencil;
  17508. private _customOpaqueSortCompareFn;
  17509. private _customAlphaTestSortCompareFn;
  17510. private _customTransparentSortCompareFn;
  17511. private _renderingGroupInfo;
  17512. /**
  17513. * Instantiates a new rendering group for a particular scene
  17514. * @param scene Defines the scene the groups belongs to
  17515. */
  17516. constructor(scene: Scene);
  17517. private _clearDepthStencilBuffer;
  17518. /**
  17519. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  17520. * @hidden
  17521. */
  17522. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  17523. /**
  17524. * Resets the different information of the group to prepare a new frame
  17525. * @hidden
  17526. */
  17527. reset(): void;
  17528. /**
  17529. * Dispose and release the group and its associated resources.
  17530. * @hidden
  17531. */
  17532. dispose(): void;
  17533. /**
  17534. * Clear the info related to rendering groups preventing retention points during dispose.
  17535. */
  17536. freeRenderingGroups(): void;
  17537. private _prepareRenderingGroup;
  17538. /**
  17539. * Add a sprite manager to the rendering manager in order to render it this frame.
  17540. * @param spriteManager Define the sprite manager to render
  17541. */
  17542. dispatchSprites(spriteManager: ISpriteManager): void;
  17543. /**
  17544. * Add a particle system to the rendering manager in order to render it this frame.
  17545. * @param particleSystem Define the particle system to render
  17546. */
  17547. dispatchParticles(particleSystem: IParticleSystem): void;
  17548. /**
  17549. * Add a submesh to the manager in order to render it this frame
  17550. * @param subMesh The submesh to dispatch
  17551. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17552. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17553. */
  17554. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17555. /**
  17556. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17557. * This allowed control for front to back rendering or reversly depending of the special needs.
  17558. *
  17559. * @param renderingGroupId The rendering group id corresponding to its index
  17560. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17561. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17562. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17563. */
  17564. 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;
  17565. /**
  17566. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17567. *
  17568. * @param renderingGroupId The rendering group id corresponding to its index
  17569. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17570. * @param depth Automatically clears depth between groups if true and autoClear is true.
  17571. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  17572. */
  17573. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  17574. /**
  17575. * Gets the current auto clear configuration for one rendering group of the rendering
  17576. * manager.
  17577. * @param index the rendering group index to get the information for
  17578. * @returns The auto clear setup for the requested rendering group
  17579. */
  17580. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  17581. }
  17582. }
  17583. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  17584. import { Observable } from "babylonjs/Misc/observable";
  17585. import { SmartArray } from "babylonjs/Misc/smartArray";
  17586. import { Nullable } from "babylonjs/types";
  17587. import { Camera } from "babylonjs/Cameras/camera";
  17588. import { Scene } from "babylonjs/scene";
  17589. import { Matrix, Vector3, Color4 } from "babylonjs/Maths/math";
  17590. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  17591. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17592. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17593. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  17594. import { Texture } from "babylonjs/Materials/Textures/texture";
  17595. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  17596. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  17597. import { Engine } from "babylonjs/Engines/engine";
  17598. /**
  17599. * This Helps creating a texture that will be created from a camera in your scene.
  17600. * It is basically a dynamic texture that could be used to create special effects for instance.
  17601. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  17602. */
  17603. export class RenderTargetTexture extends Texture {
  17604. isCube: boolean;
  17605. /**
  17606. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  17607. */
  17608. static readonly REFRESHRATE_RENDER_ONCE: number;
  17609. /**
  17610. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  17611. */
  17612. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  17613. /**
  17614. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  17615. * the central point of your effect and can save a lot of performances.
  17616. */
  17617. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  17618. /**
  17619. * Use this predicate to dynamically define the list of mesh you want to render.
  17620. * If set, the renderList property will be overwritten.
  17621. */
  17622. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  17623. private _renderList;
  17624. /**
  17625. * Use this list to define the list of mesh you want to render.
  17626. */
  17627. renderList: Nullable<Array<AbstractMesh>>;
  17628. private _hookArray;
  17629. /**
  17630. * Define if particles should be rendered in your texture.
  17631. */
  17632. renderParticles: boolean;
  17633. /**
  17634. * Define if sprites should be rendered in your texture.
  17635. */
  17636. renderSprites: boolean;
  17637. /**
  17638. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  17639. */
  17640. coordinatesMode: number;
  17641. /**
  17642. * Define the camera used to render the texture.
  17643. */
  17644. activeCamera: Nullable<Camera>;
  17645. /**
  17646. * Override the render function of the texture with your own one.
  17647. */
  17648. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  17649. /**
  17650. * Define if camera post processes should be use while rendering the texture.
  17651. */
  17652. useCameraPostProcesses: boolean;
  17653. /**
  17654. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  17655. */
  17656. ignoreCameraViewport: boolean;
  17657. private _postProcessManager;
  17658. private _postProcesses;
  17659. private _resizeObserver;
  17660. /**
  17661. * An event triggered when the texture is unbind.
  17662. */
  17663. onBeforeBindObservable: Observable<RenderTargetTexture>;
  17664. /**
  17665. * An event triggered when the texture is unbind.
  17666. */
  17667. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  17668. private _onAfterUnbindObserver;
  17669. /**
  17670. * Set a after unbind callback in the texture.
  17671. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  17672. */
  17673. onAfterUnbind: () => void;
  17674. /**
  17675. * An event triggered before rendering the texture
  17676. */
  17677. onBeforeRenderObservable: Observable<number>;
  17678. private _onBeforeRenderObserver;
  17679. /**
  17680. * Set a before render callback in the texture.
  17681. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  17682. */
  17683. onBeforeRender: (faceIndex: number) => void;
  17684. /**
  17685. * An event triggered after rendering the texture
  17686. */
  17687. onAfterRenderObservable: Observable<number>;
  17688. private _onAfterRenderObserver;
  17689. /**
  17690. * Set a after render callback in the texture.
  17691. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  17692. */
  17693. onAfterRender: (faceIndex: number) => void;
  17694. /**
  17695. * An event triggered after the texture clear
  17696. */
  17697. onClearObservable: Observable<import("babylonjs/Engines/engine").Engine>;
  17698. private _onClearObserver;
  17699. /**
  17700. * Set a clear callback in the texture.
  17701. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  17702. */
  17703. onClear: (Engine: Engine) => void;
  17704. /**
  17705. * Define the clear color of the Render Target if it should be different from the scene.
  17706. */
  17707. clearColor: Color4;
  17708. protected _size: number | {
  17709. width: number;
  17710. height: number;
  17711. };
  17712. protected _initialSizeParameter: number | {
  17713. width: number;
  17714. height: number;
  17715. } | {
  17716. ratio: number;
  17717. };
  17718. protected _sizeRatio: Nullable<number>;
  17719. /** @hidden */
  17720. _generateMipMaps: boolean;
  17721. protected _renderingManager: RenderingManager;
  17722. /** @hidden */
  17723. _waitingRenderList: string[];
  17724. protected _doNotChangeAspectRatio: boolean;
  17725. protected _currentRefreshId: number;
  17726. protected _refreshRate: number;
  17727. protected _textureMatrix: Matrix;
  17728. protected _samples: number;
  17729. protected _renderTargetOptions: RenderTargetCreationOptions;
  17730. /**
  17731. * Gets render target creation options that were used.
  17732. */
  17733. readonly renderTargetOptions: RenderTargetCreationOptions;
  17734. protected _engine: Engine;
  17735. protected _onRatioRescale(): void;
  17736. /**
  17737. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  17738. * It must define where the camera used to render the texture is set
  17739. */
  17740. boundingBoxPosition: Vector3;
  17741. private _boundingBoxSize;
  17742. /**
  17743. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  17744. * When defined, the cubemap will switch to local mode
  17745. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  17746. * @example https://www.babylonjs-playground.com/#RNASML
  17747. */
  17748. boundingBoxSize: Vector3;
  17749. /**
  17750. * In case the RTT has been created with a depth texture, get the associated
  17751. * depth texture.
  17752. * Otherwise, return null.
  17753. */
  17754. depthStencilTexture: Nullable<InternalTexture>;
  17755. /**
  17756. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  17757. * or used a shadow, depth texture...
  17758. * @param name The friendly name of the texture
  17759. * @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)
  17760. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  17761. * @param generateMipMaps True if mip maps need to be generated after render.
  17762. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  17763. * @param type The type of the buffer in the RTT (int, half float, float...)
  17764. * @param isCube True if a cube texture needs to be created
  17765. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  17766. * @param generateDepthBuffer True to generate a depth buffer
  17767. * @param generateStencilBuffer True to generate a stencil buffer
  17768. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  17769. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  17770. * @param delayAllocation if the texture allocation should be delayed (default: false)
  17771. */
  17772. constructor(name: string, size: number | {
  17773. width: number;
  17774. height: number;
  17775. } | {
  17776. ratio: number;
  17777. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  17778. /**
  17779. * Creates a depth stencil texture.
  17780. * This is only available in WebGL 2 or with the depth texture extension available.
  17781. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  17782. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  17783. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  17784. */
  17785. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  17786. private _processSizeParameter;
  17787. /**
  17788. * Define the number of samples to use in case of MSAA.
  17789. * It defaults to one meaning no MSAA has been enabled.
  17790. */
  17791. samples: number;
  17792. /**
  17793. * Resets the refresh counter of the texture and start bak from scratch.
  17794. * Could be useful to regenerate the texture if it is setup to render only once.
  17795. */
  17796. resetRefreshCounter(): void;
  17797. /**
  17798. * Define the refresh rate of the texture or the rendering frequency.
  17799. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  17800. */
  17801. refreshRate: number;
  17802. /**
  17803. * Adds a post process to the render target rendering passes.
  17804. * @param postProcess define the post process to add
  17805. */
  17806. addPostProcess(postProcess: PostProcess): void;
  17807. /**
  17808. * Clear all the post processes attached to the render target
  17809. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  17810. */
  17811. clearPostProcesses(dispose?: boolean): void;
  17812. /**
  17813. * Remove one of the post process from the list of attached post processes to the texture
  17814. * @param postProcess define the post process to remove from the list
  17815. */
  17816. removePostProcess(postProcess: PostProcess): void;
  17817. /** @hidden */
  17818. _shouldRender(): boolean;
  17819. /**
  17820. * Gets the actual render size of the texture.
  17821. * @returns the width of the render size
  17822. */
  17823. getRenderSize(): number;
  17824. /**
  17825. * Gets the actual render width of the texture.
  17826. * @returns the width of the render size
  17827. */
  17828. getRenderWidth(): number;
  17829. /**
  17830. * Gets the actual render height of the texture.
  17831. * @returns the height of the render size
  17832. */
  17833. getRenderHeight(): number;
  17834. /**
  17835. * Get if the texture can be rescaled or not.
  17836. */
  17837. readonly canRescale: boolean;
  17838. /**
  17839. * Resize the texture using a ratio.
  17840. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  17841. */
  17842. scale(ratio: number): void;
  17843. /**
  17844. * Get the texture reflection matrix used to rotate/transform the reflection.
  17845. * @returns the reflection matrix
  17846. */
  17847. getReflectionTextureMatrix(): Matrix;
  17848. /**
  17849. * Resize the texture to a new desired size.
  17850. * Be carrefull as it will recreate all the data in the new texture.
  17851. * @param size Define the new size. It can be:
  17852. * - a number for squared texture,
  17853. * - an object containing { width: number, height: number }
  17854. * - or an object containing a ratio { ratio: number }
  17855. */
  17856. resize(size: number | {
  17857. width: number;
  17858. height: number;
  17859. } | {
  17860. ratio: number;
  17861. }): void;
  17862. /**
  17863. * Renders all the objects from the render list into the texture.
  17864. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  17865. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  17866. */
  17867. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  17868. private _bestReflectionRenderTargetDimension;
  17869. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  17870. private renderToTarget;
  17871. /**
  17872. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17873. * This allowed control for front to back rendering or reversly depending of the special needs.
  17874. *
  17875. * @param renderingGroupId The rendering group id corresponding to its index
  17876. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17877. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17878. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17879. */
  17880. 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;
  17881. /**
  17882. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17883. *
  17884. * @param renderingGroupId The rendering group id corresponding to its index
  17885. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17886. */
  17887. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  17888. /**
  17889. * Clones the texture.
  17890. * @returns the cloned texture
  17891. */
  17892. clone(): RenderTargetTexture;
  17893. /**
  17894. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  17895. * @returns The JSON representation of the texture
  17896. */
  17897. serialize(): any;
  17898. /**
  17899. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  17900. */
  17901. disposeFramebufferObjects(): void;
  17902. /**
  17903. * Dispose the texture and release its associated resources.
  17904. */
  17905. dispose(): void;
  17906. /** @hidden */
  17907. _rebuild(): void;
  17908. /**
  17909. * Clear the info related to rendering groups preventing retention point in material dispose.
  17910. */
  17911. freeRenderingGroups(): void;
  17912. }
  17913. }
  17914. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  17915. import { Scene } from "babylonjs/scene";
  17916. import { Plane } from "babylonjs/Maths/math";
  17917. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  17918. /**
  17919. * Mirror texture can be used to simulate the view from a mirror in a scene.
  17920. * It will dynamically be rendered every frame to adapt to the camera point of view.
  17921. * You can then easily use it as a reflectionTexture on a flat surface.
  17922. * In case the surface is not a plane, please consider relying on reflection probes.
  17923. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  17924. */
  17925. export class MirrorTexture extends RenderTargetTexture {
  17926. private scene;
  17927. /**
  17928. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  17929. * 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.
  17930. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  17931. */
  17932. mirrorPlane: Plane;
  17933. /**
  17934. * Define the blur ratio used to blur the reflection if needed.
  17935. */
  17936. blurRatio: number;
  17937. /**
  17938. * Define the adaptive blur kernel used to blur the reflection if needed.
  17939. * This will autocompute the closest best match for the `blurKernel`
  17940. */
  17941. adaptiveBlurKernel: number;
  17942. /**
  17943. * Define the blur kernel used to blur the reflection if needed.
  17944. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  17945. */
  17946. blurKernel: number;
  17947. /**
  17948. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  17949. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  17950. */
  17951. blurKernelX: number;
  17952. /**
  17953. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  17954. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  17955. */
  17956. blurKernelY: number;
  17957. private _autoComputeBlurKernel;
  17958. protected _onRatioRescale(): void;
  17959. private _updateGammaSpace;
  17960. private _imageProcessingConfigChangeObserver;
  17961. private _transformMatrix;
  17962. private _mirrorMatrix;
  17963. private _savedViewMatrix;
  17964. private _blurX;
  17965. private _blurY;
  17966. private _adaptiveBlurKernel;
  17967. private _blurKernelX;
  17968. private _blurKernelY;
  17969. private _blurRatio;
  17970. /**
  17971. * Instantiates a Mirror Texture.
  17972. * Mirror texture can be used to simulate the view from a mirror in a scene.
  17973. * It will dynamically be rendered every frame to adapt to the camera point of view.
  17974. * You can then easily use it as a reflectionTexture on a flat surface.
  17975. * In case the surface is not a plane, please consider relying on reflection probes.
  17976. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  17977. * @param name
  17978. * @param size
  17979. * @param scene
  17980. * @param generateMipMaps
  17981. * @param type
  17982. * @param samplingMode
  17983. * @param generateDepthBuffer
  17984. */
  17985. constructor(name: string, size: number | {
  17986. width: number;
  17987. height: number;
  17988. } | {
  17989. ratio: number;
  17990. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  17991. private _preparePostProcesses;
  17992. /**
  17993. * Clone the mirror texture.
  17994. * @returns the cloned texture
  17995. */
  17996. clone(): MirrorTexture;
  17997. /**
  17998. * Serialize the texture to a JSON representation you could use in Parse later on
  17999. * @returns the serialized JSON representation
  18000. */
  18001. serialize(): any;
  18002. /**
  18003. * Dispose the texture and release its associated resources.
  18004. */
  18005. dispose(): void;
  18006. }
  18007. }
  18008. declare module "babylonjs/Materials/Textures/texture" {
  18009. import { Observable } from "babylonjs/Misc/observable";
  18010. import { Nullable } from "babylonjs/types";
  18011. import { Scene } from "babylonjs/scene";
  18012. import { Matrix } from "babylonjs/Maths/math";
  18013. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  18014. /**
  18015. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  18016. * @see http://doc.babylonjs.com/babylon101/materials#texture
  18017. */
  18018. export class Texture extends BaseTexture {
  18019. /** @hidden */
  18020. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  18021. /** @hidden */
  18022. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  18023. /** @hidden */
  18024. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  18025. /** nearest is mag = nearest and min = nearest and mip = linear */
  18026. static readonly NEAREST_SAMPLINGMODE: number;
  18027. /** nearest is mag = nearest and min = nearest and mip = linear */
  18028. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  18029. /** Bilinear is mag = linear and min = linear and mip = nearest */
  18030. static readonly BILINEAR_SAMPLINGMODE: number;
  18031. /** Bilinear is mag = linear and min = linear and mip = nearest */
  18032. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  18033. /** Trilinear is mag = linear and min = linear and mip = linear */
  18034. static readonly TRILINEAR_SAMPLINGMODE: number;
  18035. /** Trilinear is mag = linear and min = linear and mip = linear */
  18036. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  18037. /** mag = nearest and min = nearest and mip = nearest */
  18038. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  18039. /** mag = nearest and min = linear and mip = nearest */
  18040. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  18041. /** mag = nearest and min = linear and mip = linear */
  18042. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  18043. /** mag = nearest and min = linear and mip = none */
  18044. static readonly NEAREST_LINEAR: number;
  18045. /** mag = nearest and min = nearest and mip = none */
  18046. static readonly NEAREST_NEAREST: number;
  18047. /** mag = linear and min = nearest and mip = nearest */
  18048. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  18049. /** mag = linear and min = nearest and mip = linear */
  18050. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  18051. /** mag = linear and min = linear and mip = none */
  18052. static readonly LINEAR_LINEAR: number;
  18053. /** mag = linear and min = nearest and mip = none */
  18054. static readonly LINEAR_NEAREST: number;
  18055. /** Explicit coordinates mode */
  18056. static readonly EXPLICIT_MODE: number;
  18057. /** Spherical coordinates mode */
  18058. static readonly SPHERICAL_MODE: number;
  18059. /** Planar coordinates mode */
  18060. static readonly PLANAR_MODE: number;
  18061. /** Cubic coordinates mode */
  18062. static readonly CUBIC_MODE: number;
  18063. /** Projection coordinates mode */
  18064. static readonly PROJECTION_MODE: number;
  18065. /** Inverse Cubic coordinates mode */
  18066. static readonly SKYBOX_MODE: number;
  18067. /** Inverse Cubic coordinates mode */
  18068. static readonly INVCUBIC_MODE: number;
  18069. /** Equirectangular coordinates mode */
  18070. static readonly EQUIRECTANGULAR_MODE: number;
  18071. /** Equirectangular Fixed coordinates mode */
  18072. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  18073. /** Equirectangular Fixed Mirrored coordinates mode */
  18074. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  18075. /** Texture is not repeating outside of 0..1 UVs */
  18076. static readonly CLAMP_ADDRESSMODE: number;
  18077. /** Texture is repeating outside of 0..1 UVs */
  18078. static readonly WRAP_ADDRESSMODE: number;
  18079. /** Texture is repeating and mirrored */
  18080. static readonly MIRROR_ADDRESSMODE: number;
  18081. /**
  18082. * 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
  18083. */
  18084. static UseSerializedUrlIfAny: boolean;
  18085. /**
  18086. * Define the url of the texture.
  18087. */
  18088. url: Nullable<string>;
  18089. /**
  18090. * Define an offset on the texture to offset the u coordinates of the UVs
  18091. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  18092. */
  18093. uOffset: number;
  18094. /**
  18095. * Define an offset on the texture to offset the v coordinates of the UVs
  18096. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  18097. */
  18098. vOffset: number;
  18099. /**
  18100. * Define an offset on the texture to scale the u coordinates of the UVs
  18101. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  18102. */
  18103. uScale: number;
  18104. /**
  18105. * Define an offset on the texture to scale the v coordinates of the UVs
  18106. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  18107. */
  18108. vScale: number;
  18109. /**
  18110. * Define an offset on the texture to rotate around the u coordinates of the UVs
  18111. * @see http://doc.babylonjs.com/how_to/more_materials
  18112. */
  18113. uAng: number;
  18114. /**
  18115. * Define an offset on the texture to rotate around the v coordinates of the UVs
  18116. * @see http://doc.babylonjs.com/how_to/more_materials
  18117. */
  18118. vAng: number;
  18119. /**
  18120. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  18121. * @see http://doc.babylonjs.com/how_to/more_materials
  18122. */
  18123. wAng: number;
  18124. /**
  18125. * Defines the center of rotation (U)
  18126. */
  18127. uRotationCenter: number;
  18128. /**
  18129. * Defines the center of rotation (V)
  18130. */
  18131. vRotationCenter: number;
  18132. /**
  18133. * Defines the center of rotation (W)
  18134. */
  18135. wRotationCenter: number;
  18136. /**
  18137. * Are mip maps generated for this texture or not.
  18138. */
  18139. readonly noMipmap: boolean;
  18140. private _noMipmap;
  18141. /** @hidden */
  18142. _invertY: boolean;
  18143. private _rowGenerationMatrix;
  18144. private _cachedTextureMatrix;
  18145. private _projectionModeMatrix;
  18146. private _t0;
  18147. private _t1;
  18148. private _t2;
  18149. private _cachedUOffset;
  18150. private _cachedVOffset;
  18151. private _cachedUScale;
  18152. private _cachedVScale;
  18153. private _cachedUAng;
  18154. private _cachedVAng;
  18155. private _cachedWAng;
  18156. private _cachedProjectionMatrixId;
  18157. private _cachedCoordinatesMode;
  18158. /** @hidden */
  18159. protected _initialSamplingMode: number;
  18160. /** @hidden */
  18161. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  18162. private _deleteBuffer;
  18163. protected _format: Nullable<number>;
  18164. private _delayedOnLoad;
  18165. private _delayedOnError;
  18166. /**
  18167. * Observable triggered once the texture has been loaded.
  18168. */
  18169. onLoadObservable: Observable<Texture>;
  18170. protected _isBlocking: boolean;
  18171. /**
  18172. * Is the texture preventing material to render while loading.
  18173. * If false, a default texture will be used instead of the loading one during the preparation step.
  18174. */
  18175. isBlocking: boolean;
  18176. /**
  18177. * Get the current sampling mode associated with the texture.
  18178. */
  18179. readonly samplingMode: number;
  18180. /**
  18181. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  18182. */
  18183. readonly invertY: boolean;
  18184. /**
  18185. * Instantiates a new texture.
  18186. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  18187. * @see http://doc.babylonjs.com/babylon101/materials#texture
  18188. * @param url define the url of the picture to load as a texture
  18189. * @param scene define the scene the texture will belong to
  18190. * @param noMipmap define if the texture will require mip maps or not
  18191. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18192. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18193. * @param onLoad define a callback triggered when the texture has been loaded
  18194. * @param onError define a callback triggered when an error occurred during the loading session
  18195. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  18196. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  18197. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18198. */
  18199. 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);
  18200. /**
  18201. * Update the url (and optional buffer) of this texture if url was null during construction.
  18202. * @param url the url of the texture
  18203. * @param buffer the buffer of the texture (defaults to null)
  18204. * @param onLoad callback called when the texture is loaded (defaults to null)
  18205. */
  18206. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  18207. /**
  18208. * Finish the loading sequence of a texture flagged as delayed load.
  18209. * @hidden
  18210. */
  18211. delayLoad(): void;
  18212. private _prepareRowForTextureGeneration;
  18213. /**
  18214. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  18215. * @returns the transform matrix of the texture.
  18216. */
  18217. getTextureMatrix(): Matrix;
  18218. /**
  18219. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  18220. * @returns The reflection texture transform
  18221. */
  18222. getReflectionTextureMatrix(): Matrix;
  18223. /**
  18224. * Clones the texture.
  18225. * @returns the cloned texture
  18226. */
  18227. clone(): Texture;
  18228. /**
  18229. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  18230. * @returns The JSON representation of the texture
  18231. */
  18232. serialize(): any;
  18233. /**
  18234. * Get the current class name of the texture useful for serialization or dynamic coding.
  18235. * @returns "Texture"
  18236. */
  18237. getClassName(): string;
  18238. /**
  18239. * Dispose the texture and release its associated resources.
  18240. */
  18241. dispose(): void;
  18242. /**
  18243. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  18244. * @param parsedTexture Define the JSON representation of the texture
  18245. * @param scene Define the scene the parsed texture should be instantiated in
  18246. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  18247. * @returns The parsed texture if successful
  18248. */
  18249. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  18250. /**
  18251. * Creates a texture from its base 64 representation.
  18252. * @param data Define the base64 payload without the data: prefix
  18253. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  18254. * @param scene Define the scene the texture should belong to
  18255. * @param noMipmap Forces the texture to not create mip map information if true
  18256. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18257. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18258. * @param onLoad define a callback triggered when the texture has been loaded
  18259. * @param onError define a callback triggered when an error occurred during the loading session
  18260. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18261. * @returns the created texture
  18262. */
  18263. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  18264. /**
  18265. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  18266. * @param data Define the base64 payload without the data: prefix
  18267. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  18268. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  18269. * @param scene Define the scene the texture should belong to
  18270. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  18271. * @param noMipmap Forces the texture to not create mip map information if true
  18272. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18273. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18274. * @param onLoad define a callback triggered when the texture has been loaded
  18275. * @param onError define a callback triggered when an error occurred during the loading session
  18276. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18277. * @returns the created texture
  18278. */
  18279. 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;
  18280. }
  18281. }
  18282. declare module "babylonjs/Materials/Textures/rawTexture" {
  18283. import { Scene } from "babylonjs/scene";
  18284. import { Texture } from "babylonjs/Materials/Textures/texture";
  18285. /**
  18286. * Raw texture can help creating a texture directly from an array of data.
  18287. * This can be super useful if you either get the data from an uncompressed source or
  18288. * if you wish to create your texture pixel by pixel.
  18289. */
  18290. export class RawTexture extends Texture {
  18291. /**
  18292. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18293. */
  18294. format: number;
  18295. private _engine;
  18296. /**
  18297. * Instantiates a new RawTexture.
  18298. * Raw texture can help creating a texture directly from an array of data.
  18299. * This can be super useful if you either get the data from an uncompressed source or
  18300. * if you wish to create your texture pixel by pixel.
  18301. * @param data define the array of data to use to create the texture
  18302. * @param width define the width of the texture
  18303. * @param height define the height of the texture
  18304. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18305. * @param scene define the scene the texture belongs to
  18306. * @param generateMipMaps define whether mip maps should be generated or not
  18307. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18308. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18309. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18310. */
  18311. constructor(data: ArrayBufferView, width: number, height: number,
  18312. /**
  18313. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18314. */
  18315. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  18316. /**
  18317. * Updates the texture underlying data.
  18318. * @param data Define the new data of the texture
  18319. */
  18320. update(data: ArrayBufferView): void;
  18321. /**
  18322. * Creates a luminance texture from some data.
  18323. * @param data Define the texture data
  18324. * @param width Define the width of the texture
  18325. * @param height Define the height of the texture
  18326. * @param scene Define the scene the texture belongs to
  18327. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18328. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18329. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18330. * @returns the luminance texture
  18331. */
  18332. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  18333. /**
  18334. * Creates a luminance alpha texture from some data.
  18335. * @param data Define the texture data
  18336. * @param width Define the width of the texture
  18337. * @param height Define the height of the texture
  18338. * @param scene Define the scene the texture belongs to
  18339. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18340. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18341. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18342. * @returns the luminance alpha texture
  18343. */
  18344. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  18345. /**
  18346. * Creates an alpha texture from some data.
  18347. * @param data Define the texture data
  18348. * @param width Define the width of the texture
  18349. * @param height Define the height of the texture
  18350. * @param scene Define the scene the texture belongs to
  18351. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18352. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18353. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18354. * @returns the alpha texture
  18355. */
  18356. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  18357. /**
  18358. * Creates a RGB texture from some data.
  18359. * @param data Define the texture data
  18360. * @param width Define the width of the texture
  18361. * @param height Define the height of the texture
  18362. * @param scene Define the scene the texture belongs to
  18363. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18364. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18365. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18366. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18367. * @returns the RGB alpha texture
  18368. */
  18369. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  18370. /**
  18371. * Creates a RGBA texture from some data.
  18372. * @param data Define the texture data
  18373. * @param width Define the width of the texture
  18374. * @param height Define the height of the texture
  18375. * @param scene Define the scene the texture belongs to
  18376. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18377. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18378. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18379. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18380. * @returns the RGBA texture
  18381. */
  18382. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  18383. /**
  18384. * Creates a R texture from some data.
  18385. * @param data Define the texture data
  18386. * @param width Define the width of the texture
  18387. * @param height Define the height of the texture
  18388. * @param scene Define the scene the texture belongs to
  18389. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18390. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18391. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18392. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18393. * @returns the R texture
  18394. */
  18395. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  18396. }
  18397. }
  18398. declare module "babylonjs/Animations/runtimeAnimation" {
  18399. import { Animation } from "babylonjs/Animations/animation";
  18400. import { Animatable } from "babylonjs/Animations/animatable";
  18401. import { Scene } from "babylonjs/scene";
  18402. /**
  18403. * Defines a runtime animation
  18404. */
  18405. export class RuntimeAnimation {
  18406. private _events;
  18407. /**
  18408. * The current frame of the runtime animation
  18409. */
  18410. private _currentFrame;
  18411. /**
  18412. * The animation used by the runtime animation
  18413. */
  18414. private _animation;
  18415. /**
  18416. * The target of the runtime animation
  18417. */
  18418. private _target;
  18419. /**
  18420. * The initiating animatable
  18421. */
  18422. private _host;
  18423. /**
  18424. * The original value of the runtime animation
  18425. */
  18426. private _originalValue;
  18427. /**
  18428. * The original blend value of the runtime animation
  18429. */
  18430. private _originalBlendValue;
  18431. /**
  18432. * The offsets cache of the runtime animation
  18433. */
  18434. private _offsetsCache;
  18435. /**
  18436. * The high limits cache of the runtime animation
  18437. */
  18438. private _highLimitsCache;
  18439. /**
  18440. * Specifies if the runtime animation has been stopped
  18441. */
  18442. private _stopped;
  18443. /**
  18444. * The blending factor of the runtime animation
  18445. */
  18446. private _blendingFactor;
  18447. /**
  18448. * The BabylonJS scene
  18449. */
  18450. private _scene;
  18451. /**
  18452. * The current value of the runtime animation
  18453. */
  18454. private _currentValue;
  18455. /** @hidden */
  18456. _workValue: any;
  18457. /**
  18458. * The active target of the runtime animation
  18459. */
  18460. private _activeTarget;
  18461. /**
  18462. * The target path of the runtime animation
  18463. */
  18464. private _targetPath;
  18465. /**
  18466. * The weight of the runtime animation
  18467. */
  18468. private _weight;
  18469. /**
  18470. * The ratio offset of the runtime animation
  18471. */
  18472. private _ratioOffset;
  18473. /**
  18474. * The previous delay of the runtime animation
  18475. */
  18476. private _previousDelay;
  18477. /**
  18478. * The previous ratio of the runtime animation
  18479. */
  18480. private _previousRatio;
  18481. /**
  18482. * Gets the current frame of the runtime animation
  18483. */
  18484. readonly currentFrame: number;
  18485. /**
  18486. * Gets the weight of the runtime animation
  18487. */
  18488. readonly weight: number;
  18489. /**
  18490. * Gets the current value of the runtime animation
  18491. */
  18492. readonly currentValue: any;
  18493. /**
  18494. * Gets the target path of the runtime animation
  18495. */
  18496. readonly targetPath: string;
  18497. /**
  18498. * Gets the actual target of the runtime animation
  18499. */
  18500. readonly target: any;
  18501. /**
  18502. * Create a new RuntimeAnimation object
  18503. * @param target defines the target of the animation
  18504. * @param animation defines the source animation object
  18505. * @param scene defines the hosting scene
  18506. * @param host defines the initiating Animatable
  18507. */
  18508. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  18509. /**
  18510. * Gets the animation from the runtime animation
  18511. */
  18512. readonly animation: Animation;
  18513. /**
  18514. * Resets the runtime animation to the beginning
  18515. * @param restoreOriginal defines whether to restore the target property to the original value
  18516. */
  18517. reset(restoreOriginal?: boolean): void;
  18518. /**
  18519. * Specifies if the runtime animation is stopped
  18520. * @returns Boolean specifying if the runtime animation is stopped
  18521. */
  18522. isStopped(): boolean;
  18523. /**
  18524. * Disposes of the runtime animation
  18525. */
  18526. dispose(): void;
  18527. /**
  18528. * Interpolates the animation from the current frame
  18529. * @param currentFrame The frame to interpolate the animation to
  18530. * @param repeatCount The number of times that the animation should loop
  18531. * @param loopMode The type of looping mode to use
  18532. * @param offsetValue Animation offset value
  18533. * @param highLimitValue The high limit value
  18534. * @returns The interpolated value
  18535. */
  18536. private _interpolate;
  18537. /**
  18538. * Apply the interpolated value to the target
  18539. * @param currentValue defines the value computed by the animation
  18540. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  18541. */
  18542. setValue(currentValue: any, weight?: number): void;
  18543. private _setValue;
  18544. /**
  18545. * Gets the loop pmode of the runtime animation
  18546. * @returns Loop Mode
  18547. */
  18548. private _getCorrectLoopMode;
  18549. /**
  18550. * Move the current animation to a given frame
  18551. * @param frame defines the frame to move to
  18552. */
  18553. goToFrame(frame: number): void;
  18554. /**
  18555. * @hidden Internal use only
  18556. */
  18557. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  18558. /**
  18559. * Execute the current animation
  18560. * @param delay defines the delay to add to the current frame
  18561. * @param from defines the lower bound of the animation range
  18562. * @param to defines the upper bound of the animation range
  18563. * @param loop defines if the current animation must loop
  18564. * @param speedRatio defines the current speed ratio
  18565. * @param weight defines the weight of the animation (default is -1 so no weight)
  18566. * @param onLoop optional callback called when animation loops
  18567. * @returns a boolean indicating if the animation is running
  18568. */
  18569. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number, onLoop?: () => void): boolean;
  18570. }
  18571. }
  18572. declare module "babylonjs/Animations/animatable" {
  18573. import { Animation } from "babylonjs/Animations/animation";
  18574. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  18575. import { Nullable } from "babylonjs/types";
  18576. import { Observable } from "babylonjs/Misc/observable";
  18577. import { Scene } from "babylonjs/scene";
  18578. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math";
  18579. import { Node } from "babylonjs/node";
  18580. /**
  18581. * Class used to store an actual running animation
  18582. */
  18583. export class Animatable {
  18584. /** defines the target object */
  18585. target: any;
  18586. /** defines the starting frame number (default is 0) */
  18587. fromFrame: number;
  18588. /** defines the ending frame number (default is 100) */
  18589. toFrame: number;
  18590. /** defines if the animation must loop (default is false) */
  18591. loopAnimation: boolean;
  18592. /** defines a callback to call when animation ends if it is not looping */
  18593. onAnimationEnd?: (() => void) | null | undefined;
  18594. /** defines a callback to call when animation loops */
  18595. onAnimationLoop?: (() => void) | null | undefined;
  18596. private _localDelayOffset;
  18597. private _pausedDelay;
  18598. private _runtimeAnimations;
  18599. private _paused;
  18600. private _scene;
  18601. private _speedRatio;
  18602. private _weight;
  18603. private _syncRoot;
  18604. /**
  18605. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  18606. * This will only apply for non looping animation (default is true)
  18607. */
  18608. disposeOnEnd: boolean;
  18609. /**
  18610. * Gets a boolean indicating if the animation has started
  18611. */
  18612. animationStarted: boolean;
  18613. /**
  18614. * Observer raised when the animation ends
  18615. */
  18616. onAnimationEndObservable: Observable<Animatable>;
  18617. /**
  18618. * Observer raised when the animation loops
  18619. */
  18620. onAnimationLoopObservable: Observable<Animatable>;
  18621. /**
  18622. * Gets the root Animatable used to synchronize and normalize animations
  18623. */
  18624. readonly syncRoot: Animatable;
  18625. /**
  18626. * Gets the current frame of the first RuntimeAnimation
  18627. * Used to synchronize Animatables
  18628. */
  18629. readonly masterFrame: number;
  18630. /**
  18631. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  18632. */
  18633. weight: number;
  18634. /**
  18635. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  18636. */
  18637. speedRatio: number;
  18638. /**
  18639. * Creates a new Animatable
  18640. * @param scene defines the hosting scene
  18641. * @param target defines the target object
  18642. * @param fromFrame defines the starting frame number (default is 0)
  18643. * @param toFrame defines the ending frame number (default is 100)
  18644. * @param loopAnimation defines if the animation must loop (default is false)
  18645. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  18646. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  18647. * @param animations defines a group of animation to add to the new Animatable
  18648. * @param onAnimationLoop defines a callback to call when animation loops
  18649. */
  18650. constructor(scene: Scene,
  18651. /** defines the target object */
  18652. target: any,
  18653. /** defines the starting frame number (default is 0) */
  18654. fromFrame?: number,
  18655. /** defines the ending frame number (default is 100) */
  18656. toFrame?: number,
  18657. /** defines if the animation must loop (default is false) */
  18658. loopAnimation?: boolean, speedRatio?: number,
  18659. /** defines a callback to call when animation ends if it is not looping */
  18660. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  18661. /** defines a callback to call when animation loops */
  18662. onAnimationLoop?: (() => void) | null | undefined);
  18663. /**
  18664. * Synchronize and normalize current Animatable with a source Animatable
  18665. * This is useful when using animation weights and when animations are not of the same length
  18666. * @param root defines the root Animatable to synchronize with
  18667. * @returns the current Animatable
  18668. */
  18669. syncWith(root: Animatable): Animatable;
  18670. /**
  18671. * Gets the list of runtime animations
  18672. * @returns an array of RuntimeAnimation
  18673. */
  18674. getAnimations(): RuntimeAnimation[];
  18675. /**
  18676. * Adds more animations to the current animatable
  18677. * @param target defines the target of the animations
  18678. * @param animations defines the new animations to add
  18679. */
  18680. appendAnimations(target: any, animations: Animation[]): void;
  18681. /**
  18682. * Gets the source animation for a specific property
  18683. * @param property defines the propertyu to look for
  18684. * @returns null or the source animation for the given property
  18685. */
  18686. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  18687. /**
  18688. * Gets the runtime animation for a specific property
  18689. * @param property defines the propertyu to look for
  18690. * @returns null or the runtime animation for the given property
  18691. */
  18692. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  18693. /**
  18694. * Resets the animatable to its original state
  18695. */
  18696. reset(): void;
  18697. /**
  18698. * Allows the animatable to blend with current running animations
  18699. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  18700. * @param blendingSpeed defines the blending speed to use
  18701. */
  18702. enableBlending(blendingSpeed: number): void;
  18703. /**
  18704. * Disable animation blending
  18705. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  18706. */
  18707. disableBlending(): void;
  18708. /**
  18709. * Jump directly to a given frame
  18710. * @param frame defines the frame to jump to
  18711. */
  18712. goToFrame(frame: number): void;
  18713. /**
  18714. * Pause the animation
  18715. */
  18716. pause(): void;
  18717. /**
  18718. * Restart the animation
  18719. */
  18720. restart(): void;
  18721. private _raiseOnAnimationEnd;
  18722. /**
  18723. * Stop and delete the current animation
  18724. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  18725. * @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)
  18726. */
  18727. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  18728. /**
  18729. * Wait asynchronously for the animation to end
  18730. * @returns a promise which will be fullfilled when the animation ends
  18731. */
  18732. waitAsync(): Promise<Animatable>;
  18733. /** @hidden */
  18734. _animate(delay: number): boolean;
  18735. }
  18736. module "babylonjs/scene" {
  18737. interface Scene {
  18738. /** @hidden */
  18739. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  18740. /** @hidden */
  18741. _processLateAnimationBindingsForMatrices(holder: {
  18742. totalWeight: number;
  18743. animations: RuntimeAnimation[];
  18744. originalValue: Matrix;
  18745. }): any;
  18746. /** @hidden */
  18747. _processLateAnimationBindingsForQuaternions(holder: {
  18748. totalWeight: number;
  18749. animations: RuntimeAnimation[];
  18750. originalValue: Quaternion;
  18751. }, refQuaternion: Quaternion): Quaternion;
  18752. /** @hidden */
  18753. _processLateAnimationBindings(): void;
  18754. /**
  18755. * Will start the animation sequence of a given target
  18756. * @param target defines the target
  18757. * @param from defines from which frame should animation start
  18758. * @param to defines until which frame should animation run.
  18759. * @param weight defines the weight to apply to the animation (1.0 by default)
  18760. * @param loop defines if the animation loops
  18761. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  18762. * @param onAnimationEnd defines the function to be executed when the animation ends
  18763. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  18764. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  18765. * @param onAnimationLoop defines the callback to call when an animation loops
  18766. * @returns the animatable object created for this animation
  18767. */
  18768. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  18769. /**
  18770. * Will start the animation sequence of a given target
  18771. * @param target defines the target
  18772. * @param from defines from which frame should animation start
  18773. * @param to defines until which frame should animation run.
  18774. * @param loop defines if the animation loops
  18775. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  18776. * @param onAnimationEnd defines the function to be executed when the animation ends
  18777. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  18778. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  18779. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  18780. * @param onAnimationLoop defines the callback to call when an animation loops
  18781. * @returns the animatable object created for this animation
  18782. */
  18783. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  18784. /**
  18785. * Will start the animation sequence of a given target and its hierarchy
  18786. * @param target defines the target
  18787. * @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.
  18788. * @param from defines from which frame should animation start
  18789. * @param to defines until which frame should animation run.
  18790. * @param loop defines if the animation loops
  18791. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  18792. * @param onAnimationEnd defines the function to be executed when the animation ends
  18793. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  18794. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  18795. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  18796. * @param onAnimationLoop defines the callback to call when an animation loops
  18797. * @returns the list of created animatables
  18798. */
  18799. 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[];
  18800. /**
  18801. * Begin a new animation on a given node
  18802. * @param target defines the target where the animation will take place
  18803. * @param animations defines the list of animations to start
  18804. * @param from defines the initial value
  18805. * @param to defines the final value
  18806. * @param loop defines if you want animation to loop (off by default)
  18807. * @param speedRatio defines the speed ratio to apply to all animations
  18808. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  18809. * @param onAnimationLoop defines the callback to call when an animation loops
  18810. * @returns the list of created animatables
  18811. */
  18812. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  18813. /**
  18814. * Begin a new animation on a given node and its hierarchy
  18815. * @param target defines the root node where the animation will take place
  18816. * @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.
  18817. * @param animations defines the list of animations to start
  18818. * @param from defines the initial value
  18819. * @param to defines the final value
  18820. * @param loop defines if you want animation to loop (off by default)
  18821. * @param speedRatio defines the speed ratio to apply to all animations
  18822. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  18823. * @param onAnimationLoop defines the callback to call when an animation loops
  18824. * @returns the list of animatables created for all nodes
  18825. */
  18826. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  18827. /**
  18828. * Gets the animatable associated with a specific target
  18829. * @param target defines the target of the animatable
  18830. * @returns the required animatable if found
  18831. */
  18832. getAnimatableByTarget(target: any): Nullable<Animatable>;
  18833. /**
  18834. * Gets all animatables associated with a given target
  18835. * @param target defines the target to look animatables for
  18836. * @returns an array of Animatables
  18837. */
  18838. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  18839. /**
  18840. * Will stop the animation of the given target
  18841. * @param target - the target
  18842. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  18843. * @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)
  18844. */
  18845. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  18846. /**
  18847. * Stops and removes all animations that have been applied to the scene
  18848. */
  18849. stopAllAnimations(): void;
  18850. }
  18851. }
  18852. module "babylonjs/Bones/bone" {
  18853. interface Bone {
  18854. /**
  18855. * Copy an animation range from another bone
  18856. * @param source defines the source bone
  18857. * @param rangeName defines the range name to copy
  18858. * @param frameOffset defines the frame offset
  18859. * @param rescaleAsRequired defines if rescaling must be applied if required
  18860. * @param skelDimensionsRatio defines the scaling ratio
  18861. * @returns true if operation was successful
  18862. */
  18863. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  18864. }
  18865. }
  18866. }
  18867. declare module "babylonjs/Bones/skeleton" {
  18868. import { Bone } from "babylonjs/Bones/bone";
  18869. import { IAnimatable } from "babylonjs/Misc/tools";
  18870. import { Observable } from "babylonjs/Misc/observable";
  18871. import { Vector3, Matrix } from "babylonjs/Maths/math";
  18872. import { Scene } from "babylonjs/scene";
  18873. import { Nullable } from "babylonjs/types";
  18874. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18875. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  18876. import { Animatable } from "babylonjs/Animations/animatable";
  18877. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  18878. import { Animation } from "babylonjs/Animations/animation";
  18879. import { AnimationRange } from "babylonjs/Animations/animationRange";
  18880. /**
  18881. * Class used to handle skinning animations
  18882. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  18883. */
  18884. export class Skeleton implements IAnimatable {
  18885. /** defines the skeleton name */
  18886. name: string;
  18887. /** defines the skeleton Id */
  18888. id: string;
  18889. /**
  18890. * Defines the list of child bones
  18891. */
  18892. bones: Bone[];
  18893. /**
  18894. * Defines an estimate of the dimension of the skeleton at rest
  18895. */
  18896. dimensionsAtRest: Vector3;
  18897. /**
  18898. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  18899. */
  18900. needInitialSkinMatrix: boolean;
  18901. /**
  18902. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  18903. */
  18904. overrideMesh: Nullable<AbstractMesh>;
  18905. /**
  18906. * Gets the list of animations attached to this skeleton
  18907. */
  18908. animations: Array<Animation>;
  18909. private _scene;
  18910. private _isDirty;
  18911. private _transformMatrices;
  18912. private _transformMatrixTexture;
  18913. private _meshesWithPoseMatrix;
  18914. private _animatables;
  18915. private _identity;
  18916. private _synchronizedWithMesh;
  18917. private _ranges;
  18918. private _lastAbsoluteTransformsUpdateId;
  18919. private _canUseTextureForBones;
  18920. /** @hidden */
  18921. _numBonesWithLinkedTransformNode: number;
  18922. /**
  18923. * Specifies if the skeleton should be serialized
  18924. */
  18925. doNotSerialize: boolean;
  18926. /**
  18927. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  18928. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  18929. */
  18930. useTextureToStoreBoneMatrices: boolean;
  18931. private _animationPropertiesOverride;
  18932. /**
  18933. * Gets or sets the animation properties override
  18934. */
  18935. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  18936. /**
  18937. * An observable triggered before computing the skeleton's matrices
  18938. */
  18939. onBeforeComputeObservable: Observable<Skeleton>;
  18940. /**
  18941. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  18942. */
  18943. readonly isUsingTextureForMatrices: boolean;
  18944. /**
  18945. * Creates a new skeleton
  18946. * @param name defines the skeleton name
  18947. * @param id defines the skeleton Id
  18948. * @param scene defines the hosting scene
  18949. */
  18950. constructor(
  18951. /** defines the skeleton name */
  18952. name: string,
  18953. /** defines the skeleton Id */
  18954. id: string, scene: Scene);
  18955. /**
  18956. * Gets the current object class name.
  18957. * @return the class name
  18958. */
  18959. getClassName(): string;
  18960. /**
  18961. * Returns an array containing the root bones
  18962. * @returns an array containing the root bones
  18963. */
  18964. getChildren(): Array<Bone>;
  18965. /**
  18966. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  18967. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  18968. * @returns a Float32Array containing matrices data
  18969. */
  18970. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  18971. /**
  18972. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  18973. * @returns a raw texture containing the data
  18974. */
  18975. getTransformMatrixTexture(): Nullable<RawTexture>;
  18976. /**
  18977. * Gets the current hosting scene
  18978. * @returns a scene object
  18979. */
  18980. getScene(): Scene;
  18981. /**
  18982. * Gets a string representing the current skeleton data
  18983. * @param fullDetails defines a boolean indicating if we want a verbose version
  18984. * @returns a string representing the current skeleton data
  18985. */
  18986. toString(fullDetails?: boolean): string;
  18987. /**
  18988. * Get bone's index searching by name
  18989. * @param name defines bone's name to search for
  18990. * @return the indice of the bone. Returns -1 if not found
  18991. */
  18992. getBoneIndexByName(name: string): number;
  18993. /**
  18994. * Creater a new animation range
  18995. * @param name defines the name of the range
  18996. * @param from defines the start key
  18997. * @param to defines the end key
  18998. */
  18999. createAnimationRange(name: string, from: number, to: number): void;
  19000. /**
  19001. * Delete a specific animation range
  19002. * @param name defines the name of the range
  19003. * @param deleteFrames defines if frames must be removed as well
  19004. */
  19005. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  19006. /**
  19007. * Gets a specific animation range
  19008. * @param name defines the name of the range to look for
  19009. * @returns the requested animation range or null if not found
  19010. */
  19011. getAnimationRange(name: string): Nullable<AnimationRange>;
  19012. /**
  19013. * Gets the list of all animation ranges defined on this skeleton
  19014. * @returns an array
  19015. */
  19016. getAnimationRanges(): Nullable<AnimationRange>[];
  19017. /**
  19018. * Copy animation range from a source skeleton.
  19019. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  19020. * @param source defines the source skeleton
  19021. * @param name defines the name of the range to copy
  19022. * @param rescaleAsRequired defines if rescaling must be applied if required
  19023. * @returns true if operation was successful
  19024. */
  19025. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  19026. /**
  19027. * Forces the skeleton to go to rest pose
  19028. */
  19029. returnToRest(): void;
  19030. private _getHighestAnimationFrame;
  19031. /**
  19032. * Begin a specific animation range
  19033. * @param name defines the name of the range to start
  19034. * @param loop defines if looping must be turned on (false by default)
  19035. * @param speedRatio defines the speed ratio to apply (1 by default)
  19036. * @param onAnimationEnd defines a callback which will be called when animation will end
  19037. * @returns a new animatable
  19038. */
  19039. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  19040. /** @hidden */
  19041. _markAsDirty(): void;
  19042. /** @hidden */
  19043. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  19044. /** @hidden */
  19045. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  19046. private _computeTransformMatrices;
  19047. /**
  19048. * Build all resources required to render a skeleton
  19049. */
  19050. prepare(): void;
  19051. /**
  19052. * Gets the list of animatables currently running for this skeleton
  19053. * @returns an array of animatables
  19054. */
  19055. getAnimatables(): IAnimatable[];
  19056. /**
  19057. * Clone the current skeleton
  19058. * @param name defines the name of the new skeleton
  19059. * @param id defines the id of the enw skeleton
  19060. * @returns the new skeleton
  19061. */
  19062. clone(name: string, id: string): Skeleton;
  19063. /**
  19064. * Enable animation blending for this skeleton
  19065. * @param blendingSpeed defines the blending speed to apply
  19066. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  19067. */
  19068. enableBlending(blendingSpeed?: number): void;
  19069. /**
  19070. * Releases all resources associated with the current skeleton
  19071. */
  19072. dispose(): void;
  19073. /**
  19074. * Serialize the skeleton in a JSON object
  19075. * @returns a JSON object
  19076. */
  19077. serialize(): any;
  19078. /**
  19079. * Creates a new skeleton from serialized data
  19080. * @param parsedSkeleton defines the serialized data
  19081. * @param scene defines the hosting scene
  19082. * @returns a new skeleton
  19083. */
  19084. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  19085. /**
  19086. * Compute all node absolute transforms
  19087. * @param forceUpdate defines if computation must be done even if cache is up to date
  19088. */
  19089. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  19090. /**
  19091. * Gets the root pose matrix
  19092. * @returns a matrix
  19093. */
  19094. getPoseMatrix(): Nullable<Matrix>;
  19095. /**
  19096. * Sorts bones per internal index
  19097. */
  19098. sortBones(): void;
  19099. private _sortBones;
  19100. }
  19101. }
  19102. declare module "babylonjs/Morph/morphTarget" {
  19103. import { IAnimatable } from "babylonjs/Misc/tools";
  19104. import { Observable } from "babylonjs/Misc/observable";
  19105. import { Nullable, FloatArray } from "babylonjs/types";
  19106. import { Scene } from "babylonjs/scene";
  19107. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19108. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  19109. /**
  19110. * Defines a target to use with MorphTargetManager
  19111. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  19112. */
  19113. export class MorphTarget implements IAnimatable {
  19114. /** defines the name of the target */
  19115. name: string;
  19116. /**
  19117. * Gets or sets the list of animations
  19118. */
  19119. animations: import("babylonjs/Animations/animation").Animation[];
  19120. private _scene;
  19121. private _positions;
  19122. private _normals;
  19123. private _tangents;
  19124. private _influence;
  19125. /**
  19126. * Observable raised when the influence changes
  19127. */
  19128. onInfluenceChanged: Observable<boolean>;
  19129. /** @hidden */
  19130. _onDataLayoutChanged: Observable<void>;
  19131. /**
  19132. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  19133. */
  19134. influence: number;
  19135. /**
  19136. * Gets or sets the id of the morph Target
  19137. */
  19138. id: string;
  19139. private _animationPropertiesOverride;
  19140. /**
  19141. * Gets or sets the animation properties override
  19142. */
  19143. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  19144. /**
  19145. * Creates a new MorphTarget
  19146. * @param name defines the name of the target
  19147. * @param influence defines the influence to use
  19148. * @param scene defines the scene the morphtarget belongs to
  19149. */
  19150. constructor(
  19151. /** defines the name of the target */
  19152. name: string, influence?: number, scene?: Nullable<Scene>);
  19153. /**
  19154. * Gets a boolean defining if the target contains position data
  19155. */
  19156. readonly hasPositions: boolean;
  19157. /**
  19158. * Gets a boolean defining if the target contains normal data
  19159. */
  19160. readonly hasNormals: boolean;
  19161. /**
  19162. * Gets a boolean defining if the target contains tangent data
  19163. */
  19164. readonly hasTangents: boolean;
  19165. /**
  19166. * Affects position data to this target
  19167. * @param data defines the position data to use
  19168. */
  19169. setPositions(data: Nullable<FloatArray>): void;
  19170. /**
  19171. * Gets the position data stored in this target
  19172. * @returns a FloatArray containing the position data (or null if not present)
  19173. */
  19174. getPositions(): Nullable<FloatArray>;
  19175. /**
  19176. * Affects normal data to this target
  19177. * @param data defines the normal data to use
  19178. */
  19179. setNormals(data: Nullable<FloatArray>): void;
  19180. /**
  19181. * Gets the normal data stored in this target
  19182. * @returns a FloatArray containing the normal data (or null if not present)
  19183. */
  19184. getNormals(): Nullable<FloatArray>;
  19185. /**
  19186. * Affects tangent data to this target
  19187. * @param data defines the tangent data to use
  19188. */
  19189. setTangents(data: Nullable<FloatArray>): void;
  19190. /**
  19191. * Gets the tangent data stored in this target
  19192. * @returns a FloatArray containing the tangent data (or null if not present)
  19193. */
  19194. getTangents(): Nullable<FloatArray>;
  19195. /**
  19196. * Serializes the current target into a Serialization object
  19197. * @returns the serialized object
  19198. */
  19199. serialize(): any;
  19200. /**
  19201. * Returns the string "MorphTarget"
  19202. * @returns "MorphTarget"
  19203. */
  19204. getClassName(): string;
  19205. /**
  19206. * Creates a new target from serialized data
  19207. * @param serializationObject defines the serialized data to use
  19208. * @returns a new MorphTarget
  19209. */
  19210. static Parse(serializationObject: any): MorphTarget;
  19211. /**
  19212. * Creates a MorphTarget from mesh data
  19213. * @param mesh defines the source mesh
  19214. * @param name defines the name to use for the new target
  19215. * @param influence defines the influence to attach to the target
  19216. * @returns a new MorphTarget
  19217. */
  19218. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  19219. }
  19220. }
  19221. declare module "babylonjs/Morph/morphTargetManager" {
  19222. import { Nullable } from "babylonjs/types";
  19223. import { Scene } from "babylonjs/scene";
  19224. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  19225. /**
  19226. * This class is used to deform meshes using morphing between different targets
  19227. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  19228. */
  19229. export class MorphTargetManager {
  19230. private _targets;
  19231. private _targetInfluenceChangedObservers;
  19232. private _targetDataLayoutChangedObservers;
  19233. private _activeTargets;
  19234. private _scene;
  19235. private _influences;
  19236. private _supportsNormals;
  19237. private _supportsTangents;
  19238. private _vertexCount;
  19239. private _uniqueId;
  19240. private _tempInfluences;
  19241. /**
  19242. * Creates a new MorphTargetManager
  19243. * @param scene defines the current scene
  19244. */
  19245. constructor(scene?: Nullable<Scene>);
  19246. /**
  19247. * Gets the unique ID of this manager
  19248. */
  19249. readonly uniqueId: number;
  19250. /**
  19251. * Gets the number of vertices handled by this manager
  19252. */
  19253. readonly vertexCount: number;
  19254. /**
  19255. * Gets a boolean indicating if this manager supports morphing of normals
  19256. */
  19257. readonly supportsNormals: boolean;
  19258. /**
  19259. * Gets a boolean indicating if this manager supports morphing of tangents
  19260. */
  19261. readonly supportsTangents: boolean;
  19262. /**
  19263. * Gets the number of targets stored in this manager
  19264. */
  19265. readonly numTargets: number;
  19266. /**
  19267. * Gets the number of influencers (ie. the number of targets with influences > 0)
  19268. */
  19269. readonly numInfluencers: number;
  19270. /**
  19271. * Gets the list of influences (one per target)
  19272. */
  19273. readonly influences: Float32Array;
  19274. /**
  19275. * Gets the active target at specified index. An active target is a target with an influence > 0
  19276. * @param index defines the index to check
  19277. * @returns the requested target
  19278. */
  19279. getActiveTarget(index: number): MorphTarget;
  19280. /**
  19281. * Gets the target at specified index
  19282. * @param index defines the index to check
  19283. * @returns the requested target
  19284. */
  19285. getTarget(index: number): MorphTarget;
  19286. /**
  19287. * Add a new target to this manager
  19288. * @param target defines the target to add
  19289. */
  19290. addTarget(target: MorphTarget): void;
  19291. /**
  19292. * Removes a target from the manager
  19293. * @param target defines the target to remove
  19294. */
  19295. removeTarget(target: MorphTarget): void;
  19296. /**
  19297. * Serializes the current manager into a Serialization object
  19298. * @returns the serialized object
  19299. */
  19300. serialize(): any;
  19301. private _syncActiveTargets;
  19302. /**
  19303. * Syncrhonize the targets with all the meshes using this morph target manager
  19304. */
  19305. synchronize(): void;
  19306. /**
  19307. * Creates a new MorphTargetManager from serialized data
  19308. * @param serializationObject defines the serialized data
  19309. * @param scene defines the hosting scene
  19310. * @returns the new MorphTargetManager
  19311. */
  19312. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  19313. }
  19314. }
  19315. declare module "babylonjs/Meshes/groundMesh" {
  19316. import { Scene } from "babylonjs/scene";
  19317. import { Vector3 } from "babylonjs/Maths/math";
  19318. import { Mesh } from "babylonjs/Meshes/mesh";
  19319. /**
  19320. * Mesh representing the gorund
  19321. */
  19322. export class GroundMesh extends Mesh {
  19323. /** If octree should be generated */
  19324. generateOctree: boolean;
  19325. private _heightQuads;
  19326. /** @hidden */
  19327. _subdivisionsX: number;
  19328. /** @hidden */
  19329. _subdivisionsY: number;
  19330. /** @hidden */
  19331. _width: number;
  19332. /** @hidden */
  19333. _height: number;
  19334. /** @hidden */
  19335. _minX: number;
  19336. /** @hidden */
  19337. _maxX: number;
  19338. /** @hidden */
  19339. _minZ: number;
  19340. /** @hidden */
  19341. _maxZ: number;
  19342. constructor(name: string, scene: Scene);
  19343. /**
  19344. * "GroundMesh"
  19345. * @returns "GroundMesh"
  19346. */
  19347. getClassName(): string;
  19348. /**
  19349. * The minimum of x and y subdivisions
  19350. */
  19351. readonly subdivisions: number;
  19352. /**
  19353. * X subdivisions
  19354. */
  19355. readonly subdivisionsX: number;
  19356. /**
  19357. * Y subdivisions
  19358. */
  19359. readonly subdivisionsY: number;
  19360. /**
  19361. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  19362. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  19363. * @param chunksCount the number of subdivisions for x and y
  19364. * @param octreeBlocksSize (Default: 32)
  19365. */
  19366. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  19367. /**
  19368. * Returns a height (y) value in the Worl system :
  19369. * the ground altitude at the coordinates (x, z) expressed in the World system.
  19370. * @param x x coordinate
  19371. * @param z z coordinate
  19372. * @returns the ground y position if (x, z) are outside the ground surface.
  19373. */
  19374. getHeightAtCoordinates(x: number, z: number): number;
  19375. /**
  19376. * Returns a normalized vector (Vector3) orthogonal to the ground
  19377. * at the ground coordinates (x, z) expressed in the World system.
  19378. * @param x x coordinate
  19379. * @param z z coordinate
  19380. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  19381. */
  19382. getNormalAtCoordinates(x: number, z: number): Vector3;
  19383. /**
  19384. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  19385. * at the ground coordinates (x, z) expressed in the World system.
  19386. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  19387. * @param x x coordinate
  19388. * @param z z coordinate
  19389. * @param ref vector to store the result
  19390. * @returns the GroundMesh.
  19391. */
  19392. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  19393. /**
  19394. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  19395. * if the ground has been updated.
  19396. * This can be used in the render loop.
  19397. * @returns the GroundMesh.
  19398. */
  19399. updateCoordinateHeights(): GroundMesh;
  19400. private _getFacetAt;
  19401. private _initHeightQuads;
  19402. private _computeHeightQuads;
  19403. /**
  19404. * Serializes this ground mesh
  19405. * @param serializationObject object to write serialization to
  19406. */
  19407. serialize(serializationObject: any): void;
  19408. /**
  19409. * Parses a serialized ground mesh
  19410. * @param parsedMesh the serialized mesh
  19411. * @param scene the scene to create the ground mesh in
  19412. * @returns the created ground mesh
  19413. */
  19414. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  19415. }
  19416. }
  19417. declare module "babylonjs/Physics/physicsJoint" {
  19418. import { Vector3 } from "babylonjs/Maths/math";
  19419. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  19420. /**
  19421. * Interface for Physics-Joint data
  19422. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19423. */
  19424. export interface PhysicsJointData {
  19425. /**
  19426. * The main pivot of the joint
  19427. */
  19428. mainPivot?: Vector3;
  19429. /**
  19430. * The connected pivot of the joint
  19431. */
  19432. connectedPivot?: Vector3;
  19433. /**
  19434. * The main axis of the joint
  19435. */
  19436. mainAxis?: Vector3;
  19437. /**
  19438. * The connected axis of the joint
  19439. */
  19440. connectedAxis?: Vector3;
  19441. /**
  19442. * The collision of the joint
  19443. */
  19444. collision?: boolean;
  19445. /**
  19446. * Native Oimo/Cannon/Energy data
  19447. */
  19448. nativeParams?: any;
  19449. }
  19450. /**
  19451. * This is a holder class for the physics joint created by the physics plugin
  19452. * It holds a set of functions to control the underlying joint
  19453. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19454. */
  19455. export class PhysicsJoint {
  19456. /**
  19457. * The type of the physics joint
  19458. */
  19459. type: number;
  19460. /**
  19461. * The data for the physics joint
  19462. */
  19463. jointData: PhysicsJointData;
  19464. private _physicsJoint;
  19465. protected _physicsPlugin: IPhysicsEnginePlugin;
  19466. /**
  19467. * Initializes the physics joint
  19468. * @param type The type of the physics joint
  19469. * @param jointData The data for the physics joint
  19470. */
  19471. constructor(
  19472. /**
  19473. * The type of the physics joint
  19474. */
  19475. type: number,
  19476. /**
  19477. * The data for the physics joint
  19478. */
  19479. jointData: PhysicsJointData);
  19480. /**
  19481. * Gets the physics joint
  19482. */
  19483. /**
  19484. * Sets the physics joint
  19485. */
  19486. physicsJoint: any;
  19487. /**
  19488. * Sets the physics plugin
  19489. */
  19490. physicsPlugin: IPhysicsEnginePlugin;
  19491. /**
  19492. * Execute a function that is physics-plugin specific.
  19493. * @param {Function} func the function that will be executed.
  19494. * It accepts two parameters: the physics world and the physics joint
  19495. */
  19496. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  19497. /**
  19498. * Distance-Joint type
  19499. */
  19500. static DistanceJoint: number;
  19501. /**
  19502. * Hinge-Joint type
  19503. */
  19504. static HingeJoint: number;
  19505. /**
  19506. * Ball-and-Socket joint type
  19507. */
  19508. static BallAndSocketJoint: number;
  19509. /**
  19510. * Wheel-Joint type
  19511. */
  19512. static WheelJoint: number;
  19513. /**
  19514. * Slider-Joint type
  19515. */
  19516. static SliderJoint: number;
  19517. /**
  19518. * Prismatic-Joint type
  19519. */
  19520. static PrismaticJoint: number;
  19521. /**
  19522. * Universal-Joint type
  19523. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  19524. */
  19525. static UniversalJoint: number;
  19526. /**
  19527. * Hinge-Joint 2 type
  19528. */
  19529. static Hinge2Joint: number;
  19530. /**
  19531. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  19532. */
  19533. static PointToPointJoint: number;
  19534. /**
  19535. * Spring-Joint type
  19536. */
  19537. static SpringJoint: number;
  19538. /**
  19539. * Lock-Joint type
  19540. */
  19541. static LockJoint: number;
  19542. }
  19543. /**
  19544. * A class representing a physics distance joint
  19545. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19546. */
  19547. export class DistanceJoint extends PhysicsJoint {
  19548. /**
  19549. *
  19550. * @param jointData The data for the Distance-Joint
  19551. */
  19552. constructor(jointData: DistanceJointData);
  19553. /**
  19554. * Update the predefined distance.
  19555. * @param maxDistance The maximum preferred distance
  19556. * @param minDistance The minimum preferred distance
  19557. */
  19558. updateDistance(maxDistance: number, minDistance?: number): void;
  19559. }
  19560. /**
  19561. * Represents a Motor-Enabled Joint
  19562. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19563. */
  19564. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  19565. /**
  19566. * Initializes the Motor-Enabled Joint
  19567. * @param type The type of the joint
  19568. * @param jointData The physica joint data for the joint
  19569. */
  19570. constructor(type: number, jointData: PhysicsJointData);
  19571. /**
  19572. * Set the motor values.
  19573. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19574. * @param force the force to apply
  19575. * @param maxForce max force for this motor.
  19576. */
  19577. setMotor(force?: number, maxForce?: number): void;
  19578. /**
  19579. * Set the motor's limits.
  19580. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19581. * @param upperLimit The upper limit of the motor
  19582. * @param lowerLimit The lower limit of the motor
  19583. */
  19584. setLimit(upperLimit: number, lowerLimit?: number): void;
  19585. }
  19586. /**
  19587. * This class represents a single physics Hinge-Joint
  19588. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19589. */
  19590. export class HingeJoint extends MotorEnabledJoint {
  19591. /**
  19592. * Initializes the Hinge-Joint
  19593. * @param jointData The joint data for the Hinge-Joint
  19594. */
  19595. constructor(jointData: PhysicsJointData);
  19596. /**
  19597. * Set the motor values.
  19598. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19599. * @param {number} force the force to apply
  19600. * @param {number} maxForce max force for this motor.
  19601. */
  19602. setMotor(force?: number, maxForce?: number): void;
  19603. /**
  19604. * Set the motor's limits.
  19605. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19606. * @param upperLimit The upper limit of the motor
  19607. * @param lowerLimit The lower limit of the motor
  19608. */
  19609. setLimit(upperLimit: number, lowerLimit?: number): void;
  19610. }
  19611. /**
  19612. * This class represents a dual hinge physics joint (same as wheel joint)
  19613. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19614. */
  19615. export class Hinge2Joint extends MotorEnabledJoint {
  19616. /**
  19617. * Initializes the Hinge2-Joint
  19618. * @param jointData The joint data for the Hinge2-Joint
  19619. */
  19620. constructor(jointData: PhysicsJointData);
  19621. /**
  19622. * Set the motor values.
  19623. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19624. * @param {number} targetSpeed the speed the motor is to reach
  19625. * @param {number} maxForce max force for this motor.
  19626. * @param {motorIndex} the motor's index, 0 or 1.
  19627. */
  19628. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  19629. /**
  19630. * Set the motor limits.
  19631. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19632. * @param {number} upperLimit the upper limit
  19633. * @param {number} lowerLimit lower limit
  19634. * @param {motorIndex} the motor's index, 0 or 1.
  19635. */
  19636. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  19637. }
  19638. /**
  19639. * Interface for a motor enabled joint
  19640. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19641. */
  19642. export interface IMotorEnabledJoint {
  19643. /**
  19644. * Physics joint
  19645. */
  19646. physicsJoint: any;
  19647. /**
  19648. * Sets the motor of the motor-enabled joint
  19649. * @param force The force of the motor
  19650. * @param maxForce The maximum force of the motor
  19651. * @param motorIndex The index of the motor
  19652. */
  19653. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  19654. /**
  19655. * Sets the limit of the motor
  19656. * @param upperLimit The upper limit of the motor
  19657. * @param lowerLimit The lower limit of the motor
  19658. * @param motorIndex The index of the motor
  19659. */
  19660. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  19661. }
  19662. /**
  19663. * Joint data for a Distance-Joint
  19664. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19665. */
  19666. export interface DistanceJointData extends PhysicsJointData {
  19667. /**
  19668. * Max distance the 2 joint objects can be apart
  19669. */
  19670. maxDistance: number;
  19671. }
  19672. /**
  19673. * Joint data from a spring joint
  19674. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19675. */
  19676. export interface SpringJointData extends PhysicsJointData {
  19677. /**
  19678. * Length of the spring
  19679. */
  19680. length: number;
  19681. /**
  19682. * Stiffness of the spring
  19683. */
  19684. stiffness: number;
  19685. /**
  19686. * Damping of the spring
  19687. */
  19688. damping: number;
  19689. /** this callback will be called when applying the force to the impostors. */
  19690. forceApplicationCallback: () => void;
  19691. }
  19692. }
  19693. declare module "babylonjs/Physics/IPhysicsEngine" {
  19694. import { Nullable } from "babylonjs/types";
  19695. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  19696. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19697. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  19698. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  19699. /**
  19700. * Interface used to describe a physics joint
  19701. */
  19702. export interface PhysicsImpostorJoint {
  19703. /** Defines the main impostor to which the joint is linked */
  19704. mainImpostor: PhysicsImpostor;
  19705. /** Defines the impostor that is connected to the main impostor using this joint */
  19706. connectedImpostor: PhysicsImpostor;
  19707. /** Defines the joint itself */
  19708. joint: PhysicsJoint;
  19709. }
  19710. /** @hidden */
  19711. export interface IPhysicsEnginePlugin {
  19712. world: any;
  19713. name: string;
  19714. setGravity(gravity: Vector3): void;
  19715. setTimeStep(timeStep: number): void;
  19716. getTimeStep(): number;
  19717. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  19718. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  19719. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  19720. generatePhysicsBody(impostor: PhysicsImpostor): void;
  19721. removePhysicsBody(impostor: PhysicsImpostor): void;
  19722. generateJoint(joint: PhysicsImpostorJoint): void;
  19723. removeJoint(joint: PhysicsImpostorJoint): void;
  19724. isSupported(): boolean;
  19725. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  19726. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  19727. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  19728. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  19729. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  19730. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  19731. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  19732. getBodyMass(impostor: PhysicsImpostor): number;
  19733. getBodyFriction(impostor: PhysicsImpostor): number;
  19734. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  19735. getBodyRestitution(impostor: PhysicsImpostor): number;
  19736. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  19737. sleepBody(impostor: PhysicsImpostor): void;
  19738. wakeUpBody(impostor: PhysicsImpostor): void;
  19739. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  19740. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  19741. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  19742. getRadius(impostor: PhysicsImpostor): number;
  19743. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  19744. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  19745. dispose(): void;
  19746. }
  19747. /**
  19748. * Interface used to define a physics engine
  19749. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  19750. */
  19751. export interface IPhysicsEngine {
  19752. /**
  19753. * Gets the gravity vector used by the simulation
  19754. */
  19755. gravity: Vector3;
  19756. /**
  19757. * Sets the gravity vector used by the simulation
  19758. * @param gravity defines the gravity vector to use
  19759. */
  19760. setGravity(gravity: Vector3): void;
  19761. /**
  19762. * Set the time step of the physics engine.
  19763. * Default is 1/60.
  19764. * To slow it down, enter 1/600 for example.
  19765. * To speed it up, 1/30
  19766. * @param newTimeStep the new timestep to apply to this world.
  19767. */
  19768. setTimeStep(newTimeStep: number): void;
  19769. /**
  19770. * Get the time step of the physics engine.
  19771. * @returns the current time step
  19772. */
  19773. getTimeStep(): number;
  19774. /**
  19775. * Release all resources
  19776. */
  19777. dispose(): void;
  19778. /**
  19779. * Gets the name of the current physics plugin
  19780. * @returns the name of the plugin
  19781. */
  19782. getPhysicsPluginName(): string;
  19783. /**
  19784. * Adding a new impostor for the impostor tracking.
  19785. * This will be done by the impostor itself.
  19786. * @param impostor the impostor to add
  19787. */
  19788. addImpostor(impostor: PhysicsImpostor): void;
  19789. /**
  19790. * Remove an impostor from the engine.
  19791. * This impostor and its mesh will not longer be updated by the physics engine.
  19792. * @param impostor the impostor to remove
  19793. */
  19794. removeImpostor(impostor: PhysicsImpostor): void;
  19795. /**
  19796. * Add a joint to the physics engine
  19797. * @param mainImpostor defines the main impostor to which the joint is added.
  19798. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  19799. * @param joint defines the joint that will connect both impostors.
  19800. */
  19801. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  19802. /**
  19803. * Removes a joint from the simulation
  19804. * @param mainImpostor defines the impostor used with the joint
  19805. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  19806. * @param joint defines the joint to remove
  19807. */
  19808. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  19809. /**
  19810. * Gets the current plugin used to run the simulation
  19811. * @returns current plugin
  19812. */
  19813. getPhysicsPlugin(): IPhysicsEnginePlugin;
  19814. /**
  19815. * Gets the list of physic impostors
  19816. * @returns an array of PhysicsImpostor
  19817. */
  19818. getImpostors(): Array<PhysicsImpostor>;
  19819. /**
  19820. * Gets the impostor for a physics enabled object
  19821. * @param object defines the object impersonated by the impostor
  19822. * @returns the PhysicsImpostor or null if not found
  19823. */
  19824. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  19825. /**
  19826. * Gets the impostor for a physics body object
  19827. * @param body defines physics body used by the impostor
  19828. * @returns the PhysicsImpostor or null if not found
  19829. */
  19830. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  19831. /**
  19832. * Called by the scene. No need to call it.
  19833. * @param delta defines the timespam between frames
  19834. */
  19835. _step(delta: number): void;
  19836. }
  19837. }
  19838. declare module "babylonjs/Physics/physicsImpostor" {
  19839. import { Nullable, IndicesArray } from "babylonjs/types";
  19840. import { Vector3, Matrix, Quaternion, Space } from "babylonjs/Maths/math";
  19841. import { TransformNode } from "babylonjs/Meshes/transformNode";
  19842. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19843. import { Scene } from "babylonjs/scene";
  19844. import { Bone } from "babylonjs/Bones/bone";
  19845. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  19846. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  19847. /**
  19848. * The interface for the physics imposter parameters
  19849. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19850. */
  19851. export interface PhysicsImpostorParameters {
  19852. /**
  19853. * The mass of the physics imposter
  19854. */
  19855. mass: number;
  19856. /**
  19857. * The friction of the physics imposter
  19858. */
  19859. friction?: number;
  19860. /**
  19861. * The coefficient of restitution of the physics imposter
  19862. */
  19863. restitution?: number;
  19864. /**
  19865. * The native options of the physics imposter
  19866. */
  19867. nativeOptions?: any;
  19868. /**
  19869. * Specifies if the parent should be ignored
  19870. */
  19871. ignoreParent?: boolean;
  19872. /**
  19873. * Specifies if bi-directional transformations should be disabled
  19874. */
  19875. disableBidirectionalTransformation?: boolean;
  19876. }
  19877. /**
  19878. * Interface for a physics-enabled object
  19879. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19880. */
  19881. export interface IPhysicsEnabledObject {
  19882. /**
  19883. * The position of the physics-enabled object
  19884. */
  19885. position: Vector3;
  19886. /**
  19887. * The rotation of the physics-enabled object
  19888. */
  19889. rotationQuaternion: Nullable<Quaternion>;
  19890. /**
  19891. * The scale of the physics-enabled object
  19892. */
  19893. scaling: Vector3;
  19894. /**
  19895. * The rotation of the physics-enabled object
  19896. */
  19897. rotation?: Vector3;
  19898. /**
  19899. * The parent of the physics-enabled object
  19900. */
  19901. parent?: any;
  19902. /**
  19903. * The bounding info of the physics-enabled object
  19904. * @returns The bounding info of the physics-enabled object
  19905. */
  19906. getBoundingInfo(): BoundingInfo;
  19907. /**
  19908. * Computes the world matrix
  19909. * @param force Specifies if the world matrix should be computed by force
  19910. * @returns A world matrix
  19911. */
  19912. computeWorldMatrix(force: boolean): Matrix;
  19913. /**
  19914. * Gets the world matrix
  19915. * @returns A world matrix
  19916. */
  19917. getWorldMatrix?(): Matrix;
  19918. /**
  19919. * Gets the child meshes
  19920. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  19921. * @returns An array of abstract meshes
  19922. */
  19923. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  19924. /**
  19925. * Gets the vertex data
  19926. * @param kind The type of vertex data
  19927. * @returns A nullable array of numbers, or a float32 array
  19928. */
  19929. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  19930. /**
  19931. * Gets the indices from the mesh
  19932. * @returns A nullable array of index arrays
  19933. */
  19934. getIndices?(): Nullable<IndicesArray>;
  19935. /**
  19936. * Gets the scene from the mesh
  19937. * @returns the indices array or null
  19938. */
  19939. getScene?(): Scene;
  19940. /**
  19941. * Gets the absolute position from the mesh
  19942. * @returns the absolute position
  19943. */
  19944. getAbsolutePosition(): Vector3;
  19945. /**
  19946. * Gets the absolute pivot point from the mesh
  19947. * @returns the absolute pivot point
  19948. */
  19949. getAbsolutePivotPoint(): Vector3;
  19950. /**
  19951. * Rotates the mesh
  19952. * @param axis The axis of rotation
  19953. * @param amount The amount of rotation
  19954. * @param space The space of the rotation
  19955. * @returns The rotation transform node
  19956. */
  19957. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  19958. /**
  19959. * Translates the mesh
  19960. * @param axis The axis of translation
  19961. * @param distance The distance of translation
  19962. * @param space The space of the translation
  19963. * @returns The transform node
  19964. */
  19965. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  19966. /**
  19967. * Sets the absolute position of the mesh
  19968. * @param absolutePosition The absolute position of the mesh
  19969. * @returns The transform node
  19970. */
  19971. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  19972. /**
  19973. * Gets the class name of the mesh
  19974. * @returns The class name
  19975. */
  19976. getClassName(): string;
  19977. }
  19978. /**
  19979. * Represents a physics imposter
  19980. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19981. */
  19982. export class PhysicsImpostor {
  19983. /**
  19984. * The physics-enabled object used as the physics imposter
  19985. */
  19986. object: IPhysicsEnabledObject;
  19987. /**
  19988. * The type of the physics imposter
  19989. */
  19990. type: number;
  19991. private _options;
  19992. private _scene?;
  19993. /**
  19994. * The default object size of the imposter
  19995. */
  19996. static DEFAULT_OBJECT_SIZE: Vector3;
  19997. /**
  19998. * The identity quaternion of the imposter
  19999. */
  20000. static IDENTITY_QUATERNION: Quaternion;
  20001. /** @hidden */
  20002. _pluginData: any;
  20003. private _physicsEngine;
  20004. private _physicsBody;
  20005. private _bodyUpdateRequired;
  20006. private _onBeforePhysicsStepCallbacks;
  20007. private _onAfterPhysicsStepCallbacks;
  20008. /** @hidden */
  20009. _onPhysicsCollideCallbacks: Array<{
  20010. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  20011. otherImpostors: Array<PhysicsImpostor>;
  20012. }>;
  20013. private _deltaPosition;
  20014. private _deltaRotation;
  20015. private _deltaRotationConjugated;
  20016. private _parent;
  20017. private _isDisposed;
  20018. private static _tmpVecs;
  20019. private static _tmpQuat;
  20020. /**
  20021. * Specifies if the physics imposter is disposed
  20022. */
  20023. readonly isDisposed: boolean;
  20024. /**
  20025. * Gets the mass of the physics imposter
  20026. */
  20027. mass: number;
  20028. /**
  20029. * Gets the coefficient of friction
  20030. */
  20031. /**
  20032. * Sets the coefficient of friction
  20033. */
  20034. friction: number;
  20035. /**
  20036. * Gets the coefficient of restitution
  20037. */
  20038. /**
  20039. * Sets the coefficient of restitution
  20040. */
  20041. restitution: number;
  20042. /**
  20043. * The unique id of the physics imposter
  20044. * set by the physics engine when adding this impostor to the array
  20045. */
  20046. uniqueId: number;
  20047. private _joints;
  20048. /**
  20049. * Initializes the physics imposter
  20050. * @param object The physics-enabled object used as the physics imposter
  20051. * @param type The type of the physics imposter
  20052. * @param _options The options for the physics imposter
  20053. * @param _scene The Babylon scene
  20054. */
  20055. constructor(
  20056. /**
  20057. * The physics-enabled object used as the physics imposter
  20058. */
  20059. object: IPhysicsEnabledObject,
  20060. /**
  20061. * The type of the physics imposter
  20062. */
  20063. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  20064. /**
  20065. * This function will completly initialize this impostor.
  20066. * It will create a new body - but only if this mesh has no parent.
  20067. * If it has, this impostor will not be used other than to define the impostor
  20068. * of the child mesh.
  20069. * @hidden
  20070. */
  20071. _init(): void;
  20072. private _getPhysicsParent;
  20073. /**
  20074. * Should a new body be generated.
  20075. * @returns boolean specifying if body initialization is required
  20076. */
  20077. isBodyInitRequired(): boolean;
  20078. /**
  20079. * Sets the updated scaling
  20080. * @param updated Specifies if the scaling is updated
  20081. */
  20082. setScalingUpdated(): void;
  20083. /**
  20084. * Force a regeneration of this or the parent's impostor's body.
  20085. * Use under cautious - This will remove all joints already implemented.
  20086. */
  20087. forceUpdate(): void;
  20088. /**
  20089. * Gets the body that holds this impostor. Either its own, or its parent.
  20090. */
  20091. /**
  20092. * Set the physics body. Used mainly by the physics engine/plugin
  20093. */
  20094. physicsBody: any;
  20095. /**
  20096. * Get the parent of the physics imposter
  20097. * @returns Physics imposter or null
  20098. */
  20099. /**
  20100. * Sets the parent of the physics imposter
  20101. */
  20102. parent: Nullable<PhysicsImpostor>;
  20103. /**
  20104. * Resets the update flags
  20105. */
  20106. resetUpdateFlags(): void;
  20107. /**
  20108. * Gets the object extend size
  20109. * @returns the object extend size
  20110. */
  20111. getObjectExtendSize(): Vector3;
  20112. /**
  20113. * Gets the object center
  20114. * @returns The object center
  20115. */
  20116. getObjectCenter(): Vector3;
  20117. /**
  20118. * Get a specific parametes from the options parameter
  20119. * @param paramName The object parameter name
  20120. * @returns The object parameter
  20121. */
  20122. getParam(paramName: string): any;
  20123. /**
  20124. * Sets a specific parameter in the options given to the physics plugin
  20125. * @param paramName The parameter name
  20126. * @param value The value of the parameter
  20127. */
  20128. setParam(paramName: string, value: number): void;
  20129. /**
  20130. * Specifically change the body's mass option. Won't recreate the physics body object
  20131. * @param mass The mass of the physics imposter
  20132. */
  20133. setMass(mass: number): void;
  20134. /**
  20135. * Gets the linear velocity
  20136. * @returns linear velocity or null
  20137. */
  20138. getLinearVelocity(): Nullable<Vector3>;
  20139. /**
  20140. * Sets the linear velocity
  20141. * @param velocity linear velocity or null
  20142. */
  20143. setLinearVelocity(velocity: Nullable<Vector3>): void;
  20144. /**
  20145. * Gets the angular velocity
  20146. * @returns angular velocity or null
  20147. */
  20148. getAngularVelocity(): Nullable<Vector3>;
  20149. /**
  20150. * Sets the angular velocity
  20151. * @param velocity The velocity or null
  20152. */
  20153. setAngularVelocity(velocity: Nullable<Vector3>): void;
  20154. /**
  20155. * Execute a function with the physics plugin native code
  20156. * Provide a function the will have two variables - the world object and the physics body object
  20157. * @param func The function to execute with the physics plugin native code
  20158. */
  20159. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  20160. /**
  20161. * Register a function that will be executed before the physics world is stepping forward
  20162. * @param func The function to execute before the physics world is stepped forward
  20163. */
  20164. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20165. /**
  20166. * Unregister a function that will be executed before the physics world is stepping forward
  20167. * @param func The function to execute before the physics world is stepped forward
  20168. */
  20169. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20170. /**
  20171. * Register a function that will be executed after the physics step
  20172. * @param func The function to execute after physics step
  20173. */
  20174. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20175. /**
  20176. * Unregisters a function that will be executed after the physics step
  20177. * @param func The function to execute after physics step
  20178. */
  20179. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20180. /**
  20181. * register a function that will be executed when this impostor collides against a different body
  20182. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  20183. * @param func Callback that is executed on collision
  20184. */
  20185. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  20186. /**
  20187. * Unregisters the physics imposter on contact
  20188. * @param collideAgainst The physics object to collide against
  20189. * @param func Callback to execute on collision
  20190. */
  20191. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  20192. private _tmpQuat;
  20193. private _tmpQuat2;
  20194. /**
  20195. * Get the parent rotation
  20196. * @returns The parent rotation
  20197. */
  20198. getParentsRotation(): Quaternion;
  20199. /**
  20200. * this function is executed by the physics engine.
  20201. */
  20202. beforeStep: () => void;
  20203. /**
  20204. * this function is executed by the physics engine
  20205. */
  20206. afterStep: () => void;
  20207. /**
  20208. * Legacy collision detection event support
  20209. */
  20210. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  20211. /**
  20212. * event and body object due to cannon's event-based architecture.
  20213. */
  20214. onCollide: (e: {
  20215. body: any;
  20216. }) => void;
  20217. /**
  20218. * Apply a force
  20219. * @param force The force to apply
  20220. * @param contactPoint The contact point for the force
  20221. * @returns The physics imposter
  20222. */
  20223. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  20224. /**
  20225. * Apply an impulse
  20226. * @param force The impulse force
  20227. * @param contactPoint The contact point for the impulse force
  20228. * @returns The physics imposter
  20229. */
  20230. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  20231. /**
  20232. * A help function to create a joint
  20233. * @param otherImpostor A physics imposter used to create a joint
  20234. * @param jointType The type of joint
  20235. * @param jointData The data for the joint
  20236. * @returns The physics imposter
  20237. */
  20238. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  20239. /**
  20240. * Add a joint to this impostor with a different impostor
  20241. * @param otherImpostor A physics imposter used to add a joint
  20242. * @param joint The joint to add
  20243. * @returns The physics imposter
  20244. */
  20245. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  20246. /**
  20247. * Will keep this body still, in a sleep mode.
  20248. * @returns the physics imposter
  20249. */
  20250. sleep(): PhysicsImpostor;
  20251. /**
  20252. * Wake the body up.
  20253. * @returns The physics imposter
  20254. */
  20255. wakeUp(): PhysicsImpostor;
  20256. /**
  20257. * Clones the physics imposter
  20258. * @param newObject The physics imposter clones to this physics-enabled object
  20259. * @returns A nullable physics imposter
  20260. */
  20261. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  20262. /**
  20263. * Disposes the physics imposter
  20264. */
  20265. dispose(): void;
  20266. /**
  20267. * Sets the delta position
  20268. * @param position The delta position amount
  20269. */
  20270. setDeltaPosition(position: Vector3): void;
  20271. /**
  20272. * Sets the delta rotation
  20273. * @param rotation The delta rotation amount
  20274. */
  20275. setDeltaRotation(rotation: Quaternion): void;
  20276. /**
  20277. * Gets the box size of the physics imposter and stores the result in the input parameter
  20278. * @param result Stores the box size
  20279. * @returns The physics imposter
  20280. */
  20281. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  20282. /**
  20283. * Gets the radius of the physics imposter
  20284. * @returns Radius of the physics imposter
  20285. */
  20286. getRadius(): number;
  20287. /**
  20288. * Sync a bone with this impostor
  20289. * @param bone The bone to sync to the impostor.
  20290. * @param boneMesh The mesh that the bone is influencing.
  20291. * @param jointPivot The pivot of the joint / bone in local space.
  20292. * @param distToJoint Optional distance from the impostor to the joint.
  20293. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  20294. */
  20295. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  20296. /**
  20297. * Sync impostor to a bone
  20298. * @param bone The bone that the impostor will be synced to.
  20299. * @param boneMesh The mesh that the bone is influencing.
  20300. * @param jointPivot The pivot of the joint / bone in local space.
  20301. * @param distToJoint Optional distance from the impostor to the joint.
  20302. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  20303. * @param boneAxis Optional vector3 axis the bone is aligned with
  20304. */
  20305. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  20306. /**
  20307. * No-Imposter type
  20308. */
  20309. static NoImpostor: number;
  20310. /**
  20311. * Sphere-Imposter type
  20312. */
  20313. static SphereImpostor: number;
  20314. /**
  20315. * Box-Imposter type
  20316. */
  20317. static BoxImpostor: number;
  20318. /**
  20319. * Plane-Imposter type
  20320. */
  20321. static PlaneImpostor: number;
  20322. /**
  20323. * Mesh-imposter type
  20324. */
  20325. static MeshImpostor: number;
  20326. /**
  20327. * Cylinder-Imposter type
  20328. */
  20329. static CylinderImpostor: number;
  20330. /**
  20331. * Particle-Imposter type
  20332. */
  20333. static ParticleImpostor: number;
  20334. /**
  20335. * Heightmap-Imposter type
  20336. */
  20337. static HeightmapImpostor: number;
  20338. }
  20339. }
  20340. declare module "babylonjs/Meshes/mesh" {
  20341. import { Observable } from "babylonjs/Misc/observable";
  20342. import { IAnimatable } from "babylonjs/Misc/tools";
  20343. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  20344. import { Camera } from "babylonjs/Cameras/camera";
  20345. import { Scene } from "babylonjs/scene";
  20346. import { Matrix, Vector3, Vector2, Color4, Plane, Vector4, Path3D } from "babylonjs/Maths/math";
  20347. import { Engine } from "babylonjs/Engines/engine";
  20348. import { Node } from "babylonjs/node";
  20349. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  20350. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  20351. import { Buffer } from "babylonjs/Meshes/buffer";
  20352. import { Geometry } from "babylonjs/Meshes/geometry";
  20353. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20354. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20355. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  20356. import { Effect } from "babylonjs/Materials/effect";
  20357. import { Material } from "babylonjs/Materials/material";
  20358. import { Skeleton } from "babylonjs/Bones/skeleton";
  20359. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  20360. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  20361. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  20362. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  20363. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  20364. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  20365. /**
  20366. * Class used to represent a specific level of detail of a mesh
  20367. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  20368. */
  20369. export class MeshLODLevel {
  20370. /** Defines the distance where this level should star being displayed */
  20371. distance: number;
  20372. /** Defines the mesh to use to render this level */
  20373. mesh: Nullable<Mesh>;
  20374. /**
  20375. * Creates a new LOD level
  20376. * @param distance defines the distance where this level should star being displayed
  20377. * @param mesh defines the mesh to use to render this level
  20378. */
  20379. constructor(
  20380. /** Defines the distance where this level should star being displayed */
  20381. distance: number,
  20382. /** Defines the mesh to use to render this level */
  20383. mesh: Nullable<Mesh>);
  20384. }
  20385. /**
  20386. * @hidden
  20387. **/
  20388. export class _CreationDataStorage {
  20389. closePath?: boolean;
  20390. closeArray?: boolean;
  20391. idx: number[];
  20392. dashSize: number;
  20393. gapSize: number;
  20394. path3D: Path3D;
  20395. pathArray: Vector3[][];
  20396. arc: number;
  20397. radius: number;
  20398. cap: number;
  20399. tessellation: number;
  20400. }
  20401. /**
  20402. * @hidden
  20403. **/
  20404. class _InstanceDataStorage {
  20405. visibleInstances: any;
  20406. renderIdForInstances: number[];
  20407. batchCache: _InstancesBatch;
  20408. instancesBufferSize: number;
  20409. instancesBuffer: Nullable<Buffer>;
  20410. instancesData: Float32Array;
  20411. overridenInstanceCount: number;
  20412. }
  20413. /**
  20414. * @hidden
  20415. **/
  20416. export class _InstancesBatch {
  20417. mustReturn: boolean;
  20418. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  20419. renderSelf: boolean[];
  20420. }
  20421. /**
  20422. * Class used to represent renderable models
  20423. */
  20424. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  20425. /**
  20426. * Mesh side orientation : usually the external or front surface
  20427. */
  20428. static readonly FRONTSIDE: number;
  20429. /**
  20430. * Mesh side orientation : usually the internal or back surface
  20431. */
  20432. static readonly BACKSIDE: number;
  20433. /**
  20434. * Mesh side orientation : both internal and external or front and back surfaces
  20435. */
  20436. static readonly DOUBLESIDE: number;
  20437. /**
  20438. * Mesh side orientation : by default, `FRONTSIDE`
  20439. */
  20440. static readonly DEFAULTSIDE: number;
  20441. /**
  20442. * Mesh cap setting : no cap
  20443. */
  20444. static readonly NO_CAP: number;
  20445. /**
  20446. * Mesh cap setting : one cap at the beginning of the mesh
  20447. */
  20448. static readonly CAP_START: number;
  20449. /**
  20450. * Mesh cap setting : one cap at the end of the mesh
  20451. */
  20452. static readonly CAP_END: number;
  20453. /**
  20454. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  20455. */
  20456. static readonly CAP_ALL: number;
  20457. /**
  20458. * Gets the default side orientation.
  20459. * @param orientation the orientation to value to attempt to get
  20460. * @returns the default orientation
  20461. * @hidden
  20462. */
  20463. static _GetDefaultSideOrientation(orientation?: number): number;
  20464. private _onBeforeRenderObservable;
  20465. private _onBeforeBindObservable;
  20466. private _onAfterRenderObservable;
  20467. private _onBeforeDrawObservable;
  20468. /**
  20469. * An event triggered before rendering the mesh
  20470. */
  20471. readonly onBeforeRenderObservable: Observable<Mesh>;
  20472. /**
  20473. * An event triggered before binding the mesh
  20474. */
  20475. readonly onBeforeBindObservable: Observable<Mesh>;
  20476. /**
  20477. * An event triggered after rendering the mesh
  20478. */
  20479. readonly onAfterRenderObservable: Observable<Mesh>;
  20480. /**
  20481. * An event triggered before drawing the mesh
  20482. */
  20483. readonly onBeforeDrawObservable: Observable<Mesh>;
  20484. private _onBeforeDrawObserver;
  20485. /**
  20486. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  20487. */
  20488. onBeforeDraw: () => void;
  20489. /**
  20490. * Gets the delay loading state of the mesh (when delay loading is turned on)
  20491. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  20492. */
  20493. delayLoadState: number;
  20494. /**
  20495. * Gets the list of instances created from this mesh
  20496. * it is not supposed to be modified manually.
  20497. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  20498. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  20499. */
  20500. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  20501. /**
  20502. * Gets the file containing delay loading data for this mesh
  20503. */
  20504. delayLoadingFile: string;
  20505. /** @hidden */
  20506. _binaryInfo: any;
  20507. private _LODLevels;
  20508. /**
  20509. * User defined function used to change how LOD level selection is done
  20510. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  20511. */
  20512. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  20513. private _morphTargetManager;
  20514. /**
  20515. * Gets or sets the morph target manager
  20516. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  20517. */
  20518. morphTargetManager: Nullable<MorphTargetManager>;
  20519. /** @hidden */
  20520. _creationDataStorage: Nullable<_CreationDataStorage>;
  20521. /** @hidden */
  20522. _geometry: Nullable<Geometry>;
  20523. /** @hidden */
  20524. _delayInfo: Array<string>;
  20525. /** @hidden */
  20526. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  20527. /** @hidden */
  20528. _instanceDataStorage: _InstanceDataStorage;
  20529. private _effectiveMaterial;
  20530. /** @hidden */
  20531. _shouldGenerateFlatShading: boolean;
  20532. private _preActivateId;
  20533. /** @hidden */
  20534. _originalBuilderSideOrientation: number;
  20535. /**
  20536. * Use this property to change the original side orientation defined at construction time
  20537. */
  20538. overrideMaterialSideOrientation: Nullable<number>;
  20539. private _areNormalsFrozen;
  20540. private _sourcePositions;
  20541. private _sourceNormals;
  20542. private _source;
  20543. private meshMap;
  20544. /**
  20545. * Gets the source mesh (the one used to clone this one from)
  20546. */
  20547. readonly source: Nullable<Mesh>;
  20548. /**
  20549. * Gets or sets a boolean indicating that this mesh does not use index buffer
  20550. */
  20551. isUnIndexed: boolean;
  20552. /**
  20553. * @constructor
  20554. * @param name The value used by scene.getMeshByName() to do a lookup.
  20555. * @param scene The scene to add this mesh to.
  20556. * @param parent The parent of this mesh, if it has one
  20557. * @param source An optional Mesh from which geometry is shared, cloned.
  20558. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  20559. * When false, achieved by calling a clone(), also passing False.
  20560. * This will make creation of children, recursive.
  20561. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  20562. */
  20563. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  20564. /**
  20565. * Gets the class name
  20566. * @returns the string "Mesh".
  20567. */
  20568. getClassName(): string;
  20569. /** @hidden */
  20570. readonly _isMesh: boolean;
  20571. /**
  20572. * Returns a description of this mesh
  20573. * @param fullDetails define if full details about this mesh must be used
  20574. * @returns a descriptive string representing this mesh
  20575. */
  20576. toString(fullDetails?: boolean): string;
  20577. /** @hidden */
  20578. _unBindEffect(): void;
  20579. /**
  20580. * Gets a boolean indicating if this mesh has LOD
  20581. */
  20582. readonly hasLODLevels: boolean;
  20583. /**
  20584. * Gets the list of MeshLODLevel associated with the current mesh
  20585. * @returns an array of MeshLODLevel
  20586. */
  20587. getLODLevels(): MeshLODLevel[];
  20588. private _sortLODLevels;
  20589. /**
  20590. * Add a mesh as LOD level triggered at the given distance.
  20591. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  20592. * @param distance The distance from the center of the object to show this level
  20593. * @param mesh The mesh to be added as LOD level (can be null)
  20594. * @return This mesh (for chaining)
  20595. */
  20596. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  20597. /**
  20598. * Returns the LOD level mesh at the passed distance or null if not found.
  20599. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  20600. * @param distance The distance from the center of the object to show this level
  20601. * @returns a Mesh or `null`
  20602. */
  20603. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  20604. /**
  20605. * Remove a mesh from the LOD array
  20606. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  20607. * @param mesh defines the mesh to be removed
  20608. * @return This mesh (for chaining)
  20609. */
  20610. removeLODLevel(mesh: Mesh): Mesh;
  20611. /**
  20612. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  20613. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  20614. * @param camera defines the camera to use to compute distance
  20615. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  20616. * @return This mesh (for chaining)
  20617. */
  20618. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  20619. /**
  20620. * Gets the mesh internal Geometry object
  20621. */
  20622. readonly geometry: Nullable<Geometry>;
  20623. /**
  20624. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  20625. * @returns the total number of vertices
  20626. */
  20627. getTotalVertices(): number;
  20628. /**
  20629. * Returns the content of an associated vertex buffer
  20630. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  20631. * - VertexBuffer.PositionKind
  20632. * - VertexBuffer.UVKind
  20633. * - VertexBuffer.UV2Kind
  20634. * - VertexBuffer.UV3Kind
  20635. * - VertexBuffer.UV4Kind
  20636. * - VertexBuffer.UV5Kind
  20637. * - VertexBuffer.UV6Kind
  20638. * - VertexBuffer.ColorKind
  20639. * - VertexBuffer.MatricesIndicesKind
  20640. * - VertexBuffer.MatricesIndicesExtraKind
  20641. * - VertexBuffer.MatricesWeightsKind
  20642. * - VertexBuffer.MatricesWeightsExtraKind
  20643. * @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
  20644. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  20645. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  20646. */
  20647. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  20648. /**
  20649. * Returns the mesh VertexBuffer object from the requested `kind`
  20650. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  20651. * - VertexBuffer.PositionKind
  20652. * - VertexBuffer.UVKind
  20653. * - VertexBuffer.UV2Kind
  20654. * - VertexBuffer.UV3Kind
  20655. * - VertexBuffer.UV4Kind
  20656. * - VertexBuffer.UV5Kind
  20657. * - VertexBuffer.UV6Kind
  20658. * - VertexBuffer.ColorKind
  20659. * - VertexBuffer.MatricesIndicesKind
  20660. * - VertexBuffer.MatricesIndicesExtraKind
  20661. * - VertexBuffer.MatricesWeightsKind
  20662. * - VertexBuffer.MatricesWeightsExtraKind
  20663. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  20664. */
  20665. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  20666. /**
  20667. * Tests if a specific vertex buffer is associated with this mesh
  20668. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  20669. * - VertexBuffer.PositionKind
  20670. * - VertexBuffer.UVKind
  20671. * - VertexBuffer.UV2Kind
  20672. * - VertexBuffer.UV3Kind
  20673. * - VertexBuffer.UV4Kind
  20674. * - VertexBuffer.UV5Kind
  20675. * - VertexBuffer.UV6Kind
  20676. * - VertexBuffer.ColorKind
  20677. * - VertexBuffer.MatricesIndicesKind
  20678. * - VertexBuffer.MatricesIndicesExtraKind
  20679. * - VertexBuffer.MatricesWeightsKind
  20680. * - VertexBuffer.MatricesWeightsExtraKind
  20681. * @returns a boolean
  20682. */
  20683. isVerticesDataPresent(kind: string): boolean;
  20684. /**
  20685. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  20686. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  20687. * - VertexBuffer.PositionKind
  20688. * - VertexBuffer.UVKind
  20689. * - VertexBuffer.UV2Kind
  20690. * - VertexBuffer.UV3Kind
  20691. * - VertexBuffer.UV4Kind
  20692. * - VertexBuffer.UV5Kind
  20693. * - VertexBuffer.UV6Kind
  20694. * - VertexBuffer.ColorKind
  20695. * - VertexBuffer.MatricesIndicesKind
  20696. * - VertexBuffer.MatricesIndicesExtraKind
  20697. * - VertexBuffer.MatricesWeightsKind
  20698. * - VertexBuffer.MatricesWeightsExtraKind
  20699. * @returns a boolean
  20700. */
  20701. isVertexBufferUpdatable(kind: string): boolean;
  20702. /**
  20703. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  20704. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  20705. * - VertexBuffer.PositionKind
  20706. * - VertexBuffer.UVKind
  20707. * - VertexBuffer.UV2Kind
  20708. * - VertexBuffer.UV3Kind
  20709. * - VertexBuffer.UV4Kind
  20710. * - VertexBuffer.UV5Kind
  20711. * - VertexBuffer.UV6Kind
  20712. * - VertexBuffer.ColorKind
  20713. * - VertexBuffer.MatricesIndicesKind
  20714. * - VertexBuffer.MatricesIndicesExtraKind
  20715. * - VertexBuffer.MatricesWeightsKind
  20716. * - VertexBuffer.MatricesWeightsExtraKind
  20717. * @returns an array of strings
  20718. */
  20719. getVerticesDataKinds(): string[];
  20720. /**
  20721. * Returns a positive integer : the total number of indices in this mesh geometry.
  20722. * @returns the numner of indices or zero if the mesh has no geometry.
  20723. */
  20724. getTotalIndices(): number;
  20725. /**
  20726. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  20727. * @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.
  20728. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  20729. * @returns the indices array or an empty array if the mesh has no geometry
  20730. */
  20731. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  20732. readonly isBlocked: boolean;
  20733. /**
  20734. * Determine if the current mesh is ready to be rendered
  20735. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  20736. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  20737. * @returns true if all associated assets are ready (material, textures, shaders)
  20738. */
  20739. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  20740. /**
  20741. * 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.
  20742. */
  20743. readonly areNormalsFrozen: boolean;
  20744. /**
  20745. * 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.
  20746. * @returns the current mesh
  20747. */
  20748. freezeNormals(): Mesh;
  20749. /**
  20750. * 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
  20751. * @returns the current mesh
  20752. */
  20753. unfreezeNormals(): Mesh;
  20754. /**
  20755. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  20756. */
  20757. overridenInstanceCount: number;
  20758. /** @hidden */
  20759. _preActivate(): Mesh;
  20760. /** @hidden */
  20761. _preActivateForIntermediateRendering(renderId: number): Mesh;
  20762. /** @hidden */
  20763. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  20764. /**
  20765. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  20766. * This means the mesh underlying bounding box and sphere are recomputed.
  20767. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  20768. * @returns the current mesh
  20769. */
  20770. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  20771. /** @hidden */
  20772. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  20773. /**
  20774. * This function will subdivide the mesh into multiple submeshes
  20775. * @param count defines the expected number of submeshes
  20776. */
  20777. subdivide(count: number): void;
  20778. /**
  20779. * Copy a FloatArray into a specific associated vertex buffer
  20780. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  20781. * - VertexBuffer.PositionKind
  20782. * - VertexBuffer.UVKind
  20783. * - VertexBuffer.UV2Kind
  20784. * - VertexBuffer.UV3Kind
  20785. * - VertexBuffer.UV4Kind
  20786. * - VertexBuffer.UV5Kind
  20787. * - VertexBuffer.UV6Kind
  20788. * - VertexBuffer.ColorKind
  20789. * - VertexBuffer.MatricesIndicesKind
  20790. * - VertexBuffer.MatricesIndicesExtraKind
  20791. * - VertexBuffer.MatricesWeightsKind
  20792. * - VertexBuffer.MatricesWeightsExtraKind
  20793. * @param data defines the data source
  20794. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  20795. * @param stride defines the data stride size (can be null)
  20796. * @returns the current mesh
  20797. */
  20798. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  20799. /**
  20800. * Flags an associated vertex buffer as updatable
  20801. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  20802. * - VertexBuffer.PositionKind
  20803. * - VertexBuffer.UVKind
  20804. * - VertexBuffer.UV2Kind
  20805. * - VertexBuffer.UV3Kind
  20806. * - VertexBuffer.UV4Kind
  20807. * - VertexBuffer.UV5Kind
  20808. * - VertexBuffer.UV6Kind
  20809. * - VertexBuffer.ColorKind
  20810. * - VertexBuffer.MatricesIndicesKind
  20811. * - VertexBuffer.MatricesIndicesExtraKind
  20812. * - VertexBuffer.MatricesWeightsKind
  20813. * - VertexBuffer.MatricesWeightsExtraKind
  20814. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  20815. */
  20816. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  20817. /**
  20818. * Sets the mesh global Vertex Buffer
  20819. * @param buffer defines the buffer to use
  20820. * @returns the current mesh
  20821. */
  20822. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  20823. /**
  20824. * Update a specific associated vertex buffer
  20825. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  20826. * - VertexBuffer.PositionKind
  20827. * - VertexBuffer.UVKind
  20828. * - VertexBuffer.UV2Kind
  20829. * - VertexBuffer.UV3Kind
  20830. * - VertexBuffer.UV4Kind
  20831. * - VertexBuffer.UV5Kind
  20832. * - VertexBuffer.UV6Kind
  20833. * - VertexBuffer.ColorKind
  20834. * - VertexBuffer.MatricesIndicesKind
  20835. * - VertexBuffer.MatricesIndicesExtraKind
  20836. * - VertexBuffer.MatricesWeightsKind
  20837. * - VertexBuffer.MatricesWeightsExtraKind
  20838. * @param data defines the data source
  20839. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  20840. * @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)
  20841. * @returns the current mesh
  20842. */
  20843. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  20844. /**
  20845. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  20846. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  20847. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  20848. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  20849. * @returns the current mesh
  20850. */
  20851. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  20852. /**
  20853. * Creates a un-shared specific occurence of the geometry for the mesh.
  20854. * @returns the current mesh
  20855. */
  20856. makeGeometryUnique(): Mesh;
  20857. /**
  20858. * Set the index buffer of this mesh
  20859. * @param indices defines the source data
  20860. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  20861. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  20862. * @returns the current mesh
  20863. */
  20864. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  20865. /**
  20866. * Update the current index buffer
  20867. * @param indices defines the source data
  20868. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  20869. * @returns the current mesh
  20870. */
  20871. updateIndices(indices: IndicesArray, offset?: number): Mesh;
  20872. /**
  20873. * Invert the geometry to move from a right handed system to a left handed one.
  20874. * @returns the current mesh
  20875. */
  20876. toLeftHanded(): Mesh;
  20877. /** @hidden */
  20878. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  20879. /** @hidden */
  20880. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number, alternate?: boolean): Mesh;
  20881. /**
  20882. * Registers for this mesh a javascript function called just before the rendering process
  20883. * @param func defines the function to call before rendering this mesh
  20884. * @returns the current mesh
  20885. */
  20886. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  20887. /**
  20888. * Disposes a previously registered javascript function called before the rendering
  20889. * @param func defines the function to remove
  20890. * @returns the current mesh
  20891. */
  20892. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  20893. /**
  20894. * Registers for this mesh a javascript function called just after the rendering is complete
  20895. * @param func defines the function to call after rendering this mesh
  20896. * @returns the current mesh
  20897. */
  20898. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  20899. /**
  20900. * Disposes a previously registered javascript function called after the rendering.
  20901. * @param func defines the function to remove
  20902. * @returns the current mesh
  20903. */
  20904. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  20905. /** @hidden */
  20906. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  20907. /** @hidden */
  20908. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  20909. /** @hidden */
  20910. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  20911. /**
  20912. * 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
  20913. * @param subMesh defines the subMesh to render
  20914. * @param enableAlphaMode defines if alpha mode can be changed
  20915. * @returns the current mesh
  20916. */
  20917. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  20918. private _onBeforeDraw;
  20919. /**
  20920. * Renormalize the mesh and patch it up if there are no weights
  20921. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  20922. * However in the case of zero weights then we set just a single influence to 1.
  20923. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  20924. */
  20925. cleanMatrixWeights(): void;
  20926. private normalizeSkinFourWeights;
  20927. private normalizeSkinWeightsAndExtra;
  20928. /**
  20929. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  20930. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  20931. * the user know there was an issue with importing the mesh
  20932. * @returns a validation object with skinned, valid and report string
  20933. */
  20934. validateSkinning(): {
  20935. skinned: boolean;
  20936. valid: boolean;
  20937. report: string;
  20938. };
  20939. /** @hidden */
  20940. _checkDelayState(): Mesh;
  20941. private _queueLoad;
  20942. /**
  20943. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  20944. * A mesh is in the frustum if its bounding box intersects the frustum
  20945. * @param frustumPlanes defines the frustum to test
  20946. * @returns true if the mesh is in the frustum planes
  20947. */
  20948. isInFrustum(frustumPlanes: Plane[]): boolean;
  20949. /**
  20950. * Sets the mesh material by the material or multiMaterial `id` property
  20951. * @param id is a string identifying the material or the multiMaterial
  20952. * @returns the current mesh
  20953. */
  20954. setMaterialByID(id: string): Mesh;
  20955. /**
  20956. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  20957. * @returns an array of IAnimatable
  20958. */
  20959. getAnimatables(): IAnimatable[];
  20960. /**
  20961. * Modifies the mesh geometry according to the passed transformation matrix.
  20962. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  20963. * The mesh normals are modified using the same transformation.
  20964. * Note that, under the hood, this method sets a new VertexBuffer each call.
  20965. * @param transform defines the transform matrix to use
  20966. * @see http://doc.babylonjs.com/resources/baking_transformations
  20967. * @returns the current mesh
  20968. */
  20969. bakeTransformIntoVertices(transform: Matrix): Mesh;
  20970. /**
  20971. * Modifies the mesh geometry according to its own current World Matrix.
  20972. * The mesh World Matrix is then reset.
  20973. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  20974. * Note that, under the hood, this method sets a new VertexBuffer each call.
  20975. * @see http://doc.babylonjs.com/resources/baking_transformations
  20976. * @returns the current mesh
  20977. */
  20978. bakeCurrentTransformIntoVertices(): Mesh;
  20979. /** @hidden */
  20980. readonly _positions: Nullable<Vector3[]>;
  20981. /** @hidden */
  20982. _resetPointsArrayCache(): Mesh;
  20983. /** @hidden */
  20984. _generatePointsArray(): boolean;
  20985. /**
  20986. * Returns a new Mesh object generated from the current mesh properties.
  20987. * This method must not get confused with createInstance()
  20988. * @param name is a string, the name given to the new mesh
  20989. * @param newParent can be any Node object (default `null`)
  20990. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  20991. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  20992. * @returns a new mesh
  20993. */
  20994. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  20995. /**
  20996. * Releases resources associated with this mesh.
  20997. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  20998. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  20999. */
  21000. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  21001. /**
  21002. * Modifies the mesh geometry according to a displacement map.
  21003. * 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.
  21004. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  21005. * @param url is a string, the URL from the image file is to be downloaded.
  21006. * @param minHeight is the lower limit of the displacement.
  21007. * @param maxHeight is the upper limit of the displacement.
  21008. * @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.
  21009. * @param uvOffset is an optional vector2 used to offset UV.
  21010. * @param uvScale is an optional vector2 used to scale UV.
  21011. * @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.
  21012. * @returns the Mesh.
  21013. */
  21014. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  21015. /**
  21016. * Modifies the mesh geometry according to a displacementMap buffer.
  21017. * 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.
  21018. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  21019. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  21020. * @param heightMapWidth is the width of the buffer image.
  21021. * @param heightMapHeight is the height of the buffer image.
  21022. * @param minHeight is the lower limit of the displacement.
  21023. * @param maxHeight is the upper limit of the displacement.
  21024. * @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.
  21025. * @param uvOffset is an optional vector2 used to offset UV.
  21026. * @param uvScale is an optional vector2 used to scale UV.
  21027. * @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.
  21028. * @returns the Mesh.
  21029. */
  21030. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  21031. /**
  21032. * Modify the mesh to get a flat shading rendering.
  21033. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  21034. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  21035. * @returns current mesh
  21036. */
  21037. convertToFlatShadedMesh(): Mesh;
  21038. /**
  21039. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  21040. * In other words, more vertices, no more indices and a single bigger VBO.
  21041. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  21042. * @returns current mesh
  21043. */
  21044. convertToUnIndexedMesh(): Mesh;
  21045. /**
  21046. * Inverses facet orientations.
  21047. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  21048. * @param flipNormals will also inverts the normals
  21049. * @returns current mesh
  21050. */
  21051. flipFaces(flipNormals?: boolean): Mesh;
  21052. /** @hidden */
  21053. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  21054. /** @hidden */
  21055. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  21056. /**
  21057. * Creates a new InstancedMesh object from the mesh model.
  21058. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  21059. * @param name defines the name of the new instance
  21060. * @returns a new InstancedMesh
  21061. */
  21062. createInstance(name: string): InstancedMesh;
  21063. /**
  21064. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  21065. * After this call, all the mesh instances have the same submeshes than the current mesh.
  21066. * @returns the current mesh
  21067. */
  21068. synchronizeInstances(): Mesh;
  21069. /**
  21070. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  21071. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  21072. * This should be used together with the simplification to avoid disappearing triangles.
  21073. * @param successCallback an optional success callback to be called after the optimization finished.
  21074. * @returns the current mesh
  21075. */
  21076. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  21077. /**
  21078. * Serialize current mesh
  21079. * @param serializationObject defines the object which will receive the serialization data
  21080. */
  21081. serialize(serializationObject: any): void;
  21082. /** @hidden */
  21083. _syncGeometryWithMorphTargetManager(): void;
  21084. /** @hidden */
  21085. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  21086. /**
  21087. * Returns a new Mesh object parsed from the source provided.
  21088. * @param parsedMesh is the source
  21089. * @param scene defines the hosting scene
  21090. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  21091. * @returns a new Mesh
  21092. */
  21093. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  21094. /**
  21095. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  21096. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  21097. * @param name defines the name of the mesh to create
  21098. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  21099. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  21100. * @param closePath creates a seam between the first and the last points of each path of the path array
  21101. * @param offset is taken in account only if the `pathArray` is containing a single path
  21102. * @param scene defines the hosting scene
  21103. * @param updatable defines if the mesh must be flagged as updatable
  21104. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21105. * @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)
  21106. * @returns a new Mesh
  21107. */
  21108. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21109. /**
  21110. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  21111. * @param name defines the name of the mesh to create
  21112. * @param radius sets the radius size (float) of the polygon (default 0.5)
  21113. * @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
  21114. * @param scene defines the hosting scene
  21115. * @param updatable defines if the mesh must be flagged as updatable
  21116. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21117. * @returns a new Mesh
  21118. */
  21119. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  21120. /**
  21121. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  21122. * @param name defines the name of the mesh to create
  21123. * @param size sets the size (float) of each box side (default 1)
  21124. * @param scene defines the hosting scene
  21125. * @param updatable defines if the mesh must be flagged as updatable
  21126. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21127. * @returns a new Mesh
  21128. */
  21129. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  21130. /**
  21131. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  21132. * @param name defines the name of the mesh to create
  21133. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  21134. * @param diameter sets the diameter size (float) of the sphere (default 1)
  21135. * @param scene defines the hosting scene
  21136. * @param updatable defines if the mesh must be flagged as updatable
  21137. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21138. * @returns a new Mesh
  21139. */
  21140. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21141. /**
  21142. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  21143. * @param name defines the name of the mesh to create
  21144. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  21145. * @param diameterTop set the top cap diameter (floats, default 1)
  21146. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  21147. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  21148. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  21149. * @param scene defines the hosting scene
  21150. * @param updatable defines if the mesh must be flagged as updatable
  21151. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21152. * @returns a new Mesh
  21153. */
  21154. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  21155. /**
  21156. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  21157. * @param name defines the name of the mesh to create
  21158. * @param diameter sets the diameter size (float) of the torus (default 1)
  21159. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  21160. * @param tessellation sets the number of torus sides (postive integer, default 16)
  21161. * @param scene defines the hosting scene
  21162. * @param updatable defines if the mesh must be flagged as updatable
  21163. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21164. * @returns a new Mesh
  21165. */
  21166. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21167. /**
  21168. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  21169. * @param name defines the name of the mesh to create
  21170. * @param radius sets the global radius size (float) of the torus knot (default 2)
  21171. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  21172. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  21173. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  21174. * @param p the number of windings on X axis (positive integers, default 2)
  21175. * @param q the number of windings on Y axis (positive integers, default 3)
  21176. * @param scene defines the hosting scene
  21177. * @param updatable defines if the mesh must be flagged as updatable
  21178. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21179. * @returns a new Mesh
  21180. */
  21181. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21182. /**
  21183. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  21184. * @param name defines the name of the mesh to create
  21185. * @param points is an array successive Vector3
  21186. * @param scene defines the hosting scene
  21187. * @param updatable defines if the mesh must be flagged as updatable
  21188. * @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).
  21189. * @returns a new Mesh
  21190. */
  21191. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  21192. /**
  21193. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  21194. * @param name defines the name of the mesh to create
  21195. * @param points is an array successive Vector3
  21196. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  21197. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  21198. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  21199. * @param scene defines the hosting scene
  21200. * @param updatable defines if the mesh must be flagged as updatable
  21201. * @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)
  21202. * @returns a new Mesh
  21203. */
  21204. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  21205. /**
  21206. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  21207. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  21208. * 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.
  21209. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21210. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21211. * Remember you can only change the shape positions, not their number when updating a polygon.
  21212. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  21213. * @param name defines the name of the mesh to create
  21214. * @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
  21215. * @param scene defines the hosting scene
  21216. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  21217. * @param updatable defines if the mesh must be flagged as updatable
  21218. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21219. * @param earcutInjection can be used to inject your own earcut reference
  21220. * @returns a new Mesh
  21221. */
  21222. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  21223. /**
  21224. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  21225. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  21226. * @param name defines the name of the mesh to create
  21227. * @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
  21228. * @param depth defines the height of extrusion
  21229. * @param scene defines the hosting scene
  21230. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  21231. * @param updatable defines if the mesh must be flagged as updatable
  21232. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21233. * @param earcutInjection can be used to inject your own earcut reference
  21234. * @returns a new Mesh
  21235. */
  21236. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  21237. /**
  21238. * Creates an extruded shape mesh.
  21239. * 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
  21240. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  21241. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  21242. * @param name defines the name of the mesh to create
  21243. * @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
  21244. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  21245. * @param scale is the value to scale the shape
  21246. * @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
  21247. * @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
  21248. * @param scene defines the hosting scene
  21249. * @param updatable defines if the mesh must be flagged as updatable
  21250. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21251. * @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)
  21252. * @returns a new Mesh
  21253. */
  21254. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21255. /**
  21256. * Creates an custom extruded shape mesh.
  21257. * The custom extrusion is a parametric shape.
  21258. * It has no predefined shape. Its final shape will depend on the input parameters.
  21259. * Please consider using the same method from the MeshBuilder class instead
  21260. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  21261. * @param name defines the name of the mesh to create
  21262. * @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
  21263. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  21264. * @param scaleFunction is a custom Javascript function called on each path point
  21265. * @param rotationFunction is a custom Javascript function called on each path point
  21266. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  21267. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  21268. * @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
  21269. * @param scene defines the hosting scene
  21270. * @param updatable defines if the mesh must be flagged as updatable
  21271. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21272. * @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)
  21273. * @returns a new Mesh
  21274. */
  21275. 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;
  21276. /**
  21277. * Creates lathe mesh.
  21278. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  21279. * Please consider using the same method from the MeshBuilder class instead
  21280. * @param name defines the name of the mesh to create
  21281. * @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
  21282. * @param radius is the radius value of the lathe
  21283. * @param tessellation is the side number of the lathe.
  21284. * @param scene defines the hosting scene
  21285. * @param updatable defines if the mesh must be flagged as updatable
  21286. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21287. * @returns a new Mesh
  21288. */
  21289. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21290. /**
  21291. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  21292. * @param name defines the name of the mesh to create
  21293. * @param size sets the size (float) of both sides of the plane at once (default 1)
  21294. * @param scene defines the hosting scene
  21295. * @param updatable defines if the mesh must be flagged as updatable
  21296. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21297. * @returns a new Mesh
  21298. */
  21299. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21300. /**
  21301. * Creates a ground mesh.
  21302. * Please consider using the same method from the MeshBuilder class instead
  21303. * @param name defines the name of the mesh to create
  21304. * @param width set the width of the ground
  21305. * @param height set the height of the ground
  21306. * @param subdivisions sets the number of subdivisions per side
  21307. * @param scene defines the hosting scene
  21308. * @param updatable defines if the mesh must be flagged as updatable
  21309. * @returns a new Mesh
  21310. */
  21311. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  21312. /**
  21313. * Creates a tiled ground mesh.
  21314. * Please consider using the same method from the MeshBuilder class instead
  21315. * @param name defines the name of the mesh to create
  21316. * @param xmin set the ground minimum X coordinate
  21317. * @param zmin set the ground minimum Y coordinate
  21318. * @param xmax set the ground maximum X coordinate
  21319. * @param zmax set the ground maximum Z coordinate
  21320. * @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
  21321. * @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
  21322. * @param scene defines the hosting scene
  21323. * @param updatable defines if the mesh must be flagged as updatable
  21324. * @returns a new Mesh
  21325. */
  21326. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  21327. w: number;
  21328. h: number;
  21329. }, precision: {
  21330. w: number;
  21331. h: number;
  21332. }, scene: Scene, updatable?: boolean): Mesh;
  21333. /**
  21334. * Creates a ground mesh from a height map.
  21335. * Please consider using the same method from the MeshBuilder class instead
  21336. * @see http://doc.babylonjs.com/babylon101/height_map
  21337. * @param name defines the name of the mesh to create
  21338. * @param url sets the URL of the height map image resource
  21339. * @param width set the ground width size
  21340. * @param height set the ground height size
  21341. * @param subdivisions sets the number of subdivision per side
  21342. * @param minHeight is the minimum altitude on the ground
  21343. * @param maxHeight is the maximum altitude on the ground
  21344. * @param scene defines the hosting scene
  21345. * @param updatable defines if the mesh must be flagged as updatable
  21346. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  21347. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  21348. * @returns a new Mesh
  21349. */
  21350. 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;
  21351. /**
  21352. * Creates a tube mesh.
  21353. * The tube is a parametric shape.
  21354. * It has no predefined shape. Its final shape will depend on the input parameters.
  21355. * Please consider using the same method from the MeshBuilder class instead
  21356. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  21357. * @param name defines the name of the mesh to create
  21358. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  21359. * @param radius sets the tube radius size
  21360. * @param tessellation is the number of sides on the tubular surface
  21361. * @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
  21362. * @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
  21363. * @param scene defines the hosting scene
  21364. * @param updatable defines if the mesh must be flagged as updatable
  21365. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21366. * @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)
  21367. * @returns a new Mesh
  21368. */
  21369. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  21370. (i: number, distance: number): number;
  21371. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21372. /**
  21373. * Creates a polyhedron mesh.
  21374. * Please consider using the same method from the MeshBuilder class instead.
  21375. * * 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
  21376. * * The parameter `size` (positive float, default 1) sets the polygon size
  21377. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  21378. * * 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`
  21379. * * 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
  21380. * * 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)`)
  21381. * * 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
  21382. * * 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
  21383. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21384. * * If you create a double-sided mesh, you can choose what parts of 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
  21385. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21386. * @param name defines the name of the mesh to create
  21387. * @param options defines the options used to create the mesh
  21388. * @param scene defines the hosting scene
  21389. * @returns a new Mesh
  21390. */
  21391. static CreatePolyhedron(name: string, options: {
  21392. type?: number;
  21393. size?: number;
  21394. sizeX?: number;
  21395. sizeY?: number;
  21396. sizeZ?: number;
  21397. custom?: any;
  21398. faceUV?: Vector4[];
  21399. faceColors?: Color4[];
  21400. updatable?: boolean;
  21401. sideOrientation?: number;
  21402. }, scene: Scene): Mesh;
  21403. /**
  21404. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  21405. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  21406. * * 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`)
  21407. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  21408. * * 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
  21409. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21410. * * If you create a double-sided mesh, you can choose what parts of 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
  21411. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21412. * @param name defines the name of the mesh
  21413. * @param options defines the options used to create the mesh
  21414. * @param scene defines the hosting scene
  21415. * @returns a new Mesh
  21416. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  21417. */
  21418. static CreateIcoSphere(name: string, options: {
  21419. radius?: number;
  21420. flat?: boolean;
  21421. subdivisions?: number;
  21422. sideOrientation?: number;
  21423. updatable?: boolean;
  21424. }, scene: Scene): Mesh;
  21425. /**
  21426. * Creates a decal mesh.
  21427. * Please consider using the same method from the MeshBuilder class instead.
  21428. * A decal is a mesh usually applied as a model onto the surface of another mesh
  21429. * @param name defines the name of the mesh
  21430. * @param sourceMesh defines the mesh receiving the decal
  21431. * @param position sets the position of the decal in world coordinates
  21432. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  21433. * @param size sets the decal scaling
  21434. * @param angle sets the angle to rotate the decal
  21435. * @returns a new Mesh
  21436. */
  21437. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  21438. /**
  21439. * Prepare internal position array for software CPU skinning
  21440. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  21441. */
  21442. setPositionsForCPUSkinning(): Float32Array;
  21443. /**
  21444. * Prepare internal normal array for software CPU skinning
  21445. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  21446. */
  21447. setNormalsForCPUSkinning(): Float32Array;
  21448. /**
  21449. * Updates the vertex buffer by applying transformation from the bones
  21450. * @param skeleton defines the skeleton to apply to current mesh
  21451. * @returns the current mesh
  21452. */
  21453. applySkeleton(skeleton: Skeleton): Mesh;
  21454. /**
  21455. * 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
  21456. * @param meshes defines the list of meshes to scan
  21457. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  21458. */
  21459. static MinMax(meshes: AbstractMesh[]): {
  21460. min: Vector3;
  21461. max: Vector3;
  21462. };
  21463. /**
  21464. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  21465. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  21466. * @returns a vector3
  21467. */
  21468. static Center(meshesOrMinMaxVector: {
  21469. min: Vector3;
  21470. max: Vector3;
  21471. } | AbstractMesh[]): Vector3;
  21472. /**
  21473. * Merge the array of meshes into a single mesh for performance reasons.
  21474. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  21475. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  21476. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  21477. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  21478. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  21479. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  21480. * @returns a new mesh
  21481. */
  21482. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  21483. /** @hidden */
  21484. addInstance(instance: InstancedMesh): void;
  21485. /** @hidden */
  21486. removeInstance(instance: InstancedMesh): void;
  21487. }
  21488. }
  21489. declare module "babylonjs/Materials/material" {
  21490. import { IAnimatable } from "babylonjs/Misc/tools";
  21491. import { SmartArray } from "babylonjs/Misc/smartArray";
  21492. import { Observable } from "babylonjs/Misc/observable";
  21493. import { Nullable } from "babylonjs/types";
  21494. import { Scene } from "babylonjs/scene";
  21495. import { Matrix } from "babylonjs/Maths/math";
  21496. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  21497. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21498. import { Mesh } from "babylonjs/Meshes/mesh";
  21499. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  21500. import { Effect } from "babylonjs/Materials/effect";
  21501. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21502. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  21503. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  21504. import { Animation } from "babylonjs/Animations/animation";
  21505. /**
  21506. * Base class for the main features of a material in Babylon.js
  21507. */
  21508. export class Material implements IAnimatable {
  21509. /**
  21510. * Returns the triangle fill mode
  21511. */
  21512. static readonly TriangleFillMode: number;
  21513. /**
  21514. * Returns the wireframe mode
  21515. */
  21516. static readonly WireFrameFillMode: number;
  21517. /**
  21518. * Returns the point fill mode
  21519. */
  21520. static readonly PointFillMode: number;
  21521. /**
  21522. * Returns the point list draw mode
  21523. */
  21524. static readonly PointListDrawMode: number;
  21525. /**
  21526. * Returns the line list draw mode
  21527. */
  21528. static readonly LineListDrawMode: number;
  21529. /**
  21530. * Returns the line loop draw mode
  21531. */
  21532. static readonly LineLoopDrawMode: number;
  21533. /**
  21534. * Returns the line strip draw mode
  21535. */
  21536. static readonly LineStripDrawMode: number;
  21537. /**
  21538. * Returns the triangle strip draw mode
  21539. */
  21540. static readonly TriangleStripDrawMode: number;
  21541. /**
  21542. * Returns the triangle fan draw mode
  21543. */
  21544. static readonly TriangleFanDrawMode: number;
  21545. /**
  21546. * Stores the clock-wise side orientation
  21547. */
  21548. static readonly ClockWiseSideOrientation: number;
  21549. /**
  21550. * Stores the counter clock-wise side orientation
  21551. */
  21552. static readonly CounterClockWiseSideOrientation: number;
  21553. /**
  21554. * The dirty texture flag value
  21555. */
  21556. static readonly TextureDirtyFlag: number;
  21557. /**
  21558. * The dirty light flag value
  21559. */
  21560. static readonly LightDirtyFlag: number;
  21561. /**
  21562. * The dirty fresnel flag value
  21563. */
  21564. static readonly FresnelDirtyFlag: number;
  21565. /**
  21566. * The dirty attribute flag value
  21567. */
  21568. static readonly AttributesDirtyFlag: number;
  21569. /**
  21570. * The dirty misc flag value
  21571. */
  21572. static readonly MiscDirtyFlag: number;
  21573. /**
  21574. * The all dirty flag value
  21575. */
  21576. static readonly AllDirtyFlag: number;
  21577. /**
  21578. * The ID of the material
  21579. */
  21580. id: string;
  21581. /**
  21582. * Gets or sets the unique id of the material
  21583. */
  21584. uniqueId: number;
  21585. /**
  21586. * The name of the material
  21587. */
  21588. name: string;
  21589. /**
  21590. * Gets or sets user defined metadata
  21591. */
  21592. metadata: any;
  21593. /**
  21594. * For internal use only. Please do not use.
  21595. */
  21596. reservedDataStore: any;
  21597. /**
  21598. * Specifies if the ready state should be checked on each call
  21599. */
  21600. checkReadyOnEveryCall: boolean;
  21601. /**
  21602. * Specifies if the ready state should be checked once
  21603. */
  21604. checkReadyOnlyOnce: boolean;
  21605. /**
  21606. * The state of the material
  21607. */
  21608. state: string;
  21609. /**
  21610. * The alpha value of the material
  21611. */
  21612. protected _alpha: number;
  21613. /**
  21614. * Sets the alpha value of the material
  21615. */
  21616. /**
  21617. * Gets the alpha value of the material
  21618. */
  21619. alpha: number;
  21620. /**
  21621. * Specifies if back face culling is enabled
  21622. */
  21623. protected _backFaceCulling: boolean;
  21624. /**
  21625. * Sets the back-face culling state
  21626. */
  21627. /**
  21628. * Gets the back-face culling state
  21629. */
  21630. backFaceCulling: boolean;
  21631. /**
  21632. * Stores the value for side orientation
  21633. */
  21634. sideOrientation: number;
  21635. /**
  21636. * Callback triggered when the material is compiled
  21637. */
  21638. onCompiled: (effect: Effect) => void;
  21639. /**
  21640. * Callback triggered when an error occurs
  21641. */
  21642. onError: (effect: Effect, errors: string) => void;
  21643. /**
  21644. * Callback triggered to get the render target textures
  21645. */
  21646. getRenderTargetTextures: () => SmartArray<RenderTargetTexture>;
  21647. /**
  21648. * Gets a boolean indicating that current material needs to register RTT
  21649. */
  21650. readonly hasRenderTargetTextures: boolean;
  21651. /**
  21652. * Specifies if the material should be serialized
  21653. */
  21654. doNotSerialize: boolean;
  21655. /**
  21656. * @hidden
  21657. */
  21658. _storeEffectOnSubMeshes: boolean;
  21659. /**
  21660. * Stores the animations for the material
  21661. */
  21662. animations: Array<Animation>;
  21663. /**
  21664. * An event triggered when the material is disposed
  21665. */
  21666. onDisposeObservable: Observable<Material>;
  21667. /**
  21668. * An observer which watches for dispose events
  21669. */
  21670. private _onDisposeObserver;
  21671. private _onUnBindObservable;
  21672. /**
  21673. * Called during a dispose event
  21674. */
  21675. onDispose: () => void;
  21676. private _onBindObservable;
  21677. /**
  21678. * An event triggered when the material is bound
  21679. */
  21680. readonly onBindObservable: Observable<AbstractMesh>;
  21681. /**
  21682. * An observer which watches for bind events
  21683. */
  21684. private _onBindObserver;
  21685. /**
  21686. * Called during a bind event
  21687. */
  21688. onBind: (Mesh: AbstractMesh) => void;
  21689. /**
  21690. * An event triggered when the material is unbound
  21691. */
  21692. readonly onUnBindObservable: Observable<Material>;
  21693. /**
  21694. * Stores the value of the alpha mode
  21695. */
  21696. private _alphaMode;
  21697. /**
  21698. * Sets the value of the alpha mode.
  21699. *
  21700. * | Value | Type | Description |
  21701. * | --- | --- | --- |
  21702. * | 0 | ALPHA_DISABLE | |
  21703. * | 1 | ALPHA_ADD | |
  21704. * | 2 | ALPHA_COMBINE | |
  21705. * | 3 | ALPHA_SUBTRACT | |
  21706. * | 4 | ALPHA_MULTIPLY | |
  21707. * | 5 | ALPHA_MAXIMIZED | |
  21708. * | 6 | ALPHA_ONEONE | |
  21709. * | 7 | ALPHA_PREMULTIPLIED | |
  21710. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  21711. * | 9 | ALPHA_INTERPOLATE | |
  21712. * | 10 | ALPHA_SCREENMODE | |
  21713. *
  21714. */
  21715. /**
  21716. * Gets the value of the alpha mode
  21717. */
  21718. alphaMode: number;
  21719. /**
  21720. * Stores the state of the need depth pre-pass value
  21721. */
  21722. private _needDepthPrePass;
  21723. /**
  21724. * Sets the need depth pre-pass value
  21725. */
  21726. /**
  21727. * Gets the depth pre-pass value
  21728. */
  21729. needDepthPrePass: boolean;
  21730. /**
  21731. * Specifies if depth writing should be disabled
  21732. */
  21733. disableDepthWrite: boolean;
  21734. /**
  21735. * Specifies if depth writing should be forced
  21736. */
  21737. forceDepthWrite: boolean;
  21738. /**
  21739. * Specifies if there should be a separate pass for culling
  21740. */
  21741. separateCullingPass: boolean;
  21742. /**
  21743. * Stores the state specifing if fog should be enabled
  21744. */
  21745. private _fogEnabled;
  21746. /**
  21747. * Sets the state for enabling fog
  21748. */
  21749. /**
  21750. * Gets the value of the fog enabled state
  21751. */
  21752. fogEnabled: boolean;
  21753. /**
  21754. * Stores the size of points
  21755. */
  21756. pointSize: number;
  21757. /**
  21758. * Stores the z offset value
  21759. */
  21760. zOffset: number;
  21761. /**
  21762. * Gets a value specifying if wireframe mode is enabled
  21763. */
  21764. /**
  21765. * Sets the state of wireframe mode
  21766. */
  21767. wireframe: boolean;
  21768. /**
  21769. * Gets the value specifying if point clouds are enabled
  21770. */
  21771. /**
  21772. * Sets the state of point cloud mode
  21773. */
  21774. pointsCloud: boolean;
  21775. /**
  21776. * Gets the material fill mode
  21777. */
  21778. /**
  21779. * Sets the material fill mode
  21780. */
  21781. fillMode: number;
  21782. /**
  21783. * @hidden
  21784. * Stores the effects for the material
  21785. */
  21786. _effect: Nullable<Effect>;
  21787. /**
  21788. * @hidden
  21789. * Specifies if the material was previously ready
  21790. */
  21791. _wasPreviouslyReady: boolean;
  21792. /**
  21793. * Specifies if uniform buffers should be used
  21794. */
  21795. private _useUBO;
  21796. /**
  21797. * Stores a reference to the scene
  21798. */
  21799. private _scene;
  21800. /**
  21801. * Stores the fill mode state
  21802. */
  21803. private _fillMode;
  21804. /**
  21805. * Specifies if the depth write state should be cached
  21806. */
  21807. private _cachedDepthWriteState;
  21808. /**
  21809. * Stores the uniform buffer
  21810. */
  21811. protected _uniformBuffer: UniformBuffer;
  21812. /** @hidden */
  21813. _indexInSceneMaterialArray: number;
  21814. /** @hidden */
  21815. meshMap: Nullable<{
  21816. [id: string]: AbstractMesh | undefined;
  21817. }>;
  21818. /**
  21819. * Creates a material instance
  21820. * @param name defines the name of the material
  21821. * @param scene defines the scene to reference
  21822. * @param doNotAdd specifies if the material should be added to the scene
  21823. */
  21824. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  21825. /**
  21826. * Returns a string representation of the current material
  21827. * @param fullDetails defines a boolean indicating which levels of logging is desired
  21828. * @returns a string with material information
  21829. */
  21830. toString(fullDetails?: boolean): string;
  21831. /**
  21832. * Gets the class name of the material
  21833. * @returns a string with the class name of the material
  21834. */
  21835. getClassName(): string;
  21836. /**
  21837. * Specifies if updates for the material been locked
  21838. */
  21839. readonly isFrozen: boolean;
  21840. /**
  21841. * Locks updates for the material
  21842. */
  21843. freeze(): void;
  21844. /**
  21845. * Unlocks updates for the material
  21846. */
  21847. unfreeze(): void;
  21848. /**
  21849. * Specifies if the material is ready to be used
  21850. * @param mesh defines the mesh to check
  21851. * @param useInstances specifies if instances should be used
  21852. * @returns a boolean indicating if the material is ready to be used
  21853. */
  21854. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21855. /**
  21856. * Specifies that the submesh is ready to be used
  21857. * @param mesh defines the mesh to check
  21858. * @param subMesh defines which submesh to check
  21859. * @param useInstances specifies that instances should be used
  21860. * @returns a boolean indicating that the submesh is ready or not
  21861. */
  21862. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21863. /**
  21864. * Returns the material effect
  21865. * @returns the effect associated with the material
  21866. */
  21867. getEffect(): Nullable<Effect>;
  21868. /**
  21869. * Returns the current scene
  21870. * @returns a Scene
  21871. */
  21872. getScene(): Scene;
  21873. /**
  21874. * Specifies if the material will require alpha blending
  21875. * @returns a boolean specifying if alpha blending is needed
  21876. */
  21877. needAlphaBlending(): boolean;
  21878. /**
  21879. * Specifies if the mesh will require alpha blending
  21880. * @param mesh defines the mesh to check
  21881. * @returns a boolean specifying if alpha blending is needed for the mesh
  21882. */
  21883. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  21884. /**
  21885. * Specifies if this material should be rendered in alpha test mode
  21886. * @returns a boolean specifying if an alpha test is needed.
  21887. */
  21888. needAlphaTesting(): boolean;
  21889. /**
  21890. * Gets the texture used for the alpha test
  21891. * @returns the texture to use for alpha testing
  21892. */
  21893. getAlphaTestTexture(): Nullable<BaseTexture>;
  21894. /**
  21895. * Marks the material to indicate that it needs to be re-calculated
  21896. */
  21897. markDirty(): void;
  21898. /** @hidden */
  21899. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  21900. /**
  21901. * Binds the material to the mesh
  21902. * @param world defines the world transformation matrix
  21903. * @param mesh defines the mesh to bind the material to
  21904. */
  21905. bind(world: Matrix, mesh?: Mesh): void;
  21906. /**
  21907. * Binds the submesh to the material
  21908. * @param world defines the world transformation matrix
  21909. * @param mesh defines the mesh containing the submesh
  21910. * @param subMesh defines the submesh to bind the material to
  21911. */
  21912. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  21913. /**
  21914. * Binds the world matrix to the material
  21915. * @param world defines the world transformation matrix
  21916. */
  21917. bindOnlyWorldMatrix(world: Matrix): void;
  21918. /**
  21919. * Binds the scene's uniform buffer to the effect.
  21920. * @param effect defines the effect to bind to the scene uniform buffer
  21921. * @param sceneUbo defines the uniform buffer storing scene data
  21922. */
  21923. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  21924. /**
  21925. * Binds the view matrix to the effect
  21926. * @param effect defines the effect to bind the view matrix to
  21927. */
  21928. bindView(effect: Effect): void;
  21929. /**
  21930. * Binds the view projection matrix to the effect
  21931. * @param effect defines the effect to bind the view projection matrix to
  21932. */
  21933. bindViewProjection(effect: Effect): void;
  21934. /**
  21935. * Specifies if material alpha testing should be turned on for the mesh
  21936. * @param mesh defines the mesh to check
  21937. */
  21938. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  21939. /**
  21940. * Processes to execute after binding the material to a mesh
  21941. * @param mesh defines the rendered mesh
  21942. */
  21943. protected _afterBind(mesh?: Mesh): void;
  21944. /**
  21945. * Unbinds the material from the mesh
  21946. */
  21947. unbind(): void;
  21948. /**
  21949. * Gets the active textures from the material
  21950. * @returns an array of textures
  21951. */
  21952. getActiveTextures(): BaseTexture[];
  21953. /**
  21954. * Specifies if the material uses a texture
  21955. * @param texture defines the texture to check against the material
  21956. * @returns a boolean specifying if the material uses the texture
  21957. */
  21958. hasTexture(texture: BaseTexture): boolean;
  21959. /**
  21960. * Makes a duplicate of the material, and gives it a new name
  21961. * @param name defines the new name for the duplicated material
  21962. * @returns the cloned material
  21963. */
  21964. clone(name: string): Nullable<Material>;
  21965. /**
  21966. * Gets the meshes bound to the material
  21967. * @returns an array of meshes bound to the material
  21968. */
  21969. getBindedMeshes(): AbstractMesh[];
  21970. /**
  21971. * Force shader compilation
  21972. * @param mesh defines the mesh associated with this material
  21973. * @param onCompiled defines a function to execute once the material is compiled
  21974. * @param options defines the options to configure the compilation
  21975. */
  21976. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  21977. clipPlane: boolean;
  21978. }>): void;
  21979. /**
  21980. * Force shader compilation
  21981. * @param mesh defines the mesh that will use this material
  21982. * @param options defines additional options for compiling the shaders
  21983. * @returns a promise that resolves when the compilation completes
  21984. */
  21985. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  21986. clipPlane: boolean;
  21987. }>): Promise<void>;
  21988. private static readonly _ImageProcessingDirtyCallBack;
  21989. private static readonly _TextureDirtyCallBack;
  21990. private static readonly _FresnelDirtyCallBack;
  21991. private static readonly _MiscDirtyCallBack;
  21992. private static readonly _LightsDirtyCallBack;
  21993. private static readonly _AttributeDirtyCallBack;
  21994. private static _FresnelAndMiscDirtyCallBack;
  21995. private static _TextureAndMiscDirtyCallBack;
  21996. private static readonly _DirtyCallbackArray;
  21997. private static readonly _RunDirtyCallBacks;
  21998. /**
  21999. * Marks a define in the material to indicate that it needs to be re-computed
  22000. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  22001. */
  22002. markAsDirty(flag: number): void;
  22003. /**
  22004. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  22005. * @param func defines a function which checks material defines against the submeshes
  22006. */
  22007. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  22008. /**
  22009. * Indicates that image processing needs to be re-calculated for all submeshes
  22010. */
  22011. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  22012. /**
  22013. * Indicates that textures need to be re-calculated for all submeshes
  22014. */
  22015. protected _markAllSubMeshesAsTexturesDirty(): void;
  22016. /**
  22017. * Indicates that fresnel needs to be re-calculated for all submeshes
  22018. */
  22019. protected _markAllSubMeshesAsFresnelDirty(): void;
  22020. /**
  22021. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  22022. */
  22023. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  22024. /**
  22025. * Indicates that lights need to be re-calculated for all submeshes
  22026. */
  22027. protected _markAllSubMeshesAsLightsDirty(): void;
  22028. /**
  22029. * Indicates that attributes need to be re-calculated for all submeshes
  22030. */
  22031. protected _markAllSubMeshesAsAttributesDirty(): void;
  22032. /**
  22033. * Indicates that misc needs to be re-calculated for all submeshes
  22034. */
  22035. protected _markAllSubMeshesAsMiscDirty(): void;
  22036. /**
  22037. * Indicates that textures and misc need to be re-calculated for all submeshes
  22038. */
  22039. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  22040. /**
  22041. * Disposes the material
  22042. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  22043. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  22044. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  22045. */
  22046. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  22047. /** @hidden */
  22048. private releaseVertexArrayObject;
  22049. /**
  22050. * Serializes this material
  22051. * @returns the serialized material object
  22052. */
  22053. serialize(): any;
  22054. /**
  22055. * Creates a material from parsed material data
  22056. * @param parsedMaterial defines parsed material data
  22057. * @param scene defines the hosting scene
  22058. * @param rootUrl defines the root URL to use to load textures
  22059. * @returns a new material
  22060. */
  22061. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): any;
  22062. }
  22063. }
  22064. declare module "babylonjs/Meshes/subMesh" {
  22065. import { Nullable, IndicesArray, DeepImmutable } from "babylonjs/types";
  22066. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  22067. import { Engine } from "babylonjs/Engines/engine";
  22068. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  22069. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  22070. import { Effect } from "babylonjs/Materials/effect";
  22071. import { Collider } from "babylonjs/Collisions/collider";
  22072. import { Material } from "babylonjs/Materials/material";
  22073. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  22074. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22075. import { Mesh } from "babylonjs/Meshes/mesh";
  22076. import { Ray } from "babylonjs/Culling/ray";
  22077. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  22078. /**
  22079. * Base class for submeshes
  22080. */
  22081. export class BaseSubMesh {
  22082. /** @hidden */
  22083. _materialDefines: Nullable<MaterialDefines>;
  22084. /** @hidden */
  22085. _materialEffect: Nullable<Effect>;
  22086. /**
  22087. * Gets associated effect
  22088. */
  22089. readonly effect: Nullable<Effect>;
  22090. /**
  22091. * Sets associated effect (effect used to render this submesh)
  22092. * @param effect defines the effect to associate with
  22093. * @param defines defines the set of defines used to compile this effect
  22094. */
  22095. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  22096. }
  22097. /**
  22098. * Defines a subdivision inside a mesh
  22099. */
  22100. export class SubMesh extends BaseSubMesh implements ICullable {
  22101. /** the material index to use */
  22102. materialIndex: number;
  22103. /** vertex index start */
  22104. verticesStart: number;
  22105. /** vertices count */
  22106. verticesCount: number;
  22107. /** index start */
  22108. indexStart: number;
  22109. /** indices count */
  22110. indexCount: number;
  22111. /** @hidden */
  22112. _linesIndexCount: number;
  22113. private _mesh;
  22114. private _renderingMesh;
  22115. private _boundingInfo;
  22116. private _linesIndexBuffer;
  22117. /** @hidden */
  22118. _lastColliderWorldVertices: Nullable<Vector3[]>;
  22119. /** @hidden */
  22120. _trianglePlanes: Plane[];
  22121. /** @hidden */
  22122. _lastColliderTransformMatrix: Matrix;
  22123. /** @hidden */
  22124. _renderId: number;
  22125. /** @hidden */
  22126. _alphaIndex: number;
  22127. /** @hidden */
  22128. _distanceToCamera: number;
  22129. /** @hidden */
  22130. _id: number;
  22131. private _currentMaterial;
  22132. /**
  22133. * Add a new submesh to a mesh
  22134. * @param materialIndex defines the material index to use
  22135. * @param verticesStart defines vertex index start
  22136. * @param verticesCount defines vertices count
  22137. * @param indexStart defines index start
  22138. * @param indexCount defines indices count
  22139. * @param mesh defines the parent mesh
  22140. * @param renderingMesh defines an optional rendering mesh
  22141. * @param createBoundingBox defines if bounding box should be created for this submesh
  22142. * @returns the new submesh
  22143. */
  22144. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  22145. /**
  22146. * Creates a new submesh
  22147. * @param materialIndex defines the material index to use
  22148. * @param verticesStart defines vertex index start
  22149. * @param verticesCount defines vertices count
  22150. * @param indexStart defines index start
  22151. * @param indexCount defines indices count
  22152. * @param mesh defines the parent mesh
  22153. * @param renderingMesh defines an optional rendering mesh
  22154. * @param createBoundingBox defines if bounding box should be created for this submesh
  22155. */
  22156. constructor(
  22157. /** the material index to use */
  22158. materialIndex: number,
  22159. /** vertex index start */
  22160. verticesStart: number,
  22161. /** vertices count */
  22162. verticesCount: number,
  22163. /** index start */
  22164. indexStart: number,
  22165. /** indices count */
  22166. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  22167. /**
  22168. * Returns true if this submesh covers the entire parent mesh
  22169. * @ignorenaming
  22170. */
  22171. readonly IsGlobal: boolean;
  22172. /**
  22173. * Returns the submesh BoudingInfo object
  22174. * @returns current bounding info (or mesh's one if the submesh is global)
  22175. */
  22176. getBoundingInfo(): BoundingInfo;
  22177. /**
  22178. * Sets the submesh BoundingInfo
  22179. * @param boundingInfo defines the new bounding info to use
  22180. * @returns the SubMesh
  22181. */
  22182. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  22183. /**
  22184. * Returns the mesh of the current submesh
  22185. * @return the parent mesh
  22186. */
  22187. getMesh(): AbstractMesh;
  22188. /**
  22189. * Returns the rendering mesh of the submesh
  22190. * @returns the rendering mesh (could be different from parent mesh)
  22191. */
  22192. getRenderingMesh(): Mesh;
  22193. /**
  22194. * Returns the submesh material
  22195. * @returns null or the current material
  22196. */
  22197. getMaterial(): Nullable<Material>;
  22198. /**
  22199. * Sets a new updated BoundingInfo object to the submesh
  22200. * @returns the SubMesh
  22201. */
  22202. refreshBoundingInfo(): SubMesh;
  22203. /** @hidden */
  22204. _checkCollision(collider: Collider): boolean;
  22205. /**
  22206. * Updates the submesh BoundingInfo
  22207. * @param world defines the world matrix to use to update the bounding info
  22208. * @returns the submesh
  22209. */
  22210. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  22211. /**
  22212. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  22213. * @param frustumPlanes defines the frustum planes
  22214. * @returns true if the submesh is intersecting with the frustum
  22215. */
  22216. isInFrustum(frustumPlanes: Plane[]): boolean;
  22217. /**
  22218. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  22219. * @param frustumPlanes defines the frustum planes
  22220. * @returns true if the submesh is inside the frustum
  22221. */
  22222. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  22223. /**
  22224. * Renders the submesh
  22225. * @param enableAlphaMode defines if alpha needs to be used
  22226. * @returns the submesh
  22227. */
  22228. render(enableAlphaMode: boolean): SubMesh;
  22229. /**
  22230. * @hidden
  22231. */
  22232. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): WebGLBuffer;
  22233. /**
  22234. * Checks if the submesh intersects with a ray
  22235. * @param ray defines the ray to test
  22236. * @returns true is the passed ray intersects the submesh bounding box
  22237. */
  22238. canIntersects(ray: Ray): boolean;
  22239. /**
  22240. * Intersects current submesh with a ray
  22241. * @param ray defines the ray to test
  22242. * @param positions defines mesh's positions array
  22243. * @param indices defines mesh's indices array
  22244. * @param fastCheck defines if only bounding info should be used
  22245. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  22246. * @returns intersection info or null if no intersection
  22247. */
  22248. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  22249. /** @hidden */
  22250. private _intersectLines;
  22251. /** @hidden */
  22252. private _intersectTriangles;
  22253. /** @hidden */
  22254. _rebuild(): void;
  22255. /**
  22256. * Creates a new submesh from the passed mesh
  22257. * @param newMesh defines the new hosting mesh
  22258. * @param newRenderingMesh defines an optional rendering mesh
  22259. * @returns the new submesh
  22260. */
  22261. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  22262. /**
  22263. * Release associated resources
  22264. */
  22265. dispose(): void;
  22266. /**
  22267. * Gets the class name
  22268. * @returns the string "SubMesh".
  22269. */
  22270. getClassName(): string;
  22271. /**
  22272. * Creates a new submesh from indices data
  22273. * @param materialIndex the index of the main mesh material
  22274. * @param startIndex the index where to start the copy in the mesh indices array
  22275. * @param indexCount the number of indices to copy then from the startIndex
  22276. * @param mesh the main mesh to create the submesh from
  22277. * @param renderingMesh the optional rendering mesh
  22278. * @returns a new submesh
  22279. */
  22280. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  22281. }
  22282. }
  22283. declare module "babylonjs/Meshes/geometry" {
  22284. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  22285. import { Scene } from "babylonjs/scene";
  22286. import { Vector3, Vector2 } from "babylonjs/Maths/math";
  22287. import { Engine } from "babylonjs/Engines/engine";
  22288. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  22289. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  22290. import { Effect } from "babylonjs/Materials/effect";
  22291. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  22292. import { Mesh } from "babylonjs/Meshes/mesh";
  22293. /**
  22294. * Class used to store geometry data (vertex buffers + index buffer)
  22295. */
  22296. export class Geometry implements IGetSetVerticesData {
  22297. /**
  22298. * Gets or sets the ID of the geometry
  22299. */
  22300. id: string;
  22301. /**
  22302. * Gets or sets the unique ID of the geometry
  22303. */
  22304. uniqueId: number;
  22305. /**
  22306. * Gets the delay loading state of the geometry (none by default which means not delayed)
  22307. */
  22308. delayLoadState: number;
  22309. /**
  22310. * Gets the file containing the data to load when running in delay load state
  22311. */
  22312. delayLoadingFile: Nullable<string>;
  22313. /**
  22314. * Callback called when the geometry is updated
  22315. */
  22316. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  22317. private _scene;
  22318. private _engine;
  22319. private _meshes;
  22320. private _totalVertices;
  22321. /** @hidden */
  22322. _indices: IndicesArray;
  22323. /** @hidden */
  22324. _vertexBuffers: {
  22325. [key: string]: VertexBuffer;
  22326. };
  22327. private _isDisposed;
  22328. private _extend;
  22329. private _boundingBias;
  22330. /** @hidden */
  22331. _delayInfo: Array<string>;
  22332. private _indexBuffer;
  22333. private _indexBufferIsUpdatable;
  22334. /** @hidden */
  22335. _boundingInfo: Nullable<BoundingInfo>;
  22336. /** @hidden */
  22337. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  22338. /** @hidden */
  22339. _softwareSkinningFrameId: number;
  22340. private _vertexArrayObjects;
  22341. private _updatable;
  22342. /** @hidden */
  22343. _positions: Nullable<Vector3[]>;
  22344. /**
  22345. * 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
  22346. */
  22347. /**
  22348. * 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
  22349. */
  22350. boundingBias: Vector2;
  22351. /**
  22352. * Static function used to attach a new empty geometry to a mesh
  22353. * @param mesh defines the mesh to attach the geometry to
  22354. * @returns the new Geometry
  22355. */
  22356. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  22357. /**
  22358. * Creates a new geometry
  22359. * @param id defines the unique ID
  22360. * @param scene defines the hosting scene
  22361. * @param vertexData defines the VertexData used to get geometry data
  22362. * @param updatable defines if geometry must be updatable (false by default)
  22363. * @param mesh defines the mesh that will be associated with the geometry
  22364. */
  22365. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  22366. /**
  22367. * Gets the current extend of the geometry
  22368. */
  22369. readonly extend: {
  22370. minimum: Vector3;
  22371. maximum: Vector3;
  22372. };
  22373. /**
  22374. * Gets the hosting scene
  22375. * @returns the hosting Scene
  22376. */
  22377. getScene(): Scene;
  22378. /**
  22379. * Gets the hosting engine
  22380. * @returns the hosting Engine
  22381. */
  22382. getEngine(): Engine;
  22383. /**
  22384. * Defines if the geometry is ready to use
  22385. * @returns true if the geometry is ready to be used
  22386. */
  22387. isReady(): boolean;
  22388. /**
  22389. * Gets a value indicating that the geometry should not be serialized
  22390. */
  22391. readonly doNotSerialize: boolean;
  22392. /** @hidden */
  22393. _rebuild(): void;
  22394. /**
  22395. * Affects all geometry data in one call
  22396. * @param vertexData defines the geometry data
  22397. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  22398. */
  22399. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  22400. /**
  22401. * Set specific vertex data
  22402. * @param kind defines the data kind (Position, normal, etc...)
  22403. * @param data defines the vertex data to use
  22404. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22405. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22406. */
  22407. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  22408. /**
  22409. * Removes a specific vertex data
  22410. * @param kind defines the data kind (Position, normal, etc...)
  22411. */
  22412. removeVerticesData(kind: string): void;
  22413. /**
  22414. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  22415. * @param buffer defines the vertex buffer to use
  22416. * @param totalVertices defines the total number of vertices for position kind (could be null)
  22417. */
  22418. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  22419. /**
  22420. * Update a specific vertex buffer
  22421. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  22422. * It will do nothing if the buffer is not updatable
  22423. * @param kind defines the data kind (Position, normal, etc...)
  22424. * @param data defines the data to use
  22425. * @param offset defines the offset in the target buffer where to store the data
  22426. * @param useBytes set to true if the offset is in bytes
  22427. */
  22428. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  22429. /**
  22430. * Update a specific vertex buffer
  22431. * This function will create a new buffer if the current one is not updatable
  22432. * @param kind defines the data kind (Position, normal, etc...)
  22433. * @param data defines the data to use
  22434. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  22435. */
  22436. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  22437. private _updateBoundingInfo;
  22438. /** @hidden */
  22439. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<WebGLBuffer>): void;
  22440. /**
  22441. * Gets total number of vertices
  22442. * @returns the total number of vertices
  22443. */
  22444. getTotalVertices(): number;
  22445. /**
  22446. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22447. * @param kind defines the data kind (Position, normal, etc...)
  22448. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22449. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22450. * @returns a float array containing vertex data
  22451. */
  22452. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22453. /**
  22454. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  22455. * @param kind defines the data kind (Position, normal, etc...)
  22456. * @returns true if the vertex buffer with the specified kind is updatable
  22457. */
  22458. isVertexBufferUpdatable(kind: string): boolean;
  22459. /**
  22460. * Gets a specific vertex buffer
  22461. * @param kind defines the data kind (Position, normal, etc...)
  22462. * @returns a VertexBuffer
  22463. */
  22464. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  22465. /**
  22466. * Returns all vertex buffers
  22467. * @return an object holding all vertex buffers indexed by kind
  22468. */
  22469. getVertexBuffers(): Nullable<{
  22470. [key: string]: VertexBuffer;
  22471. }>;
  22472. /**
  22473. * Gets a boolean indicating if specific vertex buffer is present
  22474. * @param kind defines the data kind (Position, normal, etc...)
  22475. * @returns true if data is present
  22476. */
  22477. isVerticesDataPresent(kind: string): boolean;
  22478. /**
  22479. * Gets a list of all attached data kinds (Position, normal, etc...)
  22480. * @returns a list of string containing all kinds
  22481. */
  22482. getVerticesDataKinds(): string[];
  22483. /**
  22484. * Update index buffer
  22485. * @param indices defines the indices to store in the index buffer
  22486. * @param offset defines the offset in the target buffer where to store the data
  22487. */
  22488. updateIndices(indices: IndicesArray, offset?: number): void;
  22489. /**
  22490. * Creates a new index buffer
  22491. * @param indices defines the indices to store in the index buffer
  22492. * @param totalVertices defines the total number of vertices (could be null)
  22493. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22494. */
  22495. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  22496. /**
  22497. * Return the total number of indices
  22498. * @returns the total number of indices
  22499. */
  22500. getTotalIndices(): number;
  22501. /**
  22502. * Gets the index buffer array
  22503. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22504. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22505. * @returns the index buffer array
  22506. */
  22507. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22508. /**
  22509. * Gets the index buffer
  22510. * @return the index buffer
  22511. */
  22512. getIndexBuffer(): Nullable<WebGLBuffer>;
  22513. /** @hidden */
  22514. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  22515. /**
  22516. * Release the associated resources for a specific mesh
  22517. * @param mesh defines the source mesh
  22518. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  22519. */
  22520. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  22521. /**
  22522. * Apply current geometry to a given mesh
  22523. * @param mesh defines the mesh to apply geometry to
  22524. */
  22525. applyToMesh(mesh: Mesh): void;
  22526. private _updateExtend;
  22527. private _applyToMesh;
  22528. private notifyUpdate;
  22529. /**
  22530. * Load the geometry if it was flagged as delay loaded
  22531. * @param scene defines the hosting scene
  22532. * @param onLoaded defines a callback called when the geometry is loaded
  22533. */
  22534. load(scene: Scene, onLoaded?: () => void): void;
  22535. private _queueLoad;
  22536. /**
  22537. * Invert the geometry to move from a right handed system to a left handed one.
  22538. */
  22539. toLeftHanded(): void;
  22540. /** @hidden */
  22541. _resetPointsArrayCache(): void;
  22542. /** @hidden */
  22543. _generatePointsArray(): boolean;
  22544. /**
  22545. * Gets a value indicating if the geometry is disposed
  22546. * @returns true if the geometry was disposed
  22547. */
  22548. isDisposed(): boolean;
  22549. private _disposeVertexArrayObjects;
  22550. /**
  22551. * Free all associated resources
  22552. */
  22553. dispose(): void;
  22554. /**
  22555. * Clone the current geometry into a new geometry
  22556. * @param id defines the unique ID of the new geometry
  22557. * @returns a new geometry object
  22558. */
  22559. copy(id: string): Geometry;
  22560. /**
  22561. * Serialize the current geometry info (and not the vertices data) into a JSON object
  22562. * @return a JSON representation of the current geometry data (without the vertices data)
  22563. */
  22564. serialize(): any;
  22565. private toNumberArray;
  22566. /**
  22567. * Serialize all vertices data into a JSON oject
  22568. * @returns a JSON representation of the current geometry data
  22569. */
  22570. serializeVerticeData(): any;
  22571. /**
  22572. * Extracts a clone of a mesh geometry
  22573. * @param mesh defines the source mesh
  22574. * @param id defines the unique ID of the new geometry object
  22575. * @returns the new geometry object
  22576. */
  22577. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  22578. /**
  22579. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  22580. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  22581. * Be aware Math.random() could cause collisions, but:
  22582. * "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"
  22583. * @returns a string containing a new GUID
  22584. */
  22585. static RandomId(): string;
  22586. /** @hidden */
  22587. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  22588. private static _CleanMatricesWeights;
  22589. /**
  22590. * Create a new geometry from persisted data (Using .babylon file format)
  22591. * @param parsedVertexData defines the persisted data
  22592. * @param scene defines the hosting scene
  22593. * @param rootUrl defines the root url to use to load assets (like delayed data)
  22594. * @returns the new geometry object
  22595. */
  22596. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  22597. }
  22598. }
  22599. declare module "babylonjs/Meshes/mesh.vertexData" {
  22600. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  22601. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  22602. import { Geometry } from "babylonjs/Meshes/geometry";
  22603. import { Mesh } from "babylonjs/Meshes/mesh";
  22604. /**
  22605. * Define an interface for all classes that will get and set the data on vertices
  22606. */
  22607. export interface IGetSetVerticesData {
  22608. /**
  22609. * Gets a boolean indicating if specific vertex data is present
  22610. * @param kind defines the vertex data kind to use
  22611. * @returns true is data kind is present
  22612. */
  22613. isVerticesDataPresent(kind: string): boolean;
  22614. /**
  22615. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22616. * @param kind defines the data kind (Position, normal, etc...)
  22617. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22618. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22619. * @returns a float array containing vertex data
  22620. */
  22621. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22622. /**
  22623. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  22624. * @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.
  22625. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22626. * @returns the indices array or an empty array if the mesh has no geometry
  22627. */
  22628. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22629. /**
  22630. * Set specific vertex data
  22631. * @param kind defines the data kind (Position, normal, etc...)
  22632. * @param data defines the vertex data to use
  22633. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22634. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22635. */
  22636. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  22637. /**
  22638. * Update a specific associated vertex buffer
  22639. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  22640. * - VertexBuffer.PositionKind
  22641. * - VertexBuffer.UVKind
  22642. * - VertexBuffer.UV2Kind
  22643. * - VertexBuffer.UV3Kind
  22644. * - VertexBuffer.UV4Kind
  22645. * - VertexBuffer.UV5Kind
  22646. * - VertexBuffer.UV6Kind
  22647. * - VertexBuffer.ColorKind
  22648. * - VertexBuffer.MatricesIndicesKind
  22649. * - VertexBuffer.MatricesIndicesExtraKind
  22650. * - VertexBuffer.MatricesWeightsKind
  22651. * - VertexBuffer.MatricesWeightsExtraKind
  22652. * @param data defines the data source
  22653. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  22654. * @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)
  22655. */
  22656. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  22657. /**
  22658. * Creates a new index buffer
  22659. * @param indices defines the indices to store in the index buffer
  22660. * @param totalVertices defines the total number of vertices (could be null)
  22661. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22662. */
  22663. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  22664. }
  22665. /**
  22666. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  22667. */
  22668. export class VertexData {
  22669. /**
  22670. * Mesh side orientation : usually the external or front surface
  22671. */
  22672. static readonly FRONTSIDE: number;
  22673. /**
  22674. * Mesh side orientation : usually the internal or back surface
  22675. */
  22676. static readonly BACKSIDE: number;
  22677. /**
  22678. * Mesh side orientation : both internal and external or front and back surfaces
  22679. */
  22680. static readonly DOUBLESIDE: number;
  22681. /**
  22682. * Mesh side orientation : by default, `FRONTSIDE`
  22683. */
  22684. static readonly DEFAULTSIDE: number;
  22685. /**
  22686. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  22687. */
  22688. positions: Nullable<FloatArray>;
  22689. /**
  22690. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  22691. */
  22692. normals: Nullable<FloatArray>;
  22693. /**
  22694. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  22695. */
  22696. tangents: Nullable<FloatArray>;
  22697. /**
  22698. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22699. */
  22700. uvs: Nullable<FloatArray>;
  22701. /**
  22702. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22703. */
  22704. uvs2: Nullable<FloatArray>;
  22705. /**
  22706. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22707. */
  22708. uvs3: Nullable<FloatArray>;
  22709. /**
  22710. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22711. */
  22712. uvs4: Nullable<FloatArray>;
  22713. /**
  22714. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22715. */
  22716. uvs5: Nullable<FloatArray>;
  22717. /**
  22718. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22719. */
  22720. uvs6: Nullable<FloatArray>;
  22721. /**
  22722. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  22723. */
  22724. colors: Nullable<FloatArray>;
  22725. /**
  22726. * 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).
  22727. */
  22728. matricesIndices: Nullable<FloatArray>;
  22729. /**
  22730. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  22731. */
  22732. matricesWeights: Nullable<FloatArray>;
  22733. /**
  22734. * An array extending the number of possible indices
  22735. */
  22736. matricesIndicesExtra: Nullable<FloatArray>;
  22737. /**
  22738. * An array extending the number of possible weights when the number of indices is extended
  22739. */
  22740. matricesWeightsExtra: Nullable<FloatArray>;
  22741. /**
  22742. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  22743. */
  22744. indices: Nullable<IndicesArray>;
  22745. /**
  22746. * Uses the passed data array to set the set the values for the specified kind of data
  22747. * @param data a linear array of floating numbers
  22748. * @param kind the type of data that is being set, eg positions, colors etc
  22749. */
  22750. set(data: FloatArray, kind: string): void;
  22751. /**
  22752. * Associates the vertexData to the passed Mesh.
  22753. * Sets it as updatable or not (default `false`)
  22754. * @param mesh the mesh the vertexData is applied to
  22755. * @param updatable when used and having the value true allows new data to update the vertexData
  22756. * @returns the VertexData
  22757. */
  22758. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  22759. /**
  22760. * Associates the vertexData to the passed Geometry.
  22761. * Sets it as updatable or not (default `false`)
  22762. * @param geometry the geometry the vertexData is applied to
  22763. * @param updatable when used and having the value true allows new data to update the vertexData
  22764. * @returns VertexData
  22765. */
  22766. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  22767. /**
  22768. * Updates the associated mesh
  22769. * @param mesh the mesh to be updated
  22770. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22771. * @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
  22772. * @returns VertexData
  22773. */
  22774. updateMesh(mesh: Mesh): VertexData;
  22775. /**
  22776. * Updates the associated geometry
  22777. * @param geometry the geometry to be updated
  22778. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22779. * @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
  22780. * @returns VertexData.
  22781. */
  22782. updateGeometry(geometry: Geometry): VertexData;
  22783. private _applyTo;
  22784. private _update;
  22785. /**
  22786. * Transforms each position and each normal of the vertexData according to the passed Matrix
  22787. * @param matrix the transforming matrix
  22788. * @returns the VertexData
  22789. */
  22790. transform(matrix: Matrix): VertexData;
  22791. /**
  22792. * Merges the passed VertexData into the current one
  22793. * @param other the VertexData to be merged into the current one
  22794. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  22795. * @returns the modified VertexData
  22796. */
  22797. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  22798. private _mergeElement;
  22799. private _validate;
  22800. /**
  22801. * Serializes the VertexData
  22802. * @returns a serialized object
  22803. */
  22804. serialize(): any;
  22805. /**
  22806. * Extracts the vertexData from a mesh
  22807. * @param mesh the mesh from which to extract the VertexData
  22808. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  22809. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22810. * @returns the object VertexData associated to the passed mesh
  22811. */
  22812. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22813. /**
  22814. * Extracts the vertexData from the geometry
  22815. * @param geometry the geometry from which to extract the VertexData
  22816. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22817. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22818. * @returns the object VertexData associated to the passed mesh
  22819. */
  22820. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22821. private static _ExtractFrom;
  22822. /**
  22823. * Creates the VertexData for a Ribbon
  22824. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22825. * * pathArray array of paths, each of which an array of successive Vector3
  22826. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  22827. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  22828. * * 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
  22829. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22830. * * 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)
  22831. * * 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)
  22832. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  22833. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  22834. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  22835. * @returns the VertexData of the ribbon
  22836. */
  22837. static CreateRibbon(options: {
  22838. pathArray: Vector3[][];
  22839. closeArray?: boolean;
  22840. closePath?: boolean;
  22841. offset?: number;
  22842. sideOrientation?: number;
  22843. frontUVs?: Vector4;
  22844. backUVs?: Vector4;
  22845. invertUV?: boolean;
  22846. uvs?: Vector2[];
  22847. colors?: Color4[];
  22848. }): VertexData;
  22849. /**
  22850. * Creates the VertexData for a box
  22851. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22852. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22853. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22854. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22855. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22856. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22857. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22858. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22859. * * 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)
  22860. * * 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)
  22861. * @returns the VertexData of the box
  22862. */
  22863. static CreateBox(options: {
  22864. size?: number;
  22865. width?: number;
  22866. height?: number;
  22867. depth?: number;
  22868. faceUV?: Vector4[];
  22869. faceColors?: Color4[];
  22870. sideOrientation?: number;
  22871. frontUVs?: Vector4;
  22872. backUVs?: Vector4;
  22873. }): VertexData;
  22874. /**
  22875. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22876. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22877. * * segments sets the number of horizontal strips optional, default 32
  22878. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22879. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22880. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22881. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22882. * * 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
  22883. * * 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
  22884. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22885. * * 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)
  22886. * * 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)
  22887. * @returns the VertexData of the ellipsoid
  22888. */
  22889. static CreateSphere(options: {
  22890. segments?: number;
  22891. diameter?: number;
  22892. diameterX?: number;
  22893. diameterY?: number;
  22894. diameterZ?: number;
  22895. arc?: number;
  22896. slice?: number;
  22897. sideOrientation?: number;
  22898. frontUVs?: Vector4;
  22899. backUVs?: Vector4;
  22900. }): VertexData;
  22901. /**
  22902. * Creates the VertexData for a cylinder, cone or prism
  22903. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22904. * * height sets the height (y direction) of the cylinder, optional, default 2
  22905. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22906. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22907. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22908. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22909. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22910. * * 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
  22911. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22912. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22913. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22914. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22915. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22916. * * 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)
  22917. * * 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)
  22918. * @returns the VertexData of the cylinder, cone or prism
  22919. */
  22920. static CreateCylinder(options: {
  22921. height?: number;
  22922. diameterTop?: number;
  22923. diameterBottom?: number;
  22924. diameter?: number;
  22925. tessellation?: number;
  22926. subdivisions?: number;
  22927. arc?: number;
  22928. faceColors?: Color4[];
  22929. faceUV?: Vector4[];
  22930. hasRings?: boolean;
  22931. enclose?: boolean;
  22932. sideOrientation?: number;
  22933. frontUVs?: Vector4;
  22934. backUVs?: Vector4;
  22935. }): VertexData;
  22936. /**
  22937. * Creates the VertexData for a torus
  22938. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22939. * * diameter the diameter of the torus, optional default 1
  22940. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22941. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22942. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22943. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  22944. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  22945. * @returns the VertexData of the torus
  22946. */
  22947. static CreateTorus(options: {
  22948. diameter?: number;
  22949. thickness?: number;
  22950. tessellation?: number;
  22951. sideOrientation?: number;
  22952. frontUVs?: Vector4;
  22953. backUVs?: Vector4;
  22954. }): VertexData;
  22955. /**
  22956. * Creates the VertexData of the LineSystem
  22957. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22958. * - lines an array of lines, each line being an array of successive Vector3
  22959. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22960. * @returns the VertexData of the LineSystem
  22961. */
  22962. static CreateLineSystem(options: {
  22963. lines: Vector3[][];
  22964. colors?: Nullable<Color4[][]>;
  22965. }): VertexData;
  22966. /**
  22967. * Create the VertexData for a DashedLines
  22968. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22969. * - points an array successive Vector3
  22970. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22971. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22972. * - dashNb the intended total number of dashes, optional, default 200
  22973. * @returns the VertexData for the DashedLines
  22974. */
  22975. static CreateDashedLines(options: {
  22976. points: Vector3[];
  22977. dashSize?: number;
  22978. gapSize?: number;
  22979. dashNb?: number;
  22980. }): VertexData;
  22981. /**
  22982. * Creates the VertexData for a Ground
  22983. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22984. * - width the width (x direction) of the ground, optional, default 1
  22985. * - height the height (z direction) of the ground, optional, default 1
  22986. * - subdivisions the number of subdivisions per side, optional, default 1
  22987. * @returns the VertexData of the Ground
  22988. */
  22989. static CreateGround(options: {
  22990. width?: number;
  22991. height?: number;
  22992. subdivisions?: number;
  22993. subdivisionsX?: number;
  22994. subdivisionsY?: number;
  22995. }): VertexData;
  22996. /**
  22997. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  22998. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22999. * * xmin the ground minimum X coordinate, optional, default -1
  23000. * * zmin the ground minimum Z coordinate, optional, default -1
  23001. * * xmax the ground maximum X coordinate, optional, default 1
  23002. * * zmax the ground maximum Z coordinate, optional, default 1
  23003. * * 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}
  23004. * * 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}
  23005. * @returns the VertexData of the TiledGround
  23006. */
  23007. static CreateTiledGround(options: {
  23008. xmin: number;
  23009. zmin: number;
  23010. xmax: number;
  23011. zmax: number;
  23012. subdivisions?: {
  23013. w: number;
  23014. h: number;
  23015. };
  23016. precision?: {
  23017. w: number;
  23018. h: number;
  23019. };
  23020. }): VertexData;
  23021. /**
  23022. * Creates the VertexData of the Ground designed from a heightmap
  23023. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  23024. * * width the width (x direction) of the ground
  23025. * * height the height (z direction) of the ground
  23026. * * subdivisions the number of subdivisions per side
  23027. * * minHeight the minimum altitude on the ground, optional, default 0
  23028. * * maxHeight the maximum altitude on the ground, optional default 1
  23029. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  23030. * * buffer the array holding the image color data
  23031. * * bufferWidth the width of image
  23032. * * bufferHeight the height of image
  23033. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  23034. * @returns the VertexData of the Ground designed from a heightmap
  23035. */
  23036. static CreateGroundFromHeightMap(options: {
  23037. width: number;
  23038. height: number;
  23039. subdivisions: number;
  23040. minHeight: number;
  23041. maxHeight: number;
  23042. colorFilter: Color3;
  23043. buffer: Uint8Array;
  23044. bufferWidth: number;
  23045. bufferHeight: number;
  23046. alphaFilter: number;
  23047. }): VertexData;
  23048. /**
  23049. * Creates the VertexData for a Plane
  23050. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  23051. * * size sets the width and height of the plane to the value of size, optional default 1
  23052. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  23053. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  23054. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23055. * * 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)
  23056. * * 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)
  23057. * @returns the VertexData of the box
  23058. */
  23059. static CreatePlane(options: {
  23060. size?: number;
  23061. width?: number;
  23062. height?: number;
  23063. sideOrientation?: number;
  23064. frontUVs?: Vector4;
  23065. backUVs?: Vector4;
  23066. }): VertexData;
  23067. /**
  23068. * Creates the VertexData of the Disc or regular Polygon
  23069. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  23070. * * radius the radius of the disc, optional default 0.5
  23071. * * tessellation the number of polygon sides, optional, default 64
  23072. * * 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
  23073. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23074. * * 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)
  23075. * * 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)
  23076. * @returns the VertexData of the box
  23077. */
  23078. static CreateDisc(options: {
  23079. radius?: number;
  23080. tessellation?: number;
  23081. arc?: number;
  23082. sideOrientation?: number;
  23083. frontUVs?: Vector4;
  23084. backUVs?: Vector4;
  23085. }): VertexData;
  23086. /**
  23087. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  23088. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  23089. * @param polygon a mesh built from polygonTriangulation.build()
  23090. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23091. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23092. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23093. * @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)
  23094. * @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)
  23095. * @returns the VertexData of the Polygon
  23096. */
  23097. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  23098. /**
  23099. * Creates the VertexData of the IcoSphere
  23100. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  23101. * * radius the radius of the IcoSphere, optional default 1
  23102. * * radiusX allows stretching in the x direction, optional, default radius
  23103. * * radiusY allows stretching in the y direction, optional, default radius
  23104. * * radiusZ allows stretching in the z direction, optional, default radius
  23105. * * flat when true creates a flat shaded mesh, optional, default true
  23106. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23107. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23108. * * 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)
  23109. * * 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)
  23110. * @returns the VertexData of the IcoSphere
  23111. */
  23112. static CreateIcoSphere(options: {
  23113. radius?: number;
  23114. radiusX?: number;
  23115. radiusY?: number;
  23116. radiusZ?: number;
  23117. flat?: boolean;
  23118. subdivisions?: number;
  23119. sideOrientation?: number;
  23120. frontUVs?: Vector4;
  23121. backUVs?: Vector4;
  23122. }): VertexData;
  23123. /**
  23124. * Creates the VertexData for a Polyhedron
  23125. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  23126. * * type provided types are:
  23127. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  23128. * * 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)
  23129. * * size the size of the IcoSphere, optional default 1
  23130. * * sizeX allows stretching in the x direction, optional, default size
  23131. * * sizeY allows stretching in the y direction, optional, default size
  23132. * * sizeZ allows stretching in the z direction, optional, default size
  23133. * * 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
  23134. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23135. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23136. * * flat when true creates a flat shaded mesh, optional, default true
  23137. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23138. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23139. * * 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)
  23140. * * 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)
  23141. * @returns the VertexData of the Polyhedron
  23142. */
  23143. static CreatePolyhedron(options: {
  23144. type?: number;
  23145. size?: number;
  23146. sizeX?: number;
  23147. sizeY?: number;
  23148. sizeZ?: number;
  23149. custom?: any;
  23150. faceUV?: Vector4[];
  23151. faceColors?: Color4[];
  23152. flat?: boolean;
  23153. sideOrientation?: number;
  23154. frontUVs?: Vector4;
  23155. backUVs?: Vector4;
  23156. }): VertexData;
  23157. /**
  23158. * Creates the VertexData for a TorusKnot
  23159. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  23160. * * radius the radius of the torus knot, optional, default 2
  23161. * * tube the thickness of the tube, optional, default 0.5
  23162. * * radialSegments the number of sides on each tube segments, optional, default 32
  23163. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  23164. * * p the number of windings around the z axis, optional, default 2
  23165. * * q the number of windings around the x axis, optional, default 3
  23166. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23167. * * 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)
  23168. * * 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)
  23169. * @returns the VertexData of the Torus Knot
  23170. */
  23171. static CreateTorusKnot(options: {
  23172. radius?: number;
  23173. tube?: number;
  23174. radialSegments?: number;
  23175. tubularSegments?: number;
  23176. p?: number;
  23177. q?: number;
  23178. sideOrientation?: number;
  23179. frontUVs?: Vector4;
  23180. backUVs?: Vector4;
  23181. }): VertexData;
  23182. /**
  23183. * Compute normals for given positions and indices
  23184. * @param positions an array of vertex positions, [...., x, y, z, ......]
  23185. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  23186. * @param normals an array of vertex normals, [...., x, y, z, ......]
  23187. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  23188. * * facetNormals : optional array of facet normals (vector3)
  23189. * * facetPositions : optional array of facet positions (vector3)
  23190. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  23191. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  23192. * * bInfo : optional bounding info, required for facetPartitioning computation
  23193. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  23194. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  23195. * * useRightHandedSystem: optional boolean to for right handed system computation
  23196. * * depthSort : optional boolean to enable the facet depth sort computation
  23197. * * distanceTo : optional Vector3 to compute the facet depth from this location
  23198. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  23199. */
  23200. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  23201. facetNormals?: any;
  23202. facetPositions?: any;
  23203. facetPartitioning?: any;
  23204. ratio?: number;
  23205. bInfo?: any;
  23206. bbSize?: Vector3;
  23207. subDiv?: any;
  23208. useRightHandedSystem?: boolean;
  23209. depthSort?: boolean;
  23210. distanceTo?: Vector3;
  23211. depthSortedFacets?: any;
  23212. }): void;
  23213. /** @hidden */
  23214. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  23215. /**
  23216. * Applies VertexData created from the imported parameters to the geometry
  23217. * @param parsedVertexData the parsed data from an imported file
  23218. * @param geometry the geometry to apply the VertexData to
  23219. */
  23220. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  23221. }
  23222. }
  23223. declare module "babylonjs/Meshes/Builders/discBuilder" {
  23224. import { Nullable } from "babylonjs/types";
  23225. import { Scene } from "babylonjs/scene";
  23226. import { Vector4 } from "babylonjs/Maths/math";
  23227. import { Mesh } from "babylonjs/Meshes/mesh";
  23228. /**
  23229. * Class containing static functions to help procedurally build meshes
  23230. */
  23231. export class DiscBuilder {
  23232. /**
  23233. * Creates a plane polygonal mesh. By default, this is a disc
  23234. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  23235. * * 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
  23236. * * 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
  23237. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23238. * * If you create a double-sided mesh, you can choose what parts of 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
  23239. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23240. * @param name defines the name of the mesh
  23241. * @param options defines the options used to create the mesh
  23242. * @param scene defines the hosting scene
  23243. * @returns the plane polygonal mesh
  23244. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  23245. */
  23246. static CreateDisc(name: string, options: {
  23247. radius?: number;
  23248. tessellation?: number;
  23249. arc?: number;
  23250. updatable?: boolean;
  23251. sideOrientation?: number;
  23252. frontUVs?: Vector4;
  23253. backUVs?: Vector4;
  23254. }, scene?: Nullable<Scene>): Mesh;
  23255. }
  23256. }
  23257. declare module "babylonjs/Particles/solidParticleSystem" {
  23258. import { Vector3 } from "babylonjs/Maths/math";
  23259. import { Mesh } from "babylonjs/Meshes/mesh";
  23260. import { Scene, IDisposable } from "babylonjs/scene";
  23261. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  23262. /**
  23263. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  23264. *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.
  23265. * The SPS is also a particle system. It provides some methods to manage the particles.
  23266. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  23267. *
  23268. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  23269. */
  23270. export class SolidParticleSystem implements IDisposable {
  23271. /**
  23272. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  23273. * Example : var p = SPS.particles[i];
  23274. */
  23275. particles: SolidParticle[];
  23276. /**
  23277. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  23278. */
  23279. nbParticles: number;
  23280. /**
  23281. * If the particles must ever face the camera (default false). Useful for planar particles.
  23282. */
  23283. billboard: boolean;
  23284. /**
  23285. * Recompute normals when adding a shape
  23286. */
  23287. recomputeNormals: boolean;
  23288. /**
  23289. * This a counter ofr your own usage. It's not set by any SPS functions.
  23290. */
  23291. counter: number;
  23292. /**
  23293. * The SPS name. This name is also given to the underlying mesh.
  23294. */
  23295. name: string;
  23296. /**
  23297. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  23298. */
  23299. mesh: Mesh;
  23300. /**
  23301. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  23302. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  23303. */
  23304. vars: any;
  23305. /**
  23306. * This array is populated when the SPS is set as 'pickable'.
  23307. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  23308. * Each element of this array is an object `{idx: int, faceId: int}`.
  23309. * `idx` is the picked particle index in the `SPS.particles` array
  23310. * `faceId` is the picked face index counted within this particle.
  23311. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  23312. */
  23313. pickedParticles: {
  23314. idx: number;
  23315. faceId: number;
  23316. }[];
  23317. /**
  23318. * This array is populated when `enableDepthSort` is set to true.
  23319. * Each element of this array is an instance of the class DepthSortedParticle.
  23320. */
  23321. depthSortedParticles: DepthSortedParticle[];
  23322. /**
  23323. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  23324. * @hidden
  23325. */
  23326. _bSphereOnly: boolean;
  23327. /**
  23328. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  23329. * @hidden
  23330. */
  23331. _bSphereRadiusFactor: number;
  23332. private _scene;
  23333. private _positions;
  23334. private _indices;
  23335. private _normals;
  23336. private _colors;
  23337. private _uvs;
  23338. private _indices32;
  23339. private _positions32;
  23340. private _normals32;
  23341. private _fixedNormal32;
  23342. private _colors32;
  23343. private _uvs32;
  23344. private _index;
  23345. private _updatable;
  23346. private _pickable;
  23347. private _isVisibilityBoxLocked;
  23348. private _alwaysVisible;
  23349. private _depthSort;
  23350. private _shapeCounter;
  23351. private _copy;
  23352. private _color;
  23353. private _computeParticleColor;
  23354. private _computeParticleTexture;
  23355. private _computeParticleRotation;
  23356. private _computeParticleVertex;
  23357. private _computeBoundingBox;
  23358. private _depthSortParticles;
  23359. private _camera;
  23360. private _mustUnrotateFixedNormals;
  23361. private _particlesIntersect;
  23362. private _needs32Bits;
  23363. /**
  23364. * Creates a SPS (Solid Particle System) object.
  23365. * @param name (String) is the SPS name, this will be the underlying mesh name.
  23366. * @param scene (Scene) is the scene in which the SPS is added.
  23367. * @param options defines the options of the sps e.g.
  23368. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  23369. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  23370. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  23371. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  23372. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  23373. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  23374. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  23375. */
  23376. constructor(name: string, scene: Scene, options?: {
  23377. updatable?: boolean;
  23378. isPickable?: boolean;
  23379. enableDepthSort?: boolean;
  23380. particleIntersection?: boolean;
  23381. boundingSphereOnly?: boolean;
  23382. bSphereRadiusFactor?: number;
  23383. });
  23384. /**
  23385. * Builds the SPS underlying mesh. Returns a standard Mesh.
  23386. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  23387. * @returns the created mesh
  23388. */
  23389. buildMesh(): Mesh;
  23390. /**
  23391. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  23392. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  23393. * Thus the particles generated from `digest()` have their property `position` set yet.
  23394. * @param mesh ( Mesh ) is the mesh to be digested
  23395. * @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
  23396. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  23397. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  23398. * @returns the current SPS
  23399. */
  23400. digest(mesh: Mesh, options?: {
  23401. facetNb?: number;
  23402. number?: number;
  23403. delta?: number;
  23404. }): SolidParticleSystem;
  23405. private _unrotateFixedNormals;
  23406. private _resetCopy;
  23407. private _meshBuilder;
  23408. private _posToShape;
  23409. private _uvsToShapeUV;
  23410. private _addParticle;
  23411. /**
  23412. * Adds some particles to the SPS from the model shape. Returns the shape id.
  23413. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  23414. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  23415. * @param nb (positive integer) the number of particles to be created from this model
  23416. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  23417. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  23418. * @returns the number of shapes in the system
  23419. */
  23420. addShape(mesh: Mesh, nb: number, options?: {
  23421. positionFunction?: any;
  23422. vertexFunction?: any;
  23423. }): number;
  23424. private _rebuildParticle;
  23425. /**
  23426. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  23427. * @returns the SPS.
  23428. */
  23429. rebuildMesh(): SolidParticleSystem;
  23430. /**
  23431. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  23432. * This method calls `updateParticle()` for each particle of the SPS.
  23433. * For an animated SPS, it is usually called within the render loop.
  23434. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  23435. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  23436. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  23437. * @returns the SPS.
  23438. */
  23439. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  23440. /**
  23441. * Disposes the SPS.
  23442. */
  23443. dispose(): void;
  23444. /**
  23445. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  23446. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23447. * @returns the SPS.
  23448. */
  23449. refreshVisibleSize(): SolidParticleSystem;
  23450. /**
  23451. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  23452. * @param size the size (float) of the visibility box
  23453. * note : this doesn't lock the SPS mesh bounding box.
  23454. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23455. */
  23456. setVisibilityBox(size: number): void;
  23457. /**
  23458. * Gets whether the SPS as always visible or not
  23459. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23460. */
  23461. /**
  23462. * Sets the SPS as always visible or not
  23463. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23464. */
  23465. isAlwaysVisible: boolean;
  23466. /**
  23467. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  23468. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23469. */
  23470. /**
  23471. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  23472. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23473. */
  23474. isVisibilityBoxLocked: boolean;
  23475. /**
  23476. * Tells to `setParticles()` to compute the particle rotations or not.
  23477. * Default value : true. The SPS is faster when it's set to false.
  23478. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  23479. */
  23480. /**
  23481. * Gets if `setParticles()` computes the particle rotations or not.
  23482. * Default value : true. The SPS is faster when it's set to false.
  23483. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  23484. */
  23485. computeParticleRotation: boolean;
  23486. /**
  23487. * Tells to `setParticles()` to compute the particle colors or not.
  23488. * Default value : true. The SPS is faster when it's set to false.
  23489. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  23490. */
  23491. /**
  23492. * Gets if `setParticles()` computes the particle colors or not.
  23493. * Default value : true. The SPS is faster when it's set to false.
  23494. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  23495. */
  23496. computeParticleColor: boolean;
  23497. /**
  23498. * Gets if `setParticles()` computes the particle textures or not.
  23499. * Default value : true. The SPS is faster when it's set to false.
  23500. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  23501. */
  23502. computeParticleTexture: boolean;
  23503. /**
  23504. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  23505. * Default value : false. The SPS is faster when it's set to false.
  23506. * Note : the particle custom vertex positions aren't stored values.
  23507. */
  23508. /**
  23509. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  23510. * Default value : false. The SPS is faster when it's set to false.
  23511. * Note : the particle custom vertex positions aren't stored values.
  23512. */
  23513. computeParticleVertex: boolean;
  23514. /**
  23515. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  23516. */
  23517. /**
  23518. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  23519. */
  23520. computeBoundingBox: boolean;
  23521. /**
  23522. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  23523. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  23524. * Default : `true`
  23525. */
  23526. /**
  23527. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  23528. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  23529. * Default : `true`
  23530. */
  23531. depthSortParticles: boolean;
  23532. /**
  23533. * This function does nothing. It may be overwritten to set all the particle first values.
  23534. * The SPS doesn't call this function, you may have to call it by your own.
  23535. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  23536. */
  23537. initParticles(): void;
  23538. /**
  23539. * This function does nothing. It may be overwritten to recycle a particle.
  23540. * The SPS doesn't call this function, you may have to call it by your own.
  23541. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  23542. * @param particle The particle to recycle
  23543. * @returns the recycled particle
  23544. */
  23545. recycleParticle(particle: SolidParticle): SolidParticle;
  23546. /**
  23547. * Updates a particle : this function should be overwritten by the user.
  23548. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  23549. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  23550. * @example : just set a particle position or velocity and recycle conditions
  23551. * @param particle The particle to update
  23552. * @returns the updated particle
  23553. */
  23554. updateParticle(particle: SolidParticle): SolidParticle;
  23555. /**
  23556. * Updates a vertex of a particle : it can be overwritten by the user.
  23557. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  23558. * @param particle the current particle
  23559. * @param vertex the current index of the current particle
  23560. * @param pt the index of the current vertex in the particle shape
  23561. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  23562. * @example : just set a vertex particle position
  23563. * @returns the updated vertex
  23564. */
  23565. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  23566. /**
  23567. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  23568. * This does nothing and may be overwritten by the user.
  23569. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23570. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23571. * @param update the boolean update value actually passed to setParticles()
  23572. */
  23573. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  23574. /**
  23575. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  23576. * This will be passed three parameters.
  23577. * This does nothing and may be overwritten by the user.
  23578. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23579. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23580. * @param update the boolean update value actually passed to setParticles()
  23581. */
  23582. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  23583. }
  23584. }
  23585. declare module "babylonjs/Particles/solidParticle" {
  23586. import { Nullable } from "babylonjs/types";
  23587. import { Color4, Vector3, Matrix, Quaternion, Vector4, Plane } from "babylonjs/Maths/math";
  23588. import { Mesh } from "babylonjs/Meshes/mesh";
  23589. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  23590. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  23591. /**
  23592. * Represents one particle of a solid particle system.
  23593. */
  23594. export class SolidParticle {
  23595. /**
  23596. * particle global index
  23597. */
  23598. idx: number;
  23599. /**
  23600. * The color of the particle
  23601. */
  23602. color: Nullable<Color4>;
  23603. /**
  23604. * The world space position of the particle.
  23605. */
  23606. position: Vector3;
  23607. /**
  23608. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  23609. */
  23610. rotation: Vector3;
  23611. /**
  23612. * The world space rotation quaternion of the particle.
  23613. */
  23614. rotationQuaternion: Nullable<Quaternion>;
  23615. /**
  23616. * The scaling of the particle.
  23617. */
  23618. scaling: Vector3;
  23619. /**
  23620. * The uvs of the particle.
  23621. */
  23622. uvs: Vector4;
  23623. /**
  23624. * The current speed of the particle.
  23625. */
  23626. velocity: Vector3;
  23627. /**
  23628. * The pivot point in the particle local space.
  23629. */
  23630. pivot: Vector3;
  23631. /**
  23632. * Must the particle be translated from its pivot point in its local space ?
  23633. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  23634. * Default : false
  23635. */
  23636. translateFromPivot: boolean;
  23637. /**
  23638. * Is the particle active or not ?
  23639. */
  23640. alive: boolean;
  23641. /**
  23642. * Is the particle visible or not ?
  23643. */
  23644. isVisible: boolean;
  23645. /**
  23646. * Index of this particle in the global "positions" array (Internal use)
  23647. * @hidden
  23648. */
  23649. _pos: number;
  23650. /**
  23651. * @hidden Index of this particle in the global "indices" array (Internal use)
  23652. */
  23653. _ind: number;
  23654. /**
  23655. * @hidden ModelShape of this particle (Internal use)
  23656. */
  23657. _model: ModelShape;
  23658. /**
  23659. * ModelShape id of this particle
  23660. */
  23661. shapeId: number;
  23662. /**
  23663. * Index of the particle in its shape id (Internal use)
  23664. */
  23665. idxInShape: number;
  23666. /**
  23667. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  23668. */
  23669. _modelBoundingInfo: BoundingInfo;
  23670. /**
  23671. * @hidden Particle BoundingInfo object (Internal use)
  23672. */
  23673. _boundingInfo: BoundingInfo;
  23674. /**
  23675. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  23676. */
  23677. _sps: SolidParticleSystem;
  23678. /**
  23679. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  23680. */
  23681. _stillInvisible: boolean;
  23682. /**
  23683. * @hidden Last computed particle rotation matrix
  23684. */
  23685. _rotationMatrix: number[];
  23686. /**
  23687. * Parent particle Id, if any.
  23688. * Default null.
  23689. */
  23690. parentId: Nullable<number>;
  23691. /**
  23692. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  23693. * The possible values are :
  23694. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  23695. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  23696. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  23697. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  23698. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  23699. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  23700. * */
  23701. cullingStrategy: number;
  23702. /**
  23703. * @hidden Internal global position in the SPS.
  23704. */
  23705. _globalPosition: Vector3;
  23706. /**
  23707. * Creates a Solid Particle object.
  23708. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  23709. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  23710. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  23711. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  23712. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  23713. * @param shapeId (integer) is the model shape identifier in the SPS.
  23714. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  23715. * @param sps defines the sps it is associated to
  23716. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  23717. */
  23718. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  23719. /**
  23720. * Legacy support, changed scale to scaling
  23721. */
  23722. /**
  23723. * Legacy support, changed scale to scaling
  23724. */
  23725. scale: Vector3;
  23726. /**
  23727. * Legacy support, changed quaternion to rotationQuaternion
  23728. */
  23729. /**
  23730. * Legacy support, changed quaternion to rotationQuaternion
  23731. */
  23732. quaternion: Nullable<Quaternion>;
  23733. /**
  23734. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  23735. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  23736. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  23737. * @returns true if it intersects
  23738. */
  23739. intersectsMesh(target: Mesh | SolidParticle): boolean;
  23740. /**
  23741. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  23742. * A particle is in the frustum if its bounding box intersects the frustum
  23743. * @param frustumPlanes defines the frustum to test
  23744. * @returns true if the particle is in the frustum planes
  23745. */
  23746. isInFrustum(frustumPlanes: Plane[]): boolean;
  23747. /**
  23748. * get the rotation matrix of the particle
  23749. * @hidden
  23750. */
  23751. getRotationMatrix(m: Matrix): void;
  23752. }
  23753. /**
  23754. * Represents the shape of the model used by one particle of a solid particle system.
  23755. * SPS internal tool, don't use it manually.
  23756. */
  23757. export class ModelShape {
  23758. /**
  23759. * The shape id
  23760. * @hidden
  23761. */
  23762. shapeID: number;
  23763. /**
  23764. * flat array of model positions (internal use)
  23765. * @hidden
  23766. */
  23767. _shape: Vector3[];
  23768. /**
  23769. * flat array of model UVs (internal use)
  23770. * @hidden
  23771. */
  23772. _shapeUV: number[];
  23773. /**
  23774. * length of the shape in the model indices array (internal use)
  23775. * @hidden
  23776. */
  23777. _indicesLength: number;
  23778. /**
  23779. * Custom position function (internal use)
  23780. * @hidden
  23781. */
  23782. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  23783. /**
  23784. * Custom vertex function (internal use)
  23785. * @hidden
  23786. */
  23787. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  23788. /**
  23789. * 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.
  23790. * SPS internal tool, don't use it manually.
  23791. * @hidden
  23792. */
  23793. 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>);
  23794. }
  23795. /**
  23796. * Represents a Depth Sorted Particle in the solid particle system.
  23797. */
  23798. export class DepthSortedParticle {
  23799. /**
  23800. * Index of the particle in the "indices" array
  23801. */
  23802. ind: number;
  23803. /**
  23804. * Length of the particle shape in the "indices" array
  23805. */
  23806. indicesLength: number;
  23807. /**
  23808. * Squared distance from the particle to the camera
  23809. */
  23810. sqDistance: number;
  23811. }
  23812. }
  23813. declare module "babylonjs/Meshes/abstractMesh" {
  23814. import { Observable } from "babylonjs/Misc/observable";
  23815. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  23816. import { Camera } from "babylonjs/Cameras/camera";
  23817. import { Scene, IDisposable } from "babylonjs/scene";
  23818. import { Matrix, Vector3, Color3, Color4, Plane, Vector2 } from "babylonjs/Maths/math";
  23819. import { Node } from "babylonjs/node";
  23820. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  23821. import { TransformNode } from "babylonjs/Meshes/transformNode";
  23822. import { SubMesh } from "babylonjs/Meshes/subMesh";
  23823. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  23824. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  23825. import { Material } from "babylonjs/Materials/material";
  23826. import { Light } from "babylonjs/Lights/light";
  23827. import { Skeleton } from "babylonjs/Bones/skeleton";
  23828. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  23829. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  23830. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  23831. import { Ray } from "babylonjs/Culling/ray";
  23832. import { Collider } from "babylonjs/Collisions/collider";
  23833. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  23834. /**
  23835. * Class used to store all common mesh properties
  23836. */
  23837. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  23838. /** No occlusion */
  23839. static OCCLUSION_TYPE_NONE: number;
  23840. /** Occlusion set to optimisitic */
  23841. static OCCLUSION_TYPE_OPTIMISTIC: number;
  23842. /** Occlusion set to strict */
  23843. static OCCLUSION_TYPE_STRICT: number;
  23844. /** Use an accurante occlusion algorithm */
  23845. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  23846. /** Use a conservative occlusion algorithm */
  23847. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  23848. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  23849. * Test order :
  23850. * Is the bounding sphere outside the frustum ?
  23851. * If not, are the bounding box vertices outside the frustum ?
  23852. * It not, then the cullable object is in the frustum.
  23853. */
  23854. static readonly CULLINGSTRATEGY_STANDARD: number;
  23855. /** Culling strategy : Bounding Sphere Only.
  23856. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  23857. * It's also less accurate than the standard because some not visible objects can still be selected.
  23858. * Test : is the bounding sphere outside the frustum ?
  23859. * If not, then the cullable object is in the frustum.
  23860. */
  23861. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  23862. /** Culling strategy : Optimistic Inclusion.
  23863. * This in an inclusion test first, then the standard exclusion test.
  23864. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  23865. * 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.
  23866. * Anyway, it's as accurate as the standard strategy.
  23867. * Test :
  23868. * Is the cullable object bounding sphere center in the frustum ?
  23869. * If not, apply the default culling strategy.
  23870. */
  23871. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  23872. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  23873. * This in an inclusion test first, then the bounding sphere only exclusion test.
  23874. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  23875. * 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.
  23876. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  23877. * Test :
  23878. * Is the cullable object bounding sphere center in the frustum ?
  23879. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  23880. */
  23881. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  23882. /**
  23883. * No billboard
  23884. */
  23885. static readonly BILLBOARDMODE_NONE: number;
  23886. /** Billboard on X axis */
  23887. static readonly BILLBOARDMODE_X: number;
  23888. /** Billboard on Y axis */
  23889. static readonly BILLBOARDMODE_Y: number;
  23890. /** Billboard on Z axis */
  23891. static readonly BILLBOARDMODE_Z: number;
  23892. /** Billboard on all axes */
  23893. static readonly BILLBOARDMODE_ALL: number;
  23894. private _facetData;
  23895. /**
  23896. * The culling strategy to use to check whether the mesh must be rendered or not.
  23897. * This value can be changed at any time and will be used on the next render mesh selection.
  23898. * The possible values are :
  23899. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  23900. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  23901. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  23902. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  23903. * Please read each static variable documentation to get details about the culling process.
  23904. * */
  23905. cullingStrategy: number;
  23906. /**
  23907. * Gets the number of facets in the mesh
  23908. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  23909. */
  23910. readonly facetNb: number;
  23911. /**
  23912. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  23913. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  23914. */
  23915. partitioningSubdivisions: number;
  23916. /**
  23917. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  23918. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  23919. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  23920. */
  23921. partitioningBBoxRatio: number;
  23922. /**
  23923. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  23924. * Works only for updatable meshes.
  23925. * Doesn't work with multi-materials
  23926. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  23927. */
  23928. mustDepthSortFacets: boolean;
  23929. /**
  23930. * The location (Vector3) where the facet depth sort must be computed from.
  23931. * By default, the active camera position.
  23932. * Used only when facet depth sort is enabled
  23933. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  23934. */
  23935. facetDepthSortFrom: Vector3;
  23936. /**
  23937. * gets a boolean indicating if facetData is enabled
  23938. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  23939. */
  23940. readonly isFacetDataEnabled: boolean;
  23941. /** @hidden */
  23942. _updateNonUniformScalingState(value: boolean): boolean;
  23943. /**
  23944. * An event triggered when this mesh collides with another one
  23945. */
  23946. onCollideObservable: Observable<AbstractMesh>;
  23947. private _onCollideObserver;
  23948. /** Set a function to call when this mesh collides with another one */
  23949. onCollide: () => void;
  23950. /**
  23951. * An event triggered when the collision's position changes
  23952. */
  23953. onCollisionPositionChangeObservable: Observable<Vector3>;
  23954. private _onCollisionPositionChangeObserver;
  23955. /** Set a function to call when the collision's position changes */
  23956. onCollisionPositionChange: () => void;
  23957. /**
  23958. * An event triggered when material is changed
  23959. */
  23960. onMaterialChangedObservable: Observable<AbstractMesh>;
  23961. /**
  23962. * Gets or sets the orientation for POV movement & rotation
  23963. */
  23964. definedFacingForward: boolean;
  23965. /** @hidden */
  23966. _occlusionQuery: Nullable<WebGLQuery>;
  23967. private _visibility;
  23968. /**
  23969. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  23970. */
  23971. /**
  23972. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  23973. */
  23974. visibility: number;
  23975. /** Gets or sets the alpha index used to sort transparent meshes
  23976. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  23977. */
  23978. alphaIndex: number;
  23979. /**
  23980. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  23981. */
  23982. isVisible: boolean;
  23983. /**
  23984. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  23985. */
  23986. isPickable: boolean;
  23987. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  23988. showSubMeshesBoundingBox: boolean;
  23989. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  23990. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  23991. */
  23992. isBlocker: boolean;
  23993. /**
  23994. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  23995. */
  23996. enablePointerMoveEvents: boolean;
  23997. /**
  23998. * Specifies the rendering group id for this mesh (0 by default)
  23999. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  24000. */
  24001. renderingGroupId: number;
  24002. private _material;
  24003. /** Gets or sets current material */
  24004. material: Nullable<Material>;
  24005. private _receiveShadows;
  24006. /**
  24007. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  24008. * @see http://doc.babylonjs.com/babylon101/shadows
  24009. */
  24010. receiveShadows: boolean;
  24011. /** Defines color to use when rendering outline */
  24012. outlineColor: Color3;
  24013. /** Define width to use when rendering outline */
  24014. outlineWidth: number;
  24015. /** Defines color to use when rendering overlay */
  24016. overlayColor: Color3;
  24017. /** Defines alpha to use when rendering overlay */
  24018. overlayAlpha: number;
  24019. private _hasVertexAlpha;
  24020. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  24021. hasVertexAlpha: boolean;
  24022. private _useVertexColors;
  24023. /** 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) */
  24024. useVertexColors: boolean;
  24025. private _computeBonesUsingShaders;
  24026. /**
  24027. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  24028. */
  24029. computeBonesUsingShaders: boolean;
  24030. private _numBoneInfluencers;
  24031. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  24032. numBoneInfluencers: number;
  24033. private _applyFog;
  24034. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  24035. applyFog: boolean;
  24036. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  24037. useOctreeForRenderingSelection: boolean;
  24038. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  24039. useOctreeForPicking: boolean;
  24040. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  24041. useOctreeForCollisions: boolean;
  24042. private _layerMask;
  24043. /**
  24044. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  24045. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  24046. */
  24047. layerMask: number;
  24048. /**
  24049. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  24050. */
  24051. alwaysSelectAsActiveMesh: boolean;
  24052. /**
  24053. * Gets or sets the current action manager
  24054. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  24055. */
  24056. actionManager: Nullable<AbstractActionManager>;
  24057. private _checkCollisions;
  24058. private _collisionMask;
  24059. private _collisionGroup;
  24060. /**
  24061. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  24062. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24063. */
  24064. ellipsoid: Vector3;
  24065. /**
  24066. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  24067. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24068. */
  24069. ellipsoidOffset: Vector3;
  24070. private _collider;
  24071. private _oldPositionForCollisions;
  24072. private _diffPositionForCollisions;
  24073. /**
  24074. * Gets or sets a collision mask used to mask collisions (default is -1).
  24075. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24076. */
  24077. collisionMask: number;
  24078. /**
  24079. * Gets or sets the current collision group mask (-1 by default).
  24080. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24081. */
  24082. collisionGroup: number;
  24083. /**
  24084. * Defines edge width used when edgesRenderer is enabled
  24085. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24086. */
  24087. edgesWidth: number;
  24088. /**
  24089. * Defines edge color used when edgesRenderer is enabled
  24090. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24091. */
  24092. edgesColor: Color4;
  24093. /** @hidden */
  24094. _edgesRenderer: Nullable<IEdgesRenderer>;
  24095. /** @hidden */
  24096. _masterMesh: Nullable<AbstractMesh>;
  24097. /** @hidden */
  24098. _boundingInfo: Nullable<BoundingInfo>;
  24099. /** @hidden */
  24100. _renderId: number;
  24101. /**
  24102. * Gets or sets the list of subMeshes
  24103. * @see http://doc.babylonjs.com/how_to/multi_materials
  24104. */
  24105. subMeshes: SubMesh[];
  24106. /** @hidden */
  24107. _intersectionsInProgress: AbstractMesh[];
  24108. /** @hidden */
  24109. _unIndexed: boolean;
  24110. /** @hidden */
  24111. _lightSources: Light[];
  24112. /** @hidden */
  24113. readonly _positions: Nullable<Vector3[]>;
  24114. /** @hidden */
  24115. _waitingActions: any;
  24116. /** @hidden */
  24117. _waitingFreezeWorldMatrix: Nullable<boolean>;
  24118. private _skeleton;
  24119. /** @hidden */
  24120. _bonesTransformMatrices: Nullable<Float32Array>;
  24121. /**
  24122. * Gets or sets a skeleton to apply skining transformations
  24123. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  24124. */
  24125. skeleton: Nullable<Skeleton>;
  24126. /**
  24127. * An event triggered when the mesh is rebuilt.
  24128. */
  24129. onRebuildObservable: Observable<AbstractMesh>;
  24130. /**
  24131. * Creates a new AbstractMesh
  24132. * @param name defines the name of the mesh
  24133. * @param scene defines the hosting scene
  24134. */
  24135. constructor(name: string, scene?: Nullable<Scene>);
  24136. /**
  24137. * Returns the string "AbstractMesh"
  24138. * @returns "AbstractMesh"
  24139. */
  24140. getClassName(): string;
  24141. /**
  24142. * Gets a string representation of the current mesh
  24143. * @param fullDetails defines a boolean indicating if full details must be included
  24144. * @returns a string representation of the current mesh
  24145. */
  24146. toString(fullDetails?: boolean): string;
  24147. /** @hidden */
  24148. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  24149. /** @hidden */
  24150. _rebuild(): void;
  24151. /** @hidden */
  24152. _resyncLightSources(): void;
  24153. /** @hidden */
  24154. _resyncLighSource(light: Light): void;
  24155. /** @hidden */
  24156. _unBindEffect(): void;
  24157. /** @hidden */
  24158. _removeLightSource(light: Light): void;
  24159. private _markSubMeshesAsDirty;
  24160. /** @hidden */
  24161. _markSubMeshesAsLightDirty(): void;
  24162. /** @hidden */
  24163. _markSubMeshesAsAttributesDirty(): void;
  24164. /** @hidden */
  24165. _markSubMeshesAsMiscDirty(): void;
  24166. /**
  24167. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  24168. */
  24169. scaling: Vector3;
  24170. /**
  24171. * Returns true if the mesh is blocked. Implemented by child classes
  24172. */
  24173. readonly isBlocked: boolean;
  24174. /**
  24175. * Returns the mesh itself by default. Implemented by child classes
  24176. * @param camera defines the camera to use to pick the right LOD level
  24177. * @returns the currentAbstractMesh
  24178. */
  24179. getLOD(camera: Camera): Nullable<AbstractMesh>;
  24180. /**
  24181. * Returns 0 by default. Implemented by child classes
  24182. * @returns an integer
  24183. */
  24184. getTotalVertices(): number;
  24185. /**
  24186. * Returns a positive integer : the total number of indices in this mesh geometry.
  24187. * @returns the numner of indices or zero if the mesh has no geometry.
  24188. */
  24189. getTotalIndices(): number;
  24190. /**
  24191. * Returns null by default. Implemented by child classes
  24192. * @returns null
  24193. */
  24194. getIndices(): Nullable<IndicesArray>;
  24195. /**
  24196. * Returns the array of the requested vertex data kind. Implemented by child classes
  24197. * @param kind defines the vertex data kind to use
  24198. * @returns null
  24199. */
  24200. getVerticesData(kind: string): Nullable<FloatArray>;
  24201. /**
  24202. * Sets the vertex data of the mesh geometry for the requested `kind`.
  24203. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  24204. * Note that a new underlying VertexBuffer object is created each call.
  24205. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  24206. * @param kind defines vertex data kind:
  24207. * * VertexBuffer.PositionKind
  24208. * * VertexBuffer.UVKind
  24209. * * VertexBuffer.UV2Kind
  24210. * * VertexBuffer.UV3Kind
  24211. * * VertexBuffer.UV4Kind
  24212. * * VertexBuffer.UV5Kind
  24213. * * VertexBuffer.UV6Kind
  24214. * * VertexBuffer.ColorKind
  24215. * * VertexBuffer.MatricesIndicesKind
  24216. * * VertexBuffer.MatricesIndicesExtraKind
  24217. * * VertexBuffer.MatricesWeightsKind
  24218. * * VertexBuffer.MatricesWeightsExtraKind
  24219. * @param data defines the data source
  24220. * @param updatable defines if the data must be flagged as updatable (or static)
  24221. * @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
  24222. * @returns the current mesh
  24223. */
  24224. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24225. /**
  24226. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  24227. * If the mesh has no geometry, it is simply returned as it is.
  24228. * @param kind defines vertex data kind:
  24229. * * VertexBuffer.PositionKind
  24230. * * VertexBuffer.UVKind
  24231. * * VertexBuffer.UV2Kind
  24232. * * VertexBuffer.UV3Kind
  24233. * * VertexBuffer.UV4Kind
  24234. * * VertexBuffer.UV5Kind
  24235. * * VertexBuffer.UV6Kind
  24236. * * VertexBuffer.ColorKind
  24237. * * VertexBuffer.MatricesIndicesKind
  24238. * * VertexBuffer.MatricesIndicesExtraKind
  24239. * * VertexBuffer.MatricesWeightsKind
  24240. * * VertexBuffer.MatricesWeightsExtraKind
  24241. * @param data defines the data source
  24242. * @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
  24243. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  24244. * @returns the current mesh
  24245. */
  24246. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24247. /**
  24248. * Sets the mesh indices,
  24249. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  24250. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  24251. * @param totalVertices Defines the total number of vertices
  24252. * @returns the current mesh
  24253. */
  24254. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  24255. /**
  24256. * Gets a boolean indicating if specific vertex data is present
  24257. * @param kind defines the vertex data kind to use
  24258. * @returns true is data kind is present
  24259. */
  24260. isVerticesDataPresent(kind: string): boolean;
  24261. /**
  24262. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  24263. * @returns a BoundingInfo
  24264. */
  24265. getBoundingInfo(): BoundingInfo;
  24266. /**
  24267. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  24268. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box
  24269. * @returns the current mesh
  24270. */
  24271. normalizeToUnitCube(includeDescendants?: boolean): AbstractMesh;
  24272. /**
  24273. * Overwrite the current bounding info
  24274. * @param boundingInfo defines the new bounding info
  24275. * @returns the current mesh
  24276. */
  24277. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  24278. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  24279. readonly useBones: boolean;
  24280. /** @hidden */
  24281. _preActivate(): void;
  24282. /** @hidden */
  24283. _preActivateForIntermediateRendering(renderId: number): void;
  24284. /** @hidden */
  24285. _activate(renderId: number): void;
  24286. /**
  24287. * Gets the current world matrix
  24288. * @returns a Matrix
  24289. */
  24290. getWorldMatrix(): Matrix;
  24291. /** @hidden */
  24292. _getWorldMatrixDeterminant(): number;
  24293. /**
  24294. * Perform relative position change from the point of view of behind the front of the mesh.
  24295. * This is performed taking into account the meshes current rotation, so you do not have to care.
  24296. * Supports definition of mesh facing forward or backward
  24297. * @param amountRight defines the distance on the right axis
  24298. * @param amountUp defines the distance on the up axis
  24299. * @param amountForward defines the distance on the forward axis
  24300. * @returns the current mesh
  24301. */
  24302. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  24303. /**
  24304. * Calculate relative position change from the point of view of behind the front of the mesh.
  24305. * This is performed taking into account the meshes current rotation, so you do not have to care.
  24306. * Supports definition of mesh facing forward or backward
  24307. * @param amountRight defines the distance on the right axis
  24308. * @param amountUp defines the distance on the up axis
  24309. * @param amountForward defines the distance on the forward axis
  24310. * @returns the new displacement vector
  24311. */
  24312. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  24313. /**
  24314. * Perform relative rotation change from the point of view of behind the front of the mesh.
  24315. * Supports definition of mesh facing forward or backward
  24316. * @param flipBack defines the flip
  24317. * @param twirlClockwise defines the twirl
  24318. * @param tiltRight defines the tilt
  24319. * @returns the current mesh
  24320. */
  24321. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  24322. /**
  24323. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  24324. * Supports definition of mesh facing forward or backward.
  24325. * @param flipBack defines the flip
  24326. * @param twirlClockwise defines the twirl
  24327. * @param tiltRight defines the tilt
  24328. * @returns the new rotation vector
  24329. */
  24330. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  24331. /**
  24332. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  24333. * @param includeDescendants Include bounding info from descendants as well (true by default)
  24334. * @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
  24335. * @returns the new bounding vectors
  24336. */
  24337. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  24338. min: Vector3;
  24339. max: Vector3;
  24340. };
  24341. /**
  24342. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24343. * This means the mesh underlying bounding box and sphere are recomputed.
  24344. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24345. * @returns the current mesh
  24346. */
  24347. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  24348. /** @hidden */
  24349. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  24350. /** @hidden */
  24351. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  24352. /** @hidden */
  24353. _updateBoundingInfo(): AbstractMesh;
  24354. /** @hidden */
  24355. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  24356. /** @hidden */
  24357. protected _afterComputeWorldMatrix(): void;
  24358. /**
  24359. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24360. * A mesh is in the frustum if its bounding box intersects the frustum
  24361. * @param frustumPlanes defines the frustum to test
  24362. * @returns true if the mesh is in the frustum planes
  24363. */
  24364. isInFrustum(frustumPlanes: Plane[]): boolean;
  24365. /**
  24366. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  24367. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  24368. * @param frustumPlanes defines the frustum to test
  24369. * @returns true if the mesh is completely in the frustum planes
  24370. */
  24371. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  24372. /**
  24373. * True if the mesh intersects another mesh or a SolidParticle object
  24374. * @param mesh defines a target mesh or SolidParticle to test
  24375. * @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)
  24376. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  24377. * @returns true if there is an intersection
  24378. */
  24379. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  24380. /**
  24381. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  24382. * @param point defines the point to test
  24383. * @returns true if there is an intersection
  24384. */
  24385. intersectsPoint(point: Vector3): boolean;
  24386. /**
  24387. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  24388. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24389. */
  24390. checkCollisions: boolean;
  24391. /**
  24392. * Gets Collider object used to compute collisions (not physics)
  24393. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24394. */
  24395. readonly collider: Collider;
  24396. /**
  24397. * Move the mesh using collision engine
  24398. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24399. * @param displacement defines the requested displacement vector
  24400. * @returns the current mesh
  24401. */
  24402. moveWithCollisions(displacement: Vector3): AbstractMesh;
  24403. private _onCollisionPositionChange;
  24404. /** @hidden */
  24405. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  24406. /** @hidden */
  24407. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  24408. /** @hidden */
  24409. _checkCollision(collider: Collider): AbstractMesh;
  24410. /** @hidden */
  24411. _generatePointsArray(): boolean;
  24412. /**
  24413. * Checks if the passed Ray intersects with the mesh
  24414. * @param ray defines the ray to use
  24415. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  24416. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  24417. * @returns the picking info
  24418. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  24419. */
  24420. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  24421. /**
  24422. * Clones the current mesh
  24423. * @param name defines the mesh name
  24424. * @param newParent defines the new mesh parent
  24425. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  24426. * @returns the new mesh
  24427. */
  24428. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  24429. /**
  24430. * Disposes all the submeshes of the current meshnp
  24431. * @returns the current mesh
  24432. */
  24433. releaseSubMeshes(): AbstractMesh;
  24434. /**
  24435. * Releases resources associated with this abstract mesh.
  24436. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24437. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24438. */
  24439. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24440. /**
  24441. * Adds the passed mesh as a child to the current mesh
  24442. * @param mesh defines the child mesh
  24443. * @returns the current mesh
  24444. */
  24445. addChild(mesh: AbstractMesh): AbstractMesh;
  24446. /**
  24447. * Removes the passed mesh from the current mesh children list
  24448. * @param mesh defines the child mesh
  24449. * @returns the current mesh
  24450. */
  24451. removeChild(mesh: AbstractMesh): AbstractMesh;
  24452. /** @hidden */
  24453. private _initFacetData;
  24454. /**
  24455. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  24456. * This method can be called within the render loop.
  24457. * 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
  24458. * @returns the current mesh
  24459. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24460. */
  24461. updateFacetData(): AbstractMesh;
  24462. /**
  24463. * Returns the facetLocalNormals array.
  24464. * The normals are expressed in the mesh local spac
  24465. * @returns an array of Vector3
  24466. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24467. */
  24468. getFacetLocalNormals(): Vector3[];
  24469. /**
  24470. * Returns the facetLocalPositions array.
  24471. * The facet positions are expressed in the mesh local space
  24472. * @returns an array of Vector3
  24473. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24474. */
  24475. getFacetLocalPositions(): Vector3[];
  24476. /**
  24477. * Returns the facetLocalPartioning array
  24478. * @returns an array of array of numbers
  24479. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24480. */
  24481. getFacetLocalPartitioning(): number[][];
  24482. /**
  24483. * Returns the i-th facet position in the world system.
  24484. * This method allocates a new Vector3 per call
  24485. * @param i defines the facet index
  24486. * @returns a new Vector3
  24487. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24488. */
  24489. getFacetPosition(i: number): Vector3;
  24490. /**
  24491. * Sets the reference Vector3 with the i-th facet position in the world system
  24492. * @param i defines the facet index
  24493. * @param ref defines the target vector
  24494. * @returns the current mesh
  24495. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24496. */
  24497. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  24498. /**
  24499. * Returns the i-th facet normal in the world system.
  24500. * This method allocates a new Vector3 per call
  24501. * @param i defines the facet index
  24502. * @returns a new Vector3
  24503. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24504. */
  24505. getFacetNormal(i: number): Vector3;
  24506. /**
  24507. * Sets the reference Vector3 with the i-th facet normal in the world system
  24508. * @param i defines the facet index
  24509. * @param ref defines the target vector
  24510. * @returns the current mesh
  24511. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24512. */
  24513. getFacetNormalToRef(i: number, ref: Vector3): this;
  24514. /**
  24515. * 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)
  24516. * @param x defines x coordinate
  24517. * @param y defines y coordinate
  24518. * @param z defines z coordinate
  24519. * @returns the array of facet indexes
  24520. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24521. */
  24522. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  24523. /**
  24524. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  24525. * @param projected sets as the (x,y,z) world projection on the facet
  24526. * @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
  24527. * @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
  24528. * @param x defines x coordinate
  24529. * @param y defines y coordinate
  24530. * @param z defines z coordinate
  24531. * @returns the face index if found (or null instead)
  24532. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24533. */
  24534. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  24535. /**
  24536. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  24537. * @param projected sets as the (x,y,z) local projection on the facet
  24538. * @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
  24539. * @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
  24540. * @param x defines x coordinate
  24541. * @param y defines y coordinate
  24542. * @param z defines z coordinate
  24543. * @returns the face index if found (or null instead)
  24544. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24545. */
  24546. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  24547. /**
  24548. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  24549. * @returns the parameters
  24550. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24551. */
  24552. getFacetDataParameters(): any;
  24553. /**
  24554. * Disables the feature FacetData and frees the related memory
  24555. * @returns the current mesh
  24556. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24557. */
  24558. disableFacetData(): AbstractMesh;
  24559. /**
  24560. * Updates the AbstractMesh indices array
  24561. * @param indices defines the data source
  24562. * @returns the current mesh
  24563. */
  24564. updateIndices(indices: IndicesArray): AbstractMesh;
  24565. /**
  24566. * Creates new normals data for the mesh
  24567. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  24568. * @returns the current mesh
  24569. */
  24570. createNormals(updatable: boolean): AbstractMesh;
  24571. /**
  24572. * Align the mesh with a normal
  24573. * @param normal defines the normal to use
  24574. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  24575. * @returns the current mesh
  24576. */
  24577. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  24578. /** @hidden */
  24579. _checkOcclusionQuery(): boolean;
  24580. }
  24581. }
  24582. declare module "babylonjs/Actions/actionEvent" {
  24583. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24584. import { Nullable } from "babylonjs/types";
  24585. import { Sprite } from "babylonjs/Sprites/sprite";
  24586. import { Scene } from "babylonjs/scene";
  24587. import { Vector2 } from "babylonjs/Maths/math";
  24588. /**
  24589. * Interface used to define ActionEvent
  24590. */
  24591. export interface 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. /**
  24606. * ActionEvent is the event being sent when an action is triggered.
  24607. */
  24608. export class ActionEvent implements IActionEvent {
  24609. /** The mesh or sprite that triggered the action */
  24610. source: any;
  24611. /** The X mouse cursor position at the time of the event */
  24612. pointerX: number;
  24613. /** The Y mouse cursor position at the time of the event */
  24614. pointerY: number;
  24615. /** The mesh that is currently pointed at (can be null) */
  24616. meshUnderPointer: Nullable<AbstractMesh>;
  24617. /** the original (browser) event that triggered the ActionEvent */
  24618. sourceEvent?: any;
  24619. /** additional data for the event */
  24620. additionalData?: any;
  24621. /**
  24622. * Creates a new ActionEvent
  24623. * @param source The mesh or sprite that triggered the action
  24624. * @param pointerX The X mouse cursor position at the time of the event
  24625. * @param pointerY The Y mouse cursor position at the time of the event
  24626. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  24627. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  24628. * @param additionalData additional data for the event
  24629. */
  24630. constructor(
  24631. /** The mesh or sprite that triggered the action */
  24632. source: any,
  24633. /** The X mouse cursor position at the time of the event */
  24634. pointerX: number,
  24635. /** The Y mouse cursor position at the time of the event */
  24636. pointerY: number,
  24637. /** The mesh that is currently pointed at (can be null) */
  24638. meshUnderPointer: Nullable<AbstractMesh>,
  24639. /** the original (browser) event that triggered the ActionEvent */
  24640. sourceEvent?: any,
  24641. /** additional data for the event */
  24642. additionalData?: any);
  24643. /**
  24644. * Helper function to auto-create an ActionEvent from a source mesh.
  24645. * @param source The source mesh that triggered the event
  24646. * @param evt The original (browser) event
  24647. * @param additionalData additional data for the event
  24648. * @returns the new ActionEvent
  24649. */
  24650. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  24651. /**
  24652. * Helper function to auto-create an ActionEvent from a source sprite
  24653. * @param source The source sprite that triggered the event
  24654. * @param scene Scene associated with the sprite
  24655. * @param evt The original (browser) event
  24656. * @param additionalData additional data for the event
  24657. * @returns the new ActionEvent
  24658. */
  24659. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  24660. /**
  24661. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  24662. * @param scene the scene where the event occurred
  24663. * @param evt The original (browser) event
  24664. * @returns the new ActionEvent
  24665. */
  24666. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  24667. /**
  24668. * Helper function to auto-create an ActionEvent from a primitive
  24669. * @param prim defines the target primitive
  24670. * @param pointerPos defines the pointer position
  24671. * @param evt The original (browser) event
  24672. * @param additionalData additional data for the event
  24673. * @returns the new ActionEvent
  24674. */
  24675. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  24676. }
  24677. }
  24678. declare module "babylonjs/Actions/abstractActionManager" {
  24679. import { IDisposable } from "babylonjs/scene";
  24680. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  24681. import { IAction } from "babylonjs/Actions/action";
  24682. import { Nullable } from "babylonjs/types";
  24683. /**
  24684. * Abstract class used to decouple action Manager from scene and meshes.
  24685. * Do not instantiate.
  24686. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  24687. */
  24688. export abstract class AbstractActionManager implements IDisposable {
  24689. /** Gets the list of active triggers */
  24690. static Triggers: {
  24691. [key: string]: number;
  24692. };
  24693. /** Gets the cursor to use when hovering items */
  24694. hoverCursor: string;
  24695. /** Gets the list of actions */
  24696. actions: IAction[];
  24697. /**
  24698. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  24699. */
  24700. isRecursive: boolean;
  24701. /**
  24702. * Releases all associated resources
  24703. */
  24704. abstract dispose(): void;
  24705. /**
  24706. * Does this action manager has pointer triggers
  24707. */
  24708. abstract readonly hasPointerTriggers: boolean;
  24709. /**
  24710. * Does this action manager has pick triggers
  24711. */
  24712. abstract readonly hasPickTriggers: boolean;
  24713. /**
  24714. * Process a specific trigger
  24715. * @param trigger defines the trigger to process
  24716. * @param evt defines the event details to be processed
  24717. */
  24718. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  24719. /**
  24720. * Does this action manager handles actions of any of the given triggers
  24721. * @param triggers defines the triggers to be tested
  24722. * @return a boolean indicating whether one (or more) of the triggers is handled
  24723. */
  24724. abstract hasSpecificTriggers(triggers: number[]): boolean;
  24725. /**
  24726. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  24727. * speed.
  24728. * @param triggerA defines the trigger to be tested
  24729. * @param triggerB defines the trigger to be tested
  24730. * @return a boolean indicating whether one (or more) of the triggers is handled
  24731. */
  24732. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  24733. /**
  24734. * Does this action manager handles actions of a given trigger
  24735. * @param trigger defines the trigger to be tested
  24736. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  24737. * @return whether the trigger is handled
  24738. */
  24739. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  24740. /**
  24741. * Serialize this manager to a JSON object
  24742. * @param name defines the property name to store this manager
  24743. * @returns a JSON representation of this manager
  24744. */
  24745. abstract serialize(name: string): any;
  24746. /**
  24747. * Registers an action to this action manager
  24748. * @param action defines the action to be registered
  24749. * @return the action amended (prepared) after registration
  24750. */
  24751. abstract registerAction(action: IAction): Nullable<IAction>;
  24752. /**
  24753. * Unregisters an action to this action manager
  24754. * @param action defines the action to be unregistered
  24755. * @return a boolean indicating whether the action has been unregistered
  24756. */
  24757. abstract unregisterAction(action: IAction): Boolean;
  24758. /**
  24759. * Does exist one action manager with at least one trigger
  24760. **/
  24761. static readonly HasTriggers: boolean;
  24762. /**
  24763. * Does exist one action manager with at least one pick trigger
  24764. **/
  24765. static readonly HasPickTriggers: boolean;
  24766. /**
  24767. * Does exist one action manager that handles actions of a given trigger
  24768. * @param trigger defines the trigger to be tested
  24769. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  24770. **/
  24771. static HasSpecificTrigger(trigger: number): boolean;
  24772. }
  24773. }
  24774. declare module "babylonjs/node" {
  24775. import { Scene } from "babylonjs/scene";
  24776. import { Nullable } from "babylonjs/types";
  24777. import { Matrix } from "babylonjs/Maths/math";
  24778. import { Engine } from "babylonjs/Engines/engine";
  24779. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  24780. import { Observable } from "babylonjs/Misc/observable";
  24781. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  24782. import { Animatable } from "babylonjs/Animations/animatable";
  24783. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  24784. import { Animation } from "babylonjs/Animations/animation";
  24785. import { AnimationRange } from "babylonjs/Animations/animationRange";
  24786. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24787. /**
  24788. * Defines how a node can be built from a string name.
  24789. */
  24790. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  24791. /**
  24792. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  24793. */
  24794. export class Node implements IBehaviorAware<Node> {
  24795. /** @hidden */
  24796. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  24797. private static _NodeConstructors;
  24798. /**
  24799. * Add a new node constructor
  24800. * @param type defines the type name of the node to construct
  24801. * @param constructorFunc defines the constructor function
  24802. */
  24803. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  24804. /**
  24805. * Returns a node constructor based on type name
  24806. * @param type defines the type name
  24807. * @param name defines the new node name
  24808. * @param scene defines the hosting scene
  24809. * @param options defines optional options to transmit to constructors
  24810. * @returns the new constructor or null
  24811. */
  24812. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  24813. /**
  24814. * Gets or sets the name of the node
  24815. */
  24816. name: string;
  24817. /**
  24818. * Gets or sets the id of the node
  24819. */
  24820. id: string;
  24821. /**
  24822. * Gets or sets the unique id of the node
  24823. */
  24824. uniqueId: number;
  24825. /**
  24826. * Gets or sets a string used to store user defined state for the node
  24827. */
  24828. state: string;
  24829. /**
  24830. * Gets or sets an object used to store user defined information for the node
  24831. */
  24832. metadata: any;
  24833. /**
  24834. * For internal use only. Please do not use.
  24835. */
  24836. reservedDataStore: any;
  24837. /**
  24838. * Gets or sets a boolean used to define if the node must be serialized
  24839. */
  24840. doNotSerialize: boolean;
  24841. /** @hidden */
  24842. _isDisposed: boolean;
  24843. /**
  24844. * Gets a list of Animations associated with the node
  24845. */
  24846. animations: import("babylonjs/Animations/animation").Animation[];
  24847. protected _ranges: {
  24848. [name: string]: Nullable<AnimationRange>;
  24849. };
  24850. /**
  24851. * Callback raised when the node is ready to be used
  24852. */
  24853. onReady: (node: Node) => void;
  24854. private _isEnabled;
  24855. private _isParentEnabled;
  24856. private _isReady;
  24857. /** @hidden */
  24858. _currentRenderId: number;
  24859. private _parentRenderId;
  24860. protected _childRenderId: number;
  24861. /** @hidden */
  24862. _waitingParentId: Nullable<string>;
  24863. /** @hidden */
  24864. _scene: Scene;
  24865. /** @hidden */
  24866. _cache: any;
  24867. private _parentNode;
  24868. private _children;
  24869. /** @hidden */
  24870. _worldMatrix: Matrix;
  24871. /** @hidden */
  24872. _worldMatrixDeterminant: number;
  24873. /** @hidden */
  24874. private _sceneRootNodesIndex;
  24875. /**
  24876. * Gets a boolean indicating if the node has been disposed
  24877. * @returns true if the node was disposed
  24878. */
  24879. isDisposed(): boolean;
  24880. /**
  24881. * Gets or sets the parent of the node
  24882. */
  24883. parent: Nullable<Node>;
  24884. private addToSceneRootNodes;
  24885. private removeFromSceneRootNodes;
  24886. private _animationPropertiesOverride;
  24887. /**
  24888. * Gets or sets the animation properties override
  24889. */
  24890. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  24891. /**
  24892. * Gets a string idenfifying the name of the class
  24893. * @returns "Node" string
  24894. */
  24895. getClassName(): string;
  24896. /** @hidden */
  24897. readonly _isNode: boolean;
  24898. /**
  24899. * An event triggered when the mesh is disposed
  24900. */
  24901. onDisposeObservable: Observable<Node>;
  24902. private _onDisposeObserver;
  24903. /**
  24904. * Sets a callback that will be raised when the node will be disposed
  24905. */
  24906. onDispose: () => void;
  24907. /**
  24908. * Creates a new Node
  24909. * @param name the name and id to be given to this node
  24910. * @param scene the scene this node will be added to
  24911. * @param addToRootNodes the node will be added to scene.rootNodes
  24912. */
  24913. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  24914. /**
  24915. * Gets the scene of the node
  24916. * @returns a scene
  24917. */
  24918. getScene(): Scene;
  24919. /**
  24920. * Gets the engine of the node
  24921. * @returns a Engine
  24922. */
  24923. getEngine(): Engine;
  24924. private _behaviors;
  24925. /**
  24926. * Attach a behavior to the node
  24927. * @see http://doc.babylonjs.com/features/behaviour
  24928. * @param behavior defines the behavior to attach
  24929. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  24930. * @returns the current Node
  24931. */
  24932. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  24933. /**
  24934. * Remove an attached behavior
  24935. * @see http://doc.babylonjs.com/features/behaviour
  24936. * @param behavior defines the behavior to attach
  24937. * @returns the current Node
  24938. */
  24939. removeBehavior(behavior: Behavior<Node>): Node;
  24940. /**
  24941. * Gets the list of attached behaviors
  24942. * @see http://doc.babylonjs.com/features/behaviour
  24943. */
  24944. readonly behaviors: Behavior<Node>[];
  24945. /**
  24946. * Gets an attached behavior by name
  24947. * @param name defines the name of the behavior to look for
  24948. * @see http://doc.babylonjs.com/features/behaviour
  24949. * @returns null if behavior was not found else the requested behavior
  24950. */
  24951. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  24952. /**
  24953. * Returns the latest update of the World matrix
  24954. * @returns a Matrix
  24955. */
  24956. getWorldMatrix(): Matrix;
  24957. /** @hidden */
  24958. _getWorldMatrixDeterminant(): number;
  24959. /**
  24960. * Returns directly the latest state of the mesh World matrix.
  24961. * A Matrix is returned.
  24962. */
  24963. readonly worldMatrixFromCache: Matrix;
  24964. /** @hidden */
  24965. _initCache(): void;
  24966. /** @hidden */
  24967. updateCache(force?: boolean): void;
  24968. /** @hidden */
  24969. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  24970. /** @hidden */
  24971. _updateCache(ignoreParentClass?: boolean): void;
  24972. /** @hidden */
  24973. _isSynchronized(): boolean;
  24974. /** @hidden */
  24975. _markSyncedWithParent(): void;
  24976. /** @hidden */
  24977. isSynchronizedWithParent(): boolean;
  24978. /** @hidden */
  24979. isSynchronized(): boolean;
  24980. /**
  24981. * Is this node ready to be used/rendered
  24982. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  24983. * @return true if the node is ready
  24984. */
  24985. isReady(completeCheck?: boolean): boolean;
  24986. /**
  24987. * Is this node enabled?
  24988. * 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
  24989. * @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
  24990. * @return whether this node (and its parent) is enabled
  24991. */
  24992. isEnabled(checkAncestors?: boolean): boolean;
  24993. /** @hidden */
  24994. protected _syncParentEnabledState(): void;
  24995. /**
  24996. * Set the enabled state of this node
  24997. * @param value defines the new enabled state
  24998. */
  24999. setEnabled(value: boolean): void;
  25000. /**
  25001. * Is this node a descendant of the given node?
  25002. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  25003. * @param ancestor defines the parent node to inspect
  25004. * @returns a boolean indicating if this node is a descendant of the given node
  25005. */
  25006. isDescendantOf(ancestor: Node): boolean;
  25007. /** @hidden */
  25008. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  25009. /**
  25010. * Will return all nodes that have this node as ascendant
  25011. * @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
  25012. * @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
  25013. * @return all children nodes of all types
  25014. */
  25015. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  25016. /**
  25017. * Get all child-meshes of this node
  25018. * @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)
  25019. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  25020. * @returns an array of AbstractMesh
  25021. */
  25022. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  25023. /**
  25024. * Get all direct children of this node
  25025. * @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
  25026. * @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)
  25027. * @returns an array of Node
  25028. */
  25029. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  25030. /** @hidden */
  25031. _setReady(state: boolean): void;
  25032. /**
  25033. * Get an animation by name
  25034. * @param name defines the name of the animation to look for
  25035. * @returns null if not found else the requested animation
  25036. */
  25037. getAnimationByName(name: string): Nullable<Animation>;
  25038. /**
  25039. * Creates an animation range for this node
  25040. * @param name defines the name of the range
  25041. * @param from defines the starting key
  25042. * @param to defines the end key
  25043. */
  25044. createAnimationRange(name: string, from: number, to: number): void;
  25045. /**
  25046. * Delete a specific animation range
  25047. * @param name defines the name of the range to delete
  25048. * @param deleteFrames defines if animation frames from the range must be deleted as well
  25049. */
  25050. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  25051. /**
  25052. * Get an animation range by name
  25053. * @param name defines the name of the animation range to look for
  25054. * @returns null if not found else the requested animation range
  25055. */
  25056. getAnimationRange(name: string): Nullable<AnimationRange>;
  25057. /**
  25058. * Gets the list of all animation ranges defined on this node
  25059. * @returns an array
  25060. */
  25061. getAnimationRanges(): Nullable<AnimationRange>[];
  25062. /**
  25063. * Will start the animation sequence
  25064. * @param name defines the range frames for animation sequence
  25065. * @param loop defines if the animation should loop (false by default)
  25066. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  25067. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  25068. * @returns the object created for this animation. If range does not exist, it will return null
  25069. */
  25070. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  25071. /**
  25072. * Serialize animation ranges into a JSON compatible object
  25073. * @returns serialization object
  25074. */
  25075. serializeAnimationRanges(): any;
  25076. /**
  25077. * Computes the world matrix of the node
  25078. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  25079. * @returns the world matrix
  25080. */
  25081. computeWorldMatrix(force?: boolean): Matrix;
  25082. /**
  25083. * Releases resources associated with this node.
  25084. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25085. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25086. */
  25087. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25088. /**
  25089. * Parse animation range data from a serialization object and store them into a given node
  25090. * @param node defines where to store the animation ranges
  25091. * @param parsedNode defines the serialization object to read data from
  25092. * @param scene defines the hosting scene
  25093. */
  25094. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  25095. }
  25096. }
  25097. declare module "babylonjs/Animations/animation" {
  25098. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  25099. import { Vector3, Quaternion, Vector2, Color3, Size, Matrix } from "babylonjs/Maths/math";
  25100. import { Nullable } from "babylonjs/types";
  25101. import { Scene } from "babylonjs/scene";
  25102. import { IAnimatable } from "babylonjs/Misc/tools";
  25103. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  25104. import { AnimationRange } from "babylonjs/Animations/animationRange";
  25105. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  25106. import { Node } from "babylonjs/node";
  25107. import { Animatable } from "babylonjs/Animations/animatable";
  25108. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  25109. /**
  25110. * Class used to store any kind of animation
  25111. */
  25112. export class Animation {
  25113. /**Name of the animation */
  25114. name: string;
  25115. /**Property to animate */
  25116. targetProperty: string;
  25117. /**The frames per second of the animation */
  25118. framePerSecond: number;
  25119. /**The data type of the animation */
  25120. dataType: number;
  25121. /**The loop mode of the animation */
  25122. loopMode?: number | undefined;
  25123. /**Specifies if blending should be enabled */
  25124. enableBlending?: boolean | undefined;
  25125. /**
  25126. * Use matrix interpolation instead of using direct key value when animating matrices
  25127. */
  25128. static AllowMatricesInterpolation: boolean;
  25129. /**
  25130. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  25131. */
  25132. static AllowMatrixDecomposeForInterpolation: boolean;
  25133. /**
  25134. * Stores the key frames of the animation
  25135. */
  25136. private _keys;
  25137. /**
  25138. * Stores the easing function of the animation
  25139. */
  25140. private _easingFunction;
  25141. /**
  25142. * @hidden Internal use only
  25143. */
  25144. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  25145. /**
  25146. * The set of event that will be linked to this animation
  25147. */
  25148. private _events;
  25149. /**
  25150. * Stores an array of target property paths
  25151. */
  25152. targetPropertyPath: string[];
  25153. /**
  25154. * Stores the blending speed of the animation
  25155. */
  25156. blendingSpeed: number;
  25157. /**
  25158. * Stores the animation ranges for the animation
  25159. */
  25160. private _ranges;
  25161. /**
  25162. * @hidden Internal use
  25163. */
  25164. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  25165. /**
  25166. * Sets up an animation
  25167. * @param property The property to animate
  25168. * @param animationType The animation type to apply
  25169. * @param framePerSecond The frames per second of the animation
  25170. * @param easingFunction The easing function used in the animation
  25171. * @returns The created animation
  25172. */
  25173. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  25174. /**
  25175. * Create and start an animation on a node
  25176. * @param name defines the name of the global animation that will be run on all nodes
  25177. * @param node defines the root node where the animation will take place
  25178. * @param targetProperty defines property to animate
  25179. * @param framePerSecond defines the number of frame per second yo use
  25180. * @param totalFrame defines the number of frames in total
  25181. * @param from defines the initial value
  25182. * @param to defines the final value
  25183. * @param loopMode defines which loop mode you want to use (off by default)
  25184. * @param easingFunction defines the easing function to use (linear by default)
  25185. * @param onAnimationEnd defines the callback to call when animation end
  25186. * @returns the animatable created for this animation
  25187. */
  25188. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  25189. /**
  25190. * Create and start an animation on a node and its descendants
  25191. * @param name defines the name of the global animation that will be run on all nodes
  25192. * @param node defines the root node where the animation will take place
  25193. * @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
  25194. * @param targetProperty defines property to animate
  25195. * @param framePerSecond defines the number of frame per second to use
  25196. * @param totalFrame defines the number of frames in total
  25197. * @param from defines the initial value
  25198. * @param to defines the final value
  25199. * @param loopMode defines which loop mode you want to use (off by default)
  25200. * @param easingFunction defines the easing function to use (linear by default)
  25201. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  25202. * @returns the list of animatables created for all nodes
  25203. * @example https://www.babylonjs-playground.com/#MH0VLI
  25204. */
  25205. 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[]>;
  25206. /**
  25207. * Creates a new animation, merges it with the existing animations and starts it
  25208. * @param name Name of the animation
  25209. * @param node Node which contains the scene that begins the animations
  25210. * @param targetProperty Specifies which property to animate
  25211. * @param framePerSecond The frames per second of the animation
  25212. * @param totalFrame The total number of frames
  25213. * @param from The frame at the beginning of the animation
  25214. * @param to The frame at the end of the animation
  25215. * @param loopMode Specifies the loop mode of the animation
  25216. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  25217. * @param onAnimationEnd Callback to run once the animation is complete
  25218. * @returns Nullable animation
  25219. */
  25220. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  25221. /**
  25222. * Transition property of an host to the target Value
  25223. * @param property The property to transition
  25224. * @param targetValue The target Value of the property
  25225. * @param host The object where the property to animate belongs
  25226. * @param scene Scene used to run the animation
  25227. * @param frameRate Framerate (in frame/s) to use
  25228. * @param transition The transition type we want to use
  25229. * @param duration The duration of the animation, in milliseconds
  25230. * @param onAnimationEnd Callback trigger at the end of the animation
  25231. * @returns Nullable animation
  25232. */
  25233. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  25234. /**
  25235. * Return the array of runtime animations currently using this animation
  25236. */
  25237. readonly runtimeAnimations: RuntimeAnimation[];
  25238. /**
  25239. * Specifies if any of the runtime animations are currently running
  25240. */
  25241. readonly hasRunningRuntimeAnimations: boolean;
  25242. /**
  25243. * Initializes the animation
  25244. * @param name Name of the animation
  25245. * @param targetProperty Property to animate
  25246. * @param framePerSecond The frames per second of the animation
  25247. * @param dataType The data type of the animation
  25248. * @param loopMode The loop mode of the animation
  25249. * @param enableBlending Specifies if blending should be enabled
  25250. */
  25251. constructor(
  25252. /**Name of the animation */
  25253. name: string,
  25254. /**Property to animate */
  25255. targetProperty: string,
  25256. /**The frames per second of the animation */
  25257. framePerSecond: number,
  25258. /**The data type of the animation */
  25259. dataType: number,
  25260. /**The loop mode of the animation */
  25261. loopMode?: number | undefined,
  25262. /**Specifies if blending should be enabled */
  25263. enableBlending?: boolean | undefined);
  25264. /**
  25265. * Converts the animation to a string
  25266. * @param fullDetails support for multiple levels of logging within scene loading
  25267. * @returns String form of the animation
  25268. */
  25269. toString(fullDetails?: boolean): string;
  25270. /**
  25271. * Add an event to this animation
  25272. * @param event Event to add
  25273. */
  25274. addEvent(event: AnimationEvent): void;
  25275. /**
  25276. * Remove all events found at the given frame
  25277. * @param frame The frame to remove events from
  25278. */
  25279. removeEvents(frame: number): void;
  25280. /**
  25281. * Retrieves all the events from the animation
  25282. * @returns Events from the animation
  25283. */
  25284. getEvents(): AnimationEvent[];
  25285. /**
  25286. * Creates an animation range
  25287. * @param name Name of the animation range
  25288. * @param from Starting frame of the animation range
  25289. * @param to Ending frame of the animation
  25290. */
  25291. createRange(name: string, from: number, to: number): void;
  25292. /**
  25293. * Deletes an animation range by name
  25294. * @param name Name of the animation range to delete
  25295. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  25296. */
  25297. deleteRange(name: string, deleteFrames?: boolean): void;
  25298. /**
  25299. * Gets the animation range by name, or null if not defined
  25300. * @param name Name of the animation range
  25301. * @returns Nullable animation range
  25302. */
  25303. getRange(name: string): Nullable<AnimationRange>;
  25304. /**
  25305. * Gets the key frames from the animation
  25306. * @returns The key frames of the animation
  25307. */
  25308. getKeys(): Array<IAnimationKey>;
  25309. /**
  25310. * Gets the highest frame rate of the animation
  25311. * @returns Highest frame rate of the animation
  25312. */
  25313. getHighestFrame(): number;
  25314. /**
  25315. * Gets the easing function of the animation
  25316. * @returns Easing function of the animation
  25317. */
  25318. getEasingFunction(): IEasingFunction;
  25319. /**
  25320. * Sets the easing function of the animation
  25321. * @param easingFunction A custom mathematical formula for animation
  25322. */
  25323. setEasingFunction(easingFunction: EasingFunction): void;
  25324. /**
  25325. * Interpolates a scalar linearly
  25326. * @param startValue Start value of the animation curve
  25327. * @param endValue End value of the animation curve
  25328. * @param gradient Scalar amount to interpolate
  25329. * @returns Interpolated scalar value
  25330. */
  25331. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  25332. /**
  25333. * Interpolates a scalar cubically
  25334. * @param startValue Start value of the animation curve
  25335. * @param outTangent End tangent of the animation
  25336. * @param endValue End value of the animation curve
  25337. * @param inTangent Start tangent of the animation curve
  25338. * @param gradient Scalar amount to interpolate
  25339. * @returns Interpolated scalar value
  25340. */
  25341. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  25342. /**
  25343. * Interpolates a quaternion using a spherical linear interpolation
  25344. * @param startValue Start value of the animation curve
  25345. * @param endValue End value of the animation curve
  25346. * @param gradient Scalar amount to interpolate
  25347. * @returns Interpolated quaternion value
  25348. */
  25349. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  25350. /**
  25351. * Interpolates a quaternion cubically
  25352. * @param startValue Start value of the animation curve
  25353. * @param outTangent End tangent of the animation curve
  25354. * @param endValue End value of the animation curve
  25355. * @param inTangent Start tangent of the animation curve
  25356. * @param gradient Scalar amount to interpolate
  25357. * @returns Interpolated quaternion value
  25358. */
  25359. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  25360. /**
  25361. * Interpolates a Vector3 linearl
  25362. * @param startValue Start value of the animation curve
  25363. * @param endValue End value of the animation curve
  25364. * @param gradient Scalar amount to interpolate
  25365. * @returns Interpolated scalar value
  25366. */
  25367. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  25368. /**
  25369. * Interpolates a Vector3 cubically
  25370. * @param startValue Start value of the animation curve
  25371. * @param outTangent End tangent of the animation
  25372. * @param endValue End value of the animation curve
  25373. * @param inTangent Start tangent of the animation curve
  25374. * @param gradient Scalar amount to interpolate
  25375. * @returns InterpolatedVector3 value
  25376. */
  25377. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  25378. /**
  25379. * Interpolates a Vector2 linearly
  25380. * @param startValue Start value of the animation curve
  25381. * @param endValue End value of the animation curve
  25382. * @param gradient Scalar amount to interpolate
  25383. * @returns Interpolated Vector2 value
  25384. */
  25385. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  25386. /**
  25387. * Interpolates a Vector2 cubically
  25388. * @param startValue Start value of the animation curve
  25389. * @param outTangent End tangent of the animation
  25390. * @param endValue End value of the animation curve
  25391. * @param inTangent Start tangent of the animation curve
  25392. * @param gradient Scalar amount to interpolate
  25393. * @returns Interpolated Vector2 value
  25394. */
  25395. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  25396. /**
  25397. * Interpolates a size linearly
  25398. * @param startValue Start value of the animation curve
  25399. * @param endValue End value of the animation curve
  25400. * @param gradient Scalar amount to interpolate
  25401. * @returns Interpolated Size value
  25402. */
  25403. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  25404. /**
  25405. * Interpolates a Color3 linearly
  25406. * @param startValue Start value of the animation curve
  25407. * @param endValue End value of the animation curve
  25408. * @param gradient Scalar amount to interpolate
  25409. * @returns Interpolated Color3 value
  25410. */
  25411. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  25412. /**
  25413. * @hidden Internal use only
  25414. */
  25415. _getKeyValue(value: any): any;
  25416. /**
  25417. * @hidden Internal use only
  25418. */
  25419. _interpolate(currentFrame: number, repeatCount: number, workValue?: any, loopMode?: number, offsetValue?: any, highLimitValue?: any): any;
  25420. /**
  25421. * Defines the function to use to interpolate matrices
  25422. * @param startValue defines the start matrix
  25423. * @param endValue defines the end matrix
  25424. * @param gradient defines the gradient between both matrices
  25425. * @param result defines an optional target matrix where to store the interpolation
  25426. * @returns the interpolated matrix
  25427. */
  25428. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  25429. /**
  25430. * Makes a copy of the animation
  25431. * @returns Cloned animation
  25432. */
  25433. clone(): Animation;
  25434. /**
  25435. * Sets the key frames of the animation
  25436. * @param values The animation key frames to set
  25437. */
  25438. setKeys(values: Array<IAnimationKey>): void;
  25439. /**
  25440. * Serializes the animation to an object
  25441. * @returns Serialized object
  25442. */
  25443. serialize(): any;
  25444. /**
  25445. * Float animation type
  25446. */
  25447. private static _ANIMATIONTYPE_FLOAT;
  25448. /**
  25449. * Vector3 animation type
  25450. */
  25451. private static _ANIMATIONTYPE_VECTOR3;
  25452. /**
  25453. * Quaternion animation type
  25454. */
  25455. private static _ANIMATIONTYPE_QUATERNION;
  25456. /**
  25457. * Matrix animation type
  25458. */
  25459. private static _ANIMATIONTYPE_MATRIX;
  25460. /**
  25461. * Color3 animation type
  25462. */
  25463. private static _ANIMATIONTYPE_COLOR3;
  25464. /**
  25465. * Vector2 animation type
  25466. */
  25467. private static _ANIMATIONTYPE_VECTOR2;
  25468. /**
  25469. * Size animation type
  25470. */
  25471. private static _ANIMATIONTYPE_SIZE;
  25472. /**
  25473. * Relative Loop Mode
  25474. */
  25475. private static _ANIMATIONLOOPMODE_RELATIVE;
  25476. /**
  25477. * Cycle Loop Mode
  25478. */
  25479. private static _ANIMATIONLOOPMODE_CYCLE;
  25480. /**
  25481. * Constant Loop Mode
  25482. */
  25483. private static _ANIMATIONLOOPMODE_CONSTANT;
  25484. /**
  25485. * Get the float animation type
  25486. */
  25487. static readonly ANIMATIONTYPE_FLOAT: number;
  25488. /**
  25489. * Get the Vector3 animation type
  25490. */
  25491. static readonly ANIMATIONTYPE_VECTOR3: number;
  25492. /**
  25493. * Get the Vector2 animation type
  25494. */
  25495. static readonly ANIMATIONTYPE_VECTOR2: number;
  25496. /**
  25497. * Get the Size animation type
  25498. */
  25499. static readonly ANIMATIONTYPE_SIZE: number;
  25500. /**
  25501. * Get the Quaternion animation type
  25502. */
  25503. static readonly ANIMATIONTYPE_QUATERNION: number;
  25504. /**
  25505. * Get the Matrix animation type
  25506. */
  25507. static readonly ANIMATIONTYPE_MATRIX: number;
  25508. /**
  25509. * Get the Color3 animation type
  25510. */
  25511. static readonly ANIMATIONTYPE_COLOR3: number;
  25512. /**
  25513. * Get the Relative Loop Mode
  25514. */
  25515. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  25516. /**
  25517. * Get the Cycle Loop Mode
  25518. */
  25519. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  25520. /**
  25521. * Get the Constant Loop Mode
  25522. */
  25523. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  25524. /** @hidden */
  25525. static _UniversalLerp(left: any, right: any, amount: number): any;
  25526. /**
  25527. * Parses an animation object and creates an animation
  25528. * @param parsedAnimation Parsed animation object
  25529. * @returns Animation object
  25530. */
  25531. static Parse(parsedAnimation: any): Animation;
  25532. /**
  25533. * Appends the serialized animations from the source animations
  25534. * @param source Source containing the animations
  25535. * @param destination Target to store the animations
  25536. */
  25537. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  25538. }
  25539. }
  25540. declare module "babylonjs/Materials/Textures/baseTexture" {
  25541. import { Observable } from "babylonjs/Misc/observable";
  25542. import { IAnimatable } from "babylonjs/Misc/tools";
  25543. import { Nullable } from "babylonjs/types";
  25544. import { Scene } from "babylonjs/scene";
  25545. import { Matrix, ISize } from "babylonjs/Maths/math";
  25546. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  25547. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  25548. /**
  25549. * Base class of all the textures in babylon.
  25550. * It groups all the common properties the materials, post process, lights... might need
  25551. * in order to make a correct use of the texture.
  25552. */
  25553. export class BaseTexture implements IAnimatable {
  25554. /**
  25555. * Default anisotropic filtering level for the application.
  25556. * It is set to 4 as a good tradeoff between perf and quality.
  25557. */
  25558. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  25559. /**
  25560. * Gets or sets the unique id of the texture
  25561. */
  25562. uniqueId: number;
  25563. /**
  25564. * Define the name of the texture.
  25565. */
  25566. name: string;
  25567. /**
  25568. * Gets or sets an object used to store user defined information.
  25569. */
  25570. metadata: any;
  25571. /**
  25572. * For internal use only. Please do not use.
  25573. */
  25574. reservedDataStore: any;
  25575. private _hasAlpha;
  25576. /**
  25577. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  25578. */
  25579. hasAlpha: boolean;
  25580. /**
  25581. * Defines if the alpha value should be determined via the rgb values.
  25582. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  25583. */
  25584. getAlphaFromRGB: boolean;
  25585. /**
  25586. * Intensity or strength of the texture.
  25587. * It is commonly used by materials to fine tune the intensity of the texture
  25588. */
  25589. level: number;
  25590. /**
  25591. * Define the UV chanel to use starting from 0 and defaulting to 0.
  25592. * This is part of the texture as textures usually maps to one uv set.
  25593. */
  25594. coordinatesIndex: number;
  25595. private _coordinatesMode;
  25596. /**
  25597. * How a texture is mapped.
  25598. *
  25599. * | Value | Type | Description |
  25600. * | ----- | ----------------------------------- | ----------- |
  25601. * | 0 | EXPLICIT_MODE | |
  25602. * | 1 | SPHERICAL_MODE | |
  25603. * | 2 | PLANAR_MODE | |
  25604. * | 3 | CUBIC_MODE | |
  25605. * | 4 | PROJECTION_MODE | |
  25606. * | 5 | SKYBOX_MODE | |
  25607. * | 6 | INVCUBIC_MODE | |
  25608. * | 7 | EQUIRECTANGULAR_MODE | |
  25609. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  25610. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  25611. */
  25612. coordinatesMode: number;
  25613. /**
  25614. * | Value | Type | Description |
  25615. * | ----- | ------------------ | ----------- |
  25616. * | 0 | CLAMP_ADDRESSMODE | |
  25617. * | 1 | WRAP_ADDRESSMODE | |
  25618. * | 2 | MIRROR_ADDRESSMODE | |
  25619. */
  25620. wrapU: number;
  25621. /**
  25622. * | Value | Type | Description |
  25623. * | ----- | ------------------ | ----------- |
  25624. * | 0 | CLAMP_ADDRESSMODE | |
  25625. * | 1 | WRAP_ADDRESSMODE | |
  25626. * | 2 | MIRROR_ADDRESSMODE | |
  25627. */
  25628. wrapV: number;
  25629. /**
  25630. * | Value | Type | Description |
  25631. * | ----- | ------------------ | ----------- |
  25632. * | 0 | CLAMP_ADDRESSMODE | |
  25633. * | 1 | WRAP_ADDRESSMODE | |
  25634. * | 2 | MIRROR_ADDRESSMODE | |
  25635. */
  25636. wrapR: number;
  25637. /**
  25638. * With compliant hardware and browser (supporting anisotropic filtering)
  25639. * this defines the level of anisotropic filtering in the texture.
  25640. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  25641. */
  25642. anisotropicFilteringLevel: number;
  25643. /**
  25644. * Define if the texture is a cube texture or if false a 2d texture.
  25645. */
  25646. isCube: boolean;
  25647. /**
  25648. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  25649. */
  25650. is3D: boolean;
  25651. /**
  25652. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  25653. * HDR texture are usually stored in linear space.
  25654. * This only impacts the PBR and Background materials
  25655. */
  25656. gammaSpace: boolean;
  25657. /**
  25658. * Gets whether or not the texture contains RGBD data.
  25659. */
  25660. readonly isRGBD: boolean;
  25661. /**
  25662. * Is Z inverted in the texture (useful in a cube texture).
  25663. */
  25664. invertZ: boolean;
  25665. /**
  25666. * Are mip maps generated for this texture or not.
  25667. */
  25668. readonly noMipmap: boolean;
  25669. /**
  25670. * @hidden
  25671. */
  25672. lodLevelInAlpha: boolean;
  25673. /**
  25674. * With prefiltered texture, defined the offset used during the prefiltering steps.
  25675. */
  25676. lodGenerationOffset: number;
  25677. /**
  25678. * With prefiltered texture, defined the scale used during the prefiltering steps.
  25679. */
  25680. lodGenerationScale: number;
  25681. /**
  25682. * Define if the texture is a render target.
  25683. */
  25684. isRenderTarget: boolean;
  25685. /**
  25686. * Define the unique id of the texture in the scene.
  25687. */
  25688. readonly uid: string;
  25689. /**
  25690. * Return a string representation of the texture.
  25691. * @returns the texture as a string
  25692. */
  25693. toString(): string;
  25694. /**
  25695. * Get the class name of the texture.
  25696. * @returns "BaseTexture"
  25697. */
  25698. getClassName(): string;
  25699. /**
  25700. * Define the list of animation attached to the texture.
  25701. */
  25702. animations: import("babylonjs/Animations/animation").Animation[];
  25703. /**
  25704. * An event triggered when the texture is disposed.
  25705. */
  25706. onDisposeObservable: Observable<BaseTexture>;
  25707. private _onDisposeObserver;
  25708. /**
  25709. * Callback triggered when the texture has been disposed.
  25710. * Kept for back compatibility, you can use the onDisposeObservable instead.
  25711. */
  25712. onDispose: () => void;
  25713. /**
  25714. * Define the current state of the loading sequence when in delayed load mode.
  25715. */
  25716. delayLoadState: number;
  25717. private _scene;
  25718. /** @hidden */
  25719. _texture: Nullable<InternalTexture>;
  25720. private _uid;
  25721. /**
  25722. * Define if the texture is preventinga material to render or not.
  25723. * If not and the texture is not ready, the engine will use a default black texture instead.
  25724. */
  25725. readonly isBlocking: boolean;
  25726. /**
  25727. * Instantiates a new BaseTexture.
  25728. * Base class of all the textures in babylon.
  25729. * It groups all the common properties the materials, post process, lights... might need
  25730. * in order to make a correct use of the texture.
  25731. * @param scene Define the scene the texture blongs to
  25732. */
  25733. constructor(scene: Nullable<Scene>);
  25734. /**
  25735. * Get the scene the texture belongs to.
  25736. * @returns the scene or null if undefined
  25737. */
  25738. getScene(): Nullable<Scene>;
  25739. /**
  25740. * Get the texture transform matrix used to offset tile the texture for istance.
  25741. * @returns the transformation matrix
  25742. */
  25743. getTextureMatrix(): Matrix;
  25744. /**
  25745. * Get the texture reflection matrix used to rotate/transform the reflection.
  25746. * @returns the reflection matrix
  25747. */
  25748. getReflectionTextureMatrix(): Matrix;
  25749. /**
  25750. * Get the underlying lower level texture from Babylon.
  25751. * @returns the insternal texture
  25752. */
  25753. getInternalTexture(): Nullable<InternalTexture>;
  25754. /**
  25755. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  25756. * @returns true if ready or not blocking
  25757. */
  25758. isReadyOrNotBlocking(): boolean;
  25759. /**
  25760. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  25761. * @returns true if fully ready
  25762. */
  25763. isReady(): boolean;
  25764. private _cachedSize;
  25765. /**
  25766. * Get the size of the texture.
  25767. * @returns the texture size.
  25768. */
  25769. getSize(): ISize;
  25770. /**
  25771. * Get the base size of the texture.
  25772. * It can be different from the size if the texture has been resized for POT for instance
  25773. * @returns the base size
  25774. */
  25775. getBaseSize(): ISize;
  25776. /**
  25777. * Update the sampling mode of the texture.
  25778. * Default is Trilinear mode.
  25779. *
  25780. * | Value | Type | Description |
  25781. * | ----- | ------------------ | ----------- |
  25782. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  25783. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  25784. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  25785. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  25786. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  25787. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  25788. * | 7 | NEAREST_LINEAR | |
  25789. * | 8 | NEAREST_NEAREST | |
  25790. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  25791. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  25792. * | 11 | LINEAR_LINEAR | |
  25793. * | 12 | LINEAR_NEAREST | |
  25794. *
  25795. * > _mag_: magnification filter (close to the viewer)
  25796. * > _min_: minification filter (far from the viewer)
  25797. * > _mip_: filter used between mip map levels
  25798. *@param samplingMode Define the new sampling mode of the texture
  25799. */
  25800. updateSamplingMode(samplingMode: number): void;
  25801. /**
  25802. * Scales the texture if is `canRescale()`
  25803. * @param ratio the resize factor we want to use to rescale
  25804. */
  25805. scale(ratio: number): void;
  25806. /**
  25807. * Get if the texture can rescale.
  25808. */
  25809. readonly canRescale: boolean;
  25810. /** @hidden */
  25811. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  25812. /** @hidden */
  25813. _rebuild(): void;
  25814. /**
  25815. * Triggers the load sequence in delayed load mode.
  25816. */
  25817. delayLoad(): void;
  25818. /**
  25819. * Clones the texture.
  25820. * @returns the cloned texture
  25821. */
  25822. clone(): Nullable<BaseTexture>;
  25823. /**
  25824. * Get the texture underlying type (INT, FLOAT...)
  25825. */
  25826. readonly textureType: number;
  25827. /**
  25828. * Get the texture underlying format (RGB, RGBA...)
  25829. */
  25830. readonly textureFormat: number;
  25831. /**
  25832. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  25833. * This will returns an RGBA array buffer containing either in values (0-255) or
  25834. * float values (0-1) depending of the underlying buffer type.
  25835. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  25836. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  25837. * @param buffer defines a user defined buffer to fill with data (can be null)
  25838. * @returns The Array buffer containing the pixels data.
  25839. */
  25840. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  25841. /**
  25842. * Release and destroy the underlying lower level texture aka internalTexture.
  25843. */
  25844. releaseInternalTexture(): void;
  25845. /**
  25846. * Get the polynomial representation of the texture data.
  25847. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  25848. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  25849. */
  25850. sphericalPolynomial: Nullable<SphericalPolynomial>;
  25851. /** @hidden */
  25852. readonly _lodTextureHigh: Nullable<BaseTexture>;
  25853. /** @hidden */
  25854. readonly _lodTextureMid: Nullable<BaseTexture>;
  25855. /** @hidden */
  25856. readonly _lodTextureLow: Nullable<BaseTexture>;
  25857. /**
  25858. * Dispose the texture and release its associated resources.
  25859. */
  25860. dispose(): void;
  25861. /**
  25862. * Serialize the texture into a JSON representation that can be parsed later on.
  25863. * @returns the JSON representation of the texture
  25864. */
  25865. serialize(): any;
  25866. /**
  25867. * Helper function to be called back once a list of texture contains only ready textures.
  25868. * @param textures Define the list of textures to wait for
  25869. * @param callback Define the callback triggered once the entire list will be ready
  25870. */
  25871. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  25872. }
  25873. }
  25874. declare module "babylonjs/Materials/uniformBuffer" {
  25875. import { Nullable, FloatArray } from "babylonjs/types";
  25876. import { Matrix, Vector3, Color3, Vector4 } from "babylonjs/Maths/math";
  25877. import { Engine } from "babylonjs/Engines/engine";
  25878. import { Effect } from "babylonjs/Materials/effect";
  25879. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  25880. /**
  25881. * Uniform buffer objects.
  25882. *
  25883. * Handles blocks of uniform on the GPU.
  25884. *
  25885. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  25886. *
  25887. * For more information, please refer to :
  25888. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  25889. */
  25890. export class UniformBuffer {
  25891. private _engine;
  25892. private _buffer;
  25893. private _data;
  25894. private _bufferData;
  25895. private _dynamic?;
  25896. private _uniformLocations;
  25897. private _uniformSizes;
  25898. private _uniformLocationPointer;
  25899. private _needSync;
  25900. private _noUBO;
  25901. private _currentEffect;
  25902. private static _MAX_UNIFORM_SIZE;
  25903. private static _tempBuffer;
  25904. /**
  25905. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  25906. * This is dynamic to allow compat with webgl 1 and 2.
  25907. * You will need to pass the name of the uniform as well as the value.
  25908. */
  25909. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  25910. /**
  25911. * Lambda to Update a 2x2 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. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  25916. /**
  25917. * Lambda to Update a single float in a uniform buffer.
  25918. * This is dynamic to allow compat with webgl 1 and 2.
  25919. * You will need to pass the name of the uniform as well as the value.
  25920. */
  25921. updateFloat: (name: string, x: number) => void;
  25922. /**
  25923. * Lambda to Update a vec2 of float in a uniform buffer.
  25924. * This is dynamic to allow compat with webgl 1 and 2.
  25925. * You will need to pass the name of the uniform as well as the value.
  25926. */
  25927. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  25928. /**
  25929. * Lambda to Update a vec3 of float in a uniform buffer.
  25930. * This is dynamic to allow compat with webgl 1 and 2.
  25931. * You will need to pass the name of the uniform as well as the value.
  25932. */
  25933. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  25934. /**
  25935. * Lambda to Update a vec4 of float 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. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  25940. /**
  25941. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  25942. * This is dynamic to allow compat with webgl 1 and 2.
  25943. * You will need to pass the name of the uniform as well as the value.
  25944. */
  25945. updateMatrix: (name: string, mat: Matrix) => void;
  25946. /**
  25947. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  25948. * This is dynamic to allow compat with webgl 1 and 2.
  25949. * You will need to pass the name of the uniform as well as the value.
  25950. */
  25951. updateVector3: (name: string, vector: Vector3) => void;
  25952. /**
  25953. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  25954. * This is dynamic to allow compat with webgl 1 and 2.
  25955. * You will need to pass the name of the uniform as well as the value.
  25956. */
  25957. updateVector4: (name: string, vector: Vector4) => void;
  25958. /**
  25959. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  25960. * This is dynamic to allow compat with webgl 1 and 2.
  25961. * You will need to pass the name of the uniform as well as the value.
  25962. */
  25963. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  25964. /**
  25965. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  25966. * This is dynamic to allow compat with webgl 1 and 2.
  25967. * You will need to pass the name of the uniform as well as the value.
  25968. */
  25969. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  25970. /**
  25971. * Instantiates a new Uniform buffer objects.
  25972. *
  25973. * Handles blocks of uniform on the GPU.
  25974. *
  25975. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  25976. *
  25977. * For more information, please refer to :
  25978. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  25979. * @param engine Define the engine the buffer is associated with
  25980. * @param data Define the data contained in the buffer
  25981. * @param dynamic Define if the buffer is updatable
  25982. */
  25983. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  25984. /**
  25985. * Indicates if the buffer is using the WebGL2 UBO implementation,
  25986. * or just falling back on setUniformXXX calls.
  25987. */
  25988. readonly useUbo: boolean;
  25989. /**
  25990. * Indicates if the WebGL underlying uniform buffer is in sync
  25991. * with the javascript cache data.
  25992. */
  25993. readonly isSync: boolean;
  25994. /**
  25995. * Indicates if the WebGL underlying uniform buffer is dynamic.
  25996. * Also, a dynamic UniformBuffer will disable cache verification and always
  25997. * update the underlying WebGL uniform buffer to the GPU.
  25998. * @returns if Dynamic, otherwise false
  25999. */
  26000. isDynamic(): boolean;
  26001. /**
  26002. * The data cache on JS side.
  26003. * @returns the underlying data as a float array
  26004. */
  26005. getData(): Float32Array;
  26006. /**
  26007. * The underlying WebGL Uniform buffer.
  26008. * @returns the webgl buffer
  26009. */
  26010. getBuffer(): Nullable<WebGLBuffer>;
  26011. /**
  26012. * std140 layout specifies how to align data within an UBO structure.
  26013. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  26014. * for specs.
  26015. */
  26016. private _fillAlignment;
  26017. /**
  26018. * Adds an uniform in the buffer.
  26019. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  26020. * for the layout to be correct !
  26021. * @param name Name of the uniform, as used in the uniform block in the shader.
  26022. * @param size Data size, or data directly.
  26023. */
  26024. addUniform(name: string, size: number | number[]): void;
  26025. /**
  26026. * Adds a Matrix 4x4 to the uniform buffer.
  26027. * @param name Name of the uniform, as used in the uniform block in the shader.
  26028. * @param mat A 4x4 matrix.
  26029. */
  26030. addMatrix(name: string, mat: Matrix): void;
  26031. /**
  26032. * Adds a vec2 to the uniform buffer.
  26033. * @param name Name of the uniform, as used in the uniform block in the shader.
  26034. * @param x Define the x component value of the vec2
  26035. * @param y Define the y component value of the vec2
  26036. */
  26037. addFloat2(name: string, x: number, y: number): void;
  26038. /**
  26039. * Adds a vec3 to the uniform buffer.
  26040. * @param name Name of the uniform, as used in the uniform block in the shader.
  26041. * @param x Define the x component value of the vec3
  26042. * @param y Define the y component value of the vec3
  26043. * @param z Define the z component value of the vec3
  26044. */
  26045. addFloat3(name: string, x: number, y: number, z: number): void;
  26046. /**
  26047. * Adds a vec3 to the uniform buffer.
  26048. * @param name Name of the uniform, as used in the uniform block in the shader.
  26049. * @param color Define the vec3 from a Color
  26050. */
  26051. addColor3(name: string, color: Color3): void;
  26052. /**
  26053. * Adds a vec4 to the uniform buffer.
  26054. * @param name Name of the uniform, as used in the uniform block in the shader.
  26055. * @param color Define the rgb components from a Color
  26056. * @param alpha Define the a component of the vec4
  26057. */
  26058. addColor4(name: string, color: Color3, alpha: number): void;
  26059. /**
  26060. * Adds a vec3 to the uniform buffer.
  26061. * @param name Name of the uniform, as used in the uniform block in the shader.
  26062. * @param vector Define the vec3 components from a Vector
  26063. */
  26064. addVector3(name: string, vector: Vector3): void;
  26065. /**
  26066. * Adds a Matrix 3x3 to the uniform buffer.
  26067. * @param name Name of the uniform, as used in the uniform block in the shader.
  26068. */
  26069. addMatrix3x3(name: string): void;
  26070. /**
  26071. * Adds a Matrix 2x2 to the uniform buffer.
  26072. * @param name Name of the uniform, as used in the uniform block in the shader.
  26073. */
  26074. addMatrix2x2(name: string): void;
  26075. /**
  26076. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  26077. */
  26078. create(): void;
  26079. /** @hidden */
  26080. _rebuild(): void;
  26081. /**
  26082. * Updates the WebGL Uniform Buffer on the GPU.
  26083. * If the `dynamic` flag is set to true, no cache comparison is done.
  26084. * Otherwise, the buffer will be updated only if the cache differs.
  26085. */
  26086. update(): void;
  26087. /**
  26088. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  26089. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  26090. * @param data Define the flattened data
  26091. * @param size Define the size of the data.
  26092. */
  26093. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  26094. private _updateMatrix3x3ForUniform;
  26095. private _updateMatrix3x3ForEffect;
  26096. private _updateMatrix2x2ForEffect;
  26097. private _updateMatrix2x2ForUniform;
  26098. private _updateFloatForEffect;
  26099. private _updateFloatForUniform;
  26100. private _updateFloat2ForEffect;
  26101. private _updateFloat2ForUniform;
  26102. private _updateFloat3ForEffect;
  26103. private _updateFloat3ForUniform;
  26104. private _updateFloat4ForEffect;
  26105. private _updateFloat4ForUniform;
  26106. private _updateMatrixForEffect;
  26107. private _updateMatrixForUniform;
  26108. private _updateVector3ForEffect;
  26109. private _updateVector3ForUniform;
  26110. private _updateVector4ForEffect;
  26111. private _updateVector4ForUniform;
  26112. private _updateColor3ForEffect;
  26113. private _updateColor3ForUniform;
  26114. private _updateColor4ForEffect;
  26115. private _updateColor4ForUniform;
  26116. /**
  26117. * Sets a sampler uniform on the effect.
  26118. * @param name Define the name of the sampler.
  26119. * @param texture Define the texture to set in the sampler
  26120. */
  26121. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  26122. /**
  26123. * Directly updates the value of the uniform in the cache AND on the GPU.
  26124. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  26125. * @param data Define the flattened data
  26126. */
  26127. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  26128. /**
  26129. * Binds this uniform buffer to an effect.
  26130. * @param effect Define the effect to bind the buffer to
  26131. * @param name Name of the uniform block in the shader.
  26132. */
  26133. bindToEffect(effect: Effect, name: string): void;
  26134. /**
  26135. * Disposes the uniform buffer.
  26136. */
  26137. dispose(): void;
  26138. }
  26139. }
  26140. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  26141. import { Nullable } from "babylonjs/types";
  26142. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  26143. /**
  26144. * This represents the required contract to create a new type of texture loader.
  26145. */
  26146. export interface IInternalTextureLoader {
  26147. /**
  26148. * Defines wether the loader supports cascade loading the different faces.
  26149. */
  26150. supportCascades: boolean;
  26151. /**
  26152. * This returns if the loader support the current file information.
  26153. * @param extension defines the file extension of the file being loaded
  26154. * @param textureFormatInUse defines the current compressed format in use iun the engine
  26155. * @param fallback defines the fallback internal texture if any
  26156. * @param isBase64 defines whether the texture is encoded as a base64
  26157. * @param isBuffer defines whether the texture data are stored as a buffer
  26158. * @returns true if the loader can load the specified file
  26159. */
  26160. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  26161. /**
  26162. * Transform the url before loading if required.
  26163. * @param rootUrl the url of the texture
  26164. * @param textureFormatInUse defines the current compressed format in use iun the engine
  26165. * @returns the transformed texture
  26166. */
  26167. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  26168. /**
  26169. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  26170. * @param rootUrl the url of the texture
  26171. * @param textureFormatInUse defines the current compressed format in use iun the engine
  26172. * @returns the fallback texture
  26173. */
  26174. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  26175. /**
  26176. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  26177. * @param data contains the texture data
  26178. * @param texture defines the BabylonJS internal texture
  26179. * @param createPolynomials will be true if polynomials have been requested
  26180. * @param onLoad defines the callback to trigger once the texture is ready
  26181. * @param onError defines the callback to trigger in case of error
  26182. */
  26183. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  26184. /**
  26185. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  26186. * @param data contains the texture data
  26187. * @param texture defines the BabylonJS internal texture
  26188. * @param callback defines the method to call once ready to upload
  26189. */
  26190. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  26191. }
  26192. }
  26193. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  26194. import { Scene } from "babylonjs/scene";
  26195. import { Engine } from "babylonjs/Engines/engine";
  26196. import { Texture } from "babylonjs/Materials/Textures/texture";
  26197. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  26198. /**
  26199. * Creation options of the multi render target texture.
  26200. */
  26201. export interface IMultiRenderTargetOptions {
  26202. /**
  26203. * Define if the texture needs to create mip maps after render.
  26204. */
  26205. generateMipMaps?: boolean;
  26206. /**
  26207. * Define the types of all the draw buffers we want to create
  26208. */
  26209. types?: number[];
  26210. /**
  26211. * Define the sampling modes of all the draw buffers we want to create
  26212. */
  26213. samplingModes?: number[];
  26214. /**
  26215. * Define if a depth buffer is required
  26216. */
  26217. generateDepthBuffer?: boolean;
  26218. /**
  26219. * Define if a stencil buffer is required
  26220. */
  26221. generateStencilBuffer?: boolean;
  26222. /**
  26223. * Define if a depth texture is required instead of a depth buffer
  26224. */
  26225. generateDepthTexture?: boolean;
  26226. /**
  26227. * Define the number of desired draw buffers
  26228. */
  26229. textureCount?: number;
  26230. /**
  26231. * Define if aspect ratio should be adapted to the texture or stay the scene one
  26232. */
  26233. doNotChangeAspectRatio?: boolean;
  26234. /**
  26235. * Define the default type of the buffers we are creating
  26236. */
  26237. defaultType?: number;
  26238. }
  26239. /**
  26240. * A multi render target, like a render target provides the ability to render to a texture.
  26241. * Unlike the render target, it can render to several draw buffers in one draw.
  26242. * This is specially interesting in deferred rendering or for any effects requiring more than
  26243. * just one color from a single pass.
  26244. */
  26245. export class MultiRenderTarget extends RenderTargetTexture {
  26246. private _internalTextures;
  26247. private _textures;
  26248. private _multiRenderTargetOptions;
  26249. /**
  26250. * Get if draw buffers are currently supported by the used hardware and browser.
  26251. */
  26252. readonly isSupported: boolean;
  26253. /**
  26254. * Get the list of textures generated by the multi render target.
  26255. */
  26256. readonly textures: Texture[];
  26257. /**
  26258. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  26259. */
  26260. readonly depthTexture: Texture;
  26261. /**
  26262. * Set the wrapping mode on U of all the textures we are rendering to.
  26263. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  26264. */
  26265. wrapU: number;
  26266. /**
  26267. * Set the wrapping mode on V of all the textures we are rendering to.
  26268. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  26269. */
  26270. wrapV: number;
  26271. /**
  26272. * Instantiate a new multi render target texture.
  26273. * A multi render target, like a render target provides the ability to render to a texture.
  26274. * Unlike the render target, it can render to several draw buffers in one draw.
  26275. * This is specially interesting in deferred rendering or for any effects requiring more than
  26276. * just one color from a single pass.
  26277. * @param name Define the name of the texture
  26278. * @param size Define the size of the buffers to render to
  26279. * @param count Define the number of target we are rendering into
  26280. * @param scene Define the scene the texture belongs to
  26281. * @param options Define the options used to create the multi render target
  26282. */
  26283. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  26284. /** @hidden */
  26285. _rebuild(): void;
  26286. private _createInternalTextures;
  26287. private _createTextures;
  26288. /**
  26289. * Define the number of samples used if MSAA is enabled.
  26290. */
  26291. samples: number;
  26292. /**
  26293. * Resize all the textures in the multi render target.
  26294. * Be carrefull as it will recreate all the data in the new texture.
  26295. * @param size Define the new size
  26296. */
  26297. resize(size: any): void;
  26298. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  26299. /**
  26300. * Dispose the render targets and their associated resources
  26301. */
  26302. dispose(): void;
  26303. /**
  26304. * Release all the underlying texture used as draw buffers.
  26305. */
  26306. releaseInternalTextures(): void;
  26307. }
  26308. }
  26309. declare module "babylonjs/Audio/analyser" {
  26310. import { Scene } from "babylonjs/scene";
  26311. /**
  26312. * Class used to work with sound analyzer using fast fourier transform (FFT)
  26313. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26314. */
  26315. export class Analyser {
  26316. /**
  26317. * Gets or sets the smoothing
  26318. * @ignorenaming
  26319. */
  26320. SMOOTHING: number;
  26321. /**
  26322. * Gets or sets the FFT table size
  26323. * @ignorenaming
  26324. */
  26325. FFT_SIZE: number;
  26326. /**
  26327. * Gets or sets the bar graph amplitude
  26328. * @ignorenaming
  26329. */
  26330. BARGRAPHAMPLITUDE: number;
  26331. /**
  26332. * Gets or sets the position of the debug canvas
  26333. * @ignorenaming
  26334. */
  26335. DEBUGCANVASPOS: {
  26336. x: number;
  26337. y: number;
  26338. };
  26339. /**
  26340. * Gets or sets the debug canvas size
  26341. * @ignorenaming
  26342. */
  26343. DEBUGCANVASSIZE: {
  26344. width: number;
  26345. height: number;
  26346. };
  26347. private _byteFreqs;
  26348. private _byteTime;
  26349. private _floatFreqs;
  26350. private _webAudioAnalyser;
  26351. private _debugCanvas;
  26352. private _debugCanvasContext;
  26353. private _scene;
  26354. private _registerFunc;
  26355. private _audioEngine;
  26356. /**
  26357. * Creates a new analyser
  26358. * @param scene defines hosting scene
  26359. */
  26360. constructor(scene: Scene);
  26361. /**
  26362. * Get the number of data values you will have to play with for the visualization
  26363. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  26364. * @returns a number
  26365. */
  26366. getFrequencyBinCount(): number;
  26367. /**
  26368. * Gets the current frequency data as a byte array
  26369. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  26370. * @returns a Uint8Array
  26371. */
  26372. getByteFrequencyData(): Uint8Array;
  26373. /**
  26374. * Gets the current waveform as a byte array
  26375. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  26376. * @returns a Uint8Array
  26377. */
  26378. getByteTimeDomainData(): Uint8Array;
  26379. /**
  26380. * Gets the current frequency data as a float array
  26381. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  26382. * @returns a Float32Array
  26383. */
  26384. getFloatFrequencyData(): Float32Array;
  26385. /**
  26386. * Renders the debug canvas
  26387. */
  26388. drawDebugCanvas(): void;
  26389. /**
  26390. * Stops rendering the debug canvas and removes it
  26391. */
  26392. stopDebugCanvas(): void;
  26393. /**
  26394. * Connects two audio nodes
  26395. * @param inputAudioNode defines first node to connect
  26396. * @param outputAudioNode defines second node to connect
  26397. */
  26398. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  26399. /**
  26400. * Releases all associated resources
  26401. */
  26402. dispose(): void;
  26403. }
  26404. }
  26405. declare module "babylonjs/Audio/audioEngine" {
  26406. import { IDisposable } from "babylonjs/scene";
  26407. import { Analyser } from "babylonjs/Audio/analyser";
  26408. import { Nullable } from "babylonjs/types";
  26409. import { Observable } from "babylonjs/Misc/observable";
  26410. /**
  26411. * This represents an audio engine and it is responsible
  26412. * to play, synchronize and analyse sounds throughout the application.
  26413. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26414. */
  26415. export interface IAudioEngine extends IDisposable {
  26416. /**
  26417. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  26418. */
  26419. readonly canUseWebAudio: boolean;
  26420. /**
  26421. * Gets the current AudioContext if available.
  26422. */
  26423. readonly audioContext: Nullable<AudioContext>;
  26424. /**
  26425. * The master gain node defines the global audio volume of your audio engine.
  26426. */
  26427. readonly masterGain: GainNode;
  26428. /**
  26429. * Gets whether or not mp3 are supported by your browser.
  26430. */
  26431. readonly isMP3supported: boolean;
  26432. /**
  26433. * Gets whether or not ogg are supported by your browser.
  26434. */
  26435. readonly isOGGsupported: boolean;
  26436. /**
  26437. * Defines if Babylon should emit a warning if WebAudio is not supported.
  26438. * @ignoreNaming
  26439. */
  26440. WarnedWebAudioUnsupported: boolean;
  26441. /**
  26442. * Defines if the audio engine relies on a custom unlocked button.
  26443. * In this case, the embedded button will not be displayed.
  26444. */
  26445. useCustomUnlockedButton: boolean;
  26446. /**
  26447. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  26448. */
  26449. readonly unlocked: boolean;
  26450. /**
  26451. * Event raised when audio has been unlocked on the browser.
  26452. */
  26453. onAudioUnlockedObservable: Observable<AudioEngine>;
  26454. /**
  26455. * Event raised when audio has been locked on the browser.
  26456. */
  26457. onAudioLockedObservable: Observable<AudioEngine>;
  26458. /**
  26459. * Flags the audio engine in Locked state.
  26460. * This happens due to new browser policies preventing audio to autoplay.
  26461. */
  26462. lock(): void;
  26463. /**
  26464. * Unlocks the audio engine once a user action has been done on the dom.
  26465. * This is helpful to resume play once browser policies have been satisfied.
  26466. */
  26467. unlock(): void;
  26468. }
  26469. /**
  26470. * This represents the default audio engine used in babylon.
  26471. * It is responsible to play, synchronize and analyse sounds throughout the application.
  26472. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26473. */
  26474. export class AudioEngine implements IAudioEngine {
  26475. private _audioContext;
  26476. private _audioContextInitialized;
  26477. private _muteButton;
  26478. private _hostElement;
  26479. /**
  26480. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  26481. */
  26482. canUseWebAudio: boolean;
  26483. /**
  26484. * The master gain node defines the global audio volume of your audio engine.
  26485. */
  26486. masterGain: GainNode;
  26487. /**
  26488. * Defines if Babylon should emit a warning if WebAudio is not supported.
  26489. * @ignoreNaming
  26490. */
  26491. WarnedWebAudioUnsupported: boolean;
  26492. /**
  26493. * Gets whether or not mp3 are supported by your browser.
  26494. */
  26495. isMP3supported: boolean;
  26496. /**
  26497. * Gets whether or not ogg are supported by your browser.
  26498. */
  26499. isOGGsupported: boolean;
  26500. /**
  26501. * Gets whether audio has been unlocked on the device.
  26502. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  26503. * a user interaction has happened.
  26504. */
  26505. unlocked: boolean;
  26506. /**
  26507. * Defines if the audio engine relies on a custom unlocked button.
  26508. * In this case, the embedded button will not be displayed.
  26509. */
  26510. useCustomUnlockedButton: boolean;
  26511. /**
  26512. * Event raised when audio has been unlocked on the browser.
  26513. */
  26514. onAudioUnlockedObservable: Observable<AudioEngine>;
  26515. /**
  26516. * Event raised when audio has been locked on the browser.
  26517. */
  26518. onAudioLockedObservable: Observable<AudioEngine>;
  26519. /**
  26520. * Gets the current AudioContext if available.
  26521. */
  26522. readonly audioContext: Nullable<AudioContext>;
  26523. private _connectedAnalyser;
  26524. /**
  26525. * Instantiates a new audio engine.
  26526. *
  26527. * There should be only one per page as some browsers restrict the number
  26528. * of audio contexts you can create.
  26529. * @param hostElement defines the host element where to display the mute icon if necessary
  26530. */
  26531. constructor(hostElement?: Nullable<HTMLElement>);
  26532. /**
  26533. * Flags the audio engine in Locked state.
  26534. * This happens due to new browser policies preventing audio to autoplay.
  26535. */
  26536. lock(): void;
  26537. /**
  26538. * Unlocks the audio engine once a user action has been done on the dom.
  26539. * This is helpful to resume play once browser policies have been satisfied.
  26540. */
  26541. unlock(): void;
  26542. private _resumeAudioContext;
  26543. private _initializeAudioContext;
  26544. private _tryToRun;
  26545. private _triggerRunningState;
  26546. private _triggerSuspendedState;
  26547. private _displayMuteButton;
  26548. private _moveButtonToTopLeft;
  26549. private _onResize;
  26550. private _hideMuteButton;
  26551. /**
  26552. * Destroy and release the resources associated with the audio ccontext.
  26553. */
  26554. dispose(): void;
  26555. /**
  26556. * Gets the global volume sets on the master gain.
  26557. * @returns the global volume if set or -1 otherwise
  26558. */
  26559. getGlobalVolume(): number;
  26560. /**
  26561. * Sets the global volume of your experience (sets on the master gain).
  26562. * @param newVolume Defines the new global volume of the application
  26563. */
  26564. setGlobalVolume(newVolume: number): void;
  26565. /**
  26566. * Connect the audio engine to an audio analyser allowing some amazing
  26567. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  26568. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  26569. * @param analyser The analyser to connect to the engine
  26570. */
  26571. connectToAnalyser(analyser: Analyser): void;
  26572. }
  26573. }
  26574. declare module "babylonjs/Loading/loadingScreen" {
  26575. /**
  26576. * Interface used to present a loading screen while loading a scene
  26577. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  26578. */
  26579. export interface ILoadingScreen {
  26580. /**
  26581. * Function called to display the loading screen
  26582. */
  26583. displayLoadingUI: () => void;
  26584. /**
  26585. * Function called to hide the loading screen
  26586. */
  26587. hideLoadingUI: () => void;
  26588. /**
  26589. * Gets or sets the color to use for the background
  26590. */
  26591. loadingUIBackgroundColor: string;
  26592. /**
  26593. * Gets or sets the text to display while loading
  26594. */
  26595. loadingUIText: string;
  26596. }
  26597. /**
  26598. * Class used for the default loading screen
  26599. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  26600. */
  26601. export class DefaultLoadingScreen implements ILoadingScreen {
  26602. private _renderingCanvas;
  26603. private _loadingText;
  26604. private _loadingDivBackgroundColor;
  26605. private _loadingDiv;
  26606. private _loadingTextDiv;
  26607. /**
  26608. * Creates a new default loading screen
  26609. * @param _renderingCanvas defines the canvas used to render the scene
  26610. * @param _loadingText defines the default text to display
  26611. * @param _loadingDivBackgroundColor defines the default background color
  26612. */
  26613. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  26614. /**
  26615. * Function called to display the loading screen
  26616. */
  26617. displayLoadingUI(): void;
  26618. /**
  26619. * Function called to hide the loading screen
  26620. */
  26621. hideLoadingUI(): void;
  26622. /**
  26623. * Gets or sets the text to display while loading
  26624. */
  26625. loadingUIText: string;
  26626. /**
  26627. * Gets or sets the color to use for the background
  26628. */
  26629. loadingUIBackgroundColor: string;
  26630. private _resizeLoadingUI;
  26631. }
  26632. }
  26633. declare module "babylonjs/Materials/Textures/videoTexture" {
  26634. import { Observable } from "babylonjs/Misc/observable";
  26635. import { Nullable } from "babylonjs/types";
  26636. import { Scene } from "babylonjs/scene";
  26637. import { Texture } from "babylonjs/Materials/Textures/texture";
  26638. /**
  26639. * Settings for finer control over video usage
  26640. */
  26641. export interface VideoTextureSettings {
  26642. /**
  26643. * Applies `autoplay` to video, if specified
  26644. */
  26645. autoPlay?: boolean;
  26646. /**
  26647. * Applies `loop` to video, if specified
  26648. */
  26649. loop?: boolean;
  26650. /**
  26651. * Automatically updates internal texture from video at every frame in the render loop
  26652. */
  26653. autoUpdateTexture: boolean;
  26654. /**
  26655. * Image src displayed during the video loading or until the user interacts with the video.
  26656. */
  26657. poster?: string;
  26658. }
  26659. /**
  26660. * If you want to display a video in your scene, this is the special texture for that.
  26661. * This special texture works similar to other textures, with the exception of a few parameters.
  26662. * @see https://doc.babylonjs.com/how_to/video_texture
  26663. */
  26664. export class VideoTexture extends Texture {
  26665. /**
  26666. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  26667. */
  26668. readonly autoUpdateTexture: boolean;
  26669. /**
  26670. * The video instance used by the texture internally
  26671. */
  26672. readonly video: HTMLVideoElement;
  26673. private _onUserActionRequestedObservable;
  26674. /**
  26675. * Event triggerd when a dom action is required by the user to play the video.
  26676. * This happens due to recent changes in browser policies preventing video to auto start.
  26677. */
  26678. readonly onUserActionRequestedObservable: Observable<Texture>;
  26679. private _generateMipMaps;
  26680. private _engine;
  26681. private _stillImageCaptured;
  26682. private _displayingPosterTexture;
  26683. private _settings;
  26684. private _createInternalTextureOnEvent;
  26685. /**
  26686. * Creates a video texture.
  26687. * If you want to display a video in your scene, this is the special texture for that.
  26688. * This special texture works similar to other textures, with the exception of a few parameters.
  26689. * @see https://doc.babylonjs.com/how_to/video_texture
  26690. * @param name optional name, will detect from video source, if not defined
  26691. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  26692. * @param scene is obviously the current scene.
  26693. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  26694. * @param invertY is false by default but can be used to invert video on Y axis
  26695. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  26696. * @param settings allows finer control over video usage
  26697. */
  26698. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  26699. private _getName;
  26700. private _getVideo;
  26701. private _createInternalTexture;
  26702. private reset;
  26703. /**
  26704. * @hidden Internal method to initiate `update`.
  26705. */
  26706. _rebuild(): void;
  26707. /**
  26708. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  26709. */
  26710. update(): void;
  26711. /**
  26712. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  26713. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  26714. */
  26715. updateTexture(isVisible: boolean): void;
  26716. protected _updateInternalTexture: () => void;
  26717. /**
  26718. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  26719. * @param url New url.
  26720. */
  26721. updateURL(url: string): void;
  26722. /**
  26723. * Dispose the texture and release its associated resources.
  26724. */
  26725. dispose(): void;
  26726. /**
  26727. * Creates a video texture straight from a stream.
  26728. * @param scene Define the scene the texture should be created in
  26729. * @param stream Define the stream the texture should be created from
  26730. * @returns The created video texture as a promise
  26731. */
  26732. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  26733. /**
  26734. * Creates a video texture straight from your WebCam video feed.
  26735. * @param scene Define the scene the texture should be created in
  26736. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  26737. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  26738. * @returns The created video texture as a promise
  26739. */
  26740. static CreateFromWebCamAsync(scene: Scene, constraints: {
  26741. minWidth: number;
  26742. maxWidth: number;
  26743. minHeight: number;
  26744. maxHeight: number;
  26745. deviceId: string;
  26746. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  26747. /**
  26748. * Creates a video texture straight from your WebCam video feed.
  26749. * @param scene Define the scene the texture should be created in
  26750. * @param onReady Define a callback to triggered once the texture will be ready
  26751. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  26752. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  26753. */
  26754. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  26755. minWidth: number;
  26756. maxWidth: number;
  26757. minHeight: number;
  26758. maxHeight: number;
  26759. deviceId: string;
  26760. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  26761. }
  26762. }
  26763. declare module "babylonjs/Engines/engine" {
  26764. import { Observable } from "babylonjs/Misc/observable";
  26765. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  26766. import { ICustomAnimationFrameRequester, PerfCounter, IFileRequest } from "babylonjs/Misc/tools";
  26767. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  26768. import { Camera } from "babylonjs/Cameras/camera";
  26769. import { Scene } from "babylonjs/scene";
  26770. import { Matrix, Color3, Color4, Viewport } from "babylonjs/Maths/math";
  26771. import { IDisplayChangedEventArgs } from "babylonjs/Engines/engine";
  26772. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  26773. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  26774. import { Effect, EffectCreationOptions, EffectFallbacks } from "babylonjs/Materials/effect";
  26775. import { Material } from "babylonjs/Materials/material";
  26776. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  26777. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  26778. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  26779. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  26780. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  26781. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  26782. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  26783. import { _DepthCullingState, _StencilState, _AlphaState } from "babylonjs/States/index";
  26784. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  26785. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  26786. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  26787. /**
  26788. * Interface for attribute information associated with buffer instanciation
  26789. */
  26790. export class InstancingAttributeInfo {
  26791. /**
  26792. * Index/offset of the attribute in the vertex shader
  26793. */
  26794. index: number;
  26795. /**
  26796. * size of the attribute, 1, 2, 3 or 4
  26797. */
  26798. attributeSize: number;
  26799. /**
  26800. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  26801. * default is FLOAT
  26802. */
  26803. attribyteType: number;
  26804. /**
  26805. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  26806. */
  26807. normalized: boolean;
  26808. /**
  26809. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  26810. */
  26811. offset: number;
  26812. /**
  26813. * Name of the GLSL attribute, for debugging purpose only
  26814. */
  26815. attributeName: string;
  26816. }
  26817. /**
  26818. * Define options used to create a depth texture
  26819. */
  26820. export class DepthTextureCreationOptions {
  26821. /** Specifies whether or not a stencil should be allocated in the texture */
  26822. generateStencil?: boolean;
  26823. /** Specifies whether or not bilinear filtering is enable on the texture */
  26824. bilinearFiltering?: boolean;
  26825. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  26826. comparisonFunction?: number;
  26827. /** Specifies if the created texture is a cube texture */
  26828. isCube?: boolean;
  26829. }
  26830. /**
  26831. * Class used to describe the capabilities of the engine relatively to the current browser
  26832. */
  26833. export class EngineCapabilities {
  26834. /** Maximum textures units per fragment shader */
  26835. maxTexturesImageUnits: number;
  26836. /** Maximum texture units per vertex shader */
  26837. maxVertexTextureImageUnits: number;
  26838. /** Maximum textures units in the entire pipeline */
  26839. maxCombinedTexturesImageUnits: number;
  26840. /** Maximum texture size */
  26841. maxTextureSize: number;
  26842. /** Maximum cube texture size */
  26843. maxCubemapTextureSize: number;
  26844. /** Maximum render texture size */
  26845. maxRenderTextureSize: number;
  26846. /** Maximum number of vertex attributes */
  26847. maxVertexAttribs: number;
  26848. /** Maximum number of varyings */
  26849. maxVaryingVectors: number;
  26850. /** Maximum number of uniforms per vertex shader */
  26851. maxVertexUniformVectors: number;
  26852. /** Maximum number of uniforms per fragment shader */
  26853. maxFragmentUniformVectors: number;
  26854. /** Defines if standard derivates (dx/dy) are supported */
  26855. standardDerivatives: boolean;
  26856. /** Defines if s3tc texture compression is supported */
  26857. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  26858. /** Defines if pvrtc texture compression is supported */
  26859. pvrtc: any;
  26860. /** Defines if etc1 texture compression is supported */
  26861. etc1: any;
  26862. /** Defines if etc2 texture compression is supported */
  26863. etc2: any;
  26864. /** Defines if astc texture compression is supported */
  26865. astc: any;
  26866. /** Defines if float textures are supported */
  26867. textureFloat: boolean;
  26868. /** Defines if vertex array objects are supported */
  26869. vertexArrayObject: boolean;
  26870. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  26871. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  26872. /** Gets the maximum level of anisotropy supported */
  26873. maxAnisotropy: number;
  26874. /** Defines if instancing is supported */
  26875. instancedArrays: boolean;
  26876. /** Defines if 32 bits indices are supported */
  26877. uintIndices: boolean;
  26878. /** Defines if high precision shaders are supported */
  26879. highPrecisionShaderSupported: boolean;
  26880. /** Defines if depth reading in the fragment shader is supported */
  26881. fragmentDepthSupported: boolean;
  26882. /** Defines if float texture linear filtering is supported*/
  26883. textureFloatLinearFiltering: boolean;
  26884. /** Defines if rendering to float textures is supported */
  26885. textureFloatRender: boolean;
  26886. /** Defines if half float textures are supported*/
  26887. textureHalfFloat: boolean;
  26888. /** Defines if half float texture linear filtering is supported*/
  26889. textureHalfFloatLinearFiltering: boolean;
  26890. /** Defines if rendering to half float textures is supported */
  26891. textureHalfFloatRender: boolean;
  26892. /** Defines if textureLOD shader command is supported */
  26893. textureLOD: boolean;
  26894. /** Defines if draw buffers extension is supported */
  26895. drawBuffersExtension: boolean;
  26896. /** Defines if depth textures are supported */
  26897. depthTextureExtension: boolean;
  26898. /** Defines if float color buffer are supported */
  26899. colorBufferFloat: boolean;
  26900. /** Gets disjoint timer query extension (null if not supported) */
  26901. timerQuery: EXT_disjoint_timer_query;
  26902. /** Defines if timestamp can be used with timer query */
  26903. canUseTimestampForTimerQuery: boolean;
  26904. /** Function used to let the system compiles shaders in background */
  26905. parallelShaderCompile: {
  26906. MAX_SHADER_COMPILER_THREADS_KHR: number;
  26907. maxShaderCompilerThreadsKHR: (thread: number) => void;
  26908. COMPLETION_STATUS_KHR: number;
  26909. };
  26910. }
  26911. /** Interface defining initialization parameters for Engine class */
  26912. export interface EngineOptions extends WebGLContextAttributes {
  26913. /**
  26914. * Defines if the engine should no exceed a specified device ratio
  26915. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  26916. */
  26917. limitDeviceRatio?: number;
  26918. /**
  26919. * Defines if webvr should be enabled automatically
  26920. * @see http://doc.babylonjs.com/how_to/webvr_camera
  26921. */
  26922. autoEnableWebVR?: boolean;
  26923. /**
  26924. * Defines if webgl2 should be turned off even if supported
  26925. * @see http://doc.babylonjs.com/features/webgl2
  26926. */
  26927. disableWebGL2Support?: boolean;
  26928. /**
  26929. * Defines if webaudio should be initialized as well
  26930. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26931. */
  26932. audioEngine?: boolean;
  26933. /**
  26934. * Defines if animations should run using a deterministic lock step
  26935. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  26936. */
  26937. deterministicLockstep?: boolean;
  26938. /** Defines the maximum steps to use with deterministic lock step mode */
  26939. lockstepMaxSteps?: number;
  26940. /**
  26941. * Defines that engine should ignore context lost events
  26942. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  26943. */
  26944. doNotHandleContextLost?: boolean;
  26945. /**
  26946. * Defines that engine should ignore modifying touch action attribute and style
  26947. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  26948. */
  26949. doNotHandleTouchAction?: boolean;
  26950. }
  26951. /**
  26952. * Defines the interface used by display changed events
  26953. */
  26954. export interface IDisplayChangedEventArgs {
  26955. /** Gets the vrDisplay object (if any) */
  26956. vrDisplay: Nullable<any>;
  26957. /** Gets a boolean indicating if webVR is supported */
  26958. vrSupported: boolean;
  26959. }
  26960. /**
  26961. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  26962. */
  26963. export class Engine {
  26964. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  26965. static ExceptionList: ({
  26966. key: string;
  26967. capture: string;
  26968. captureConstraint: number;
  26969. targets: string[];
  26970. } | {
  26971. key: string;
  26972. capture: null;
  26973. captureConstraint: null;
  26974. targets: string[];
  26975. })[];
  26976. /** Gets the list of created engines */
  26977. static readonly Instances: Engine[];
  26978. /**
  26979. * Gets the latest created engine
  26980. */
  26981. static readonly LastCreatedEngine: Nullable<Engine>;
  26982. /**
  26983. * Gets the latest created scene
  26984. */
  26985. static readonly LastCreatedScene: Nullable<Scene>;
  26986. /**
  26987. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  26988. * @param flag defines which part of the materials must be marked as dirty
  26989. * @param predicate defines a predicate used to filter which materials should be affected
  26990. */
  26991. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  26992. /**
  26993. * Hidden
  26994. */
  26995. static _TextureLoaders: IInternalTextureLoader[];
  26996. /** Defines that alpha blending is disabled */
  26997. static readonly ALPHA_DISABLE: number;
  26998. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  26999. static readonly ALPHA_ADD: number;
  27000. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  27001. static readonly ALPHA_COMBINE: number;
  27002. /** Defines that alpha blending to DEST - SRC * DEST */
  27003. static readonly ALPHA_SUBTRACT: number;
  27004. /** Defines that alpha blending to SRC * DEST */
  27005. static readonly ALPHA_MULTIPLY: number;
  27006. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  27007. static readonly ALPHA_MAXIMIZED: number;
  27008. /** Defines that alpha blending to SRC + DEST */
  27009. static readonly ALPHA_ONEONE: number;
  27010. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  27011. static readonly ALPHA_PREMULTIPLIED: number;
  27012. /**
  27013. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  27014. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  27015. */
  27016. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  27017. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  27018. static readonly ALPHA_INTERPOLATE: number;
  27019. /**
  27020. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  27021. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  27022. */
  27023. static readonly ALPHA_SCREENMODE: number;
  27024. /** Defines that the ressource is not delayed*/
  27025. static readonly DELAYLOADSTATE_NONE: number;
  27026. /** Defines that the ressource was successfully delay loaded */
  27027. static readonly DELAYLOADSTATE_LOADED: number;
  27028. /** Defines that the ressource is currently delay loading */
  27029. static readonly DELAYLOADSTATE_LOADING: number;
  27030. /** Defines that the ressource is delayed and has not started loading */
  27031. static readonly DELAYLOADSTATE_NOTLOADED: number;
  27032. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  27033. static readonly NEVER: number;
  27034. /** 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 */
  27035. static readonly ALWAYS: number;
  27036. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  27037. static readonly LESS: number;
  27038. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  27039. static readonly EQUAL: number;
  27040. /** 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 */
  27041. static readonly LEQUAL: number;
  27042. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  27043. static readonly GREATER: number;
  27044. /** 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 */
  27045. static readonly GEQUAL: number;
  27046. /** 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 */
  27047. static readonly NOTEQUAL: number;
  27048. /** Passed to stencilOperation to specify that stencil value must be kept */
  27049. static readonly KEEP: number;
  27050. /** Passed to stencilOperation to specify that stencil value must be replaced */
  27051. static readonly REPLACE: number;
  27052. /** Passed to stencilOperation to specify that stencil value must be incremented */
  27053. static readonly INCR: number;
  27054. /** Passed to stencilOperation to specify that stencil value must be decremented */
  27055. static readonly DECR: number;
  27056. /** Passed to stencilOperation to specify that stencil value must be inverted */
  27057. static readonly INVERT: number;
  27058. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  27059. static readonly INCR_WRAP: number;
  27060. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  27061. static readonly DECR_WRAP: number;
  27062. /** Texture is not repeating outside of 0..1 UVs */
  27063. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  27064. /** Texture is repeating outside of 0..1 UVs */
  27065. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  27066. /** Texture is repeating and mirrored */
  27067. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  27068. /** ALPHA */
  27069. static readonly TEXTUREFORMAT_ALPHA: number;
  27070. /** LUMINANCE */
  27071. static readonly TEXTUREFORMAT_LUMINANCE: number;
  27072. /** LUMINANCE_ALPHA */
  27073. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  27074. /** RGB */
  27075. static readonly TEXTUREFORMAT_RGB: number;
  27076. /** RGBA */
  27077. static readonly TEXTUREFORMAT_RGBA: number;
  27078. /** RED */
  27079. static readonly TEXTUREFORMAT_RED: number;
  27080. /** RED (2nd reference) */
  27081. static readonly TEXTUREFORMAT_R: number;
  27082. /** RG */
  27083. static readonly TEXTUREFORMAT_RG: number;
  27084. /** RED_INTEGER */
  27085. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  27086. /** RED_INTEGER (2nd reference) */
  27087. static readonly TEXTUREFORMAT_R_INTEGER: number;
  27088. /** RG_INTEGER */
  27089. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  27090. /** RGB_INTEGER */
  27091. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  27092. /** RGBA_INTEGER */
  27093. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  27094. /** UNSIGNED_BYTE */
  27095. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  27096. /** UNSIGNED_BYTE (2nd reference) */
  27097. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  27098. /** FLOAT */
  27099. static readonly TEXTURETYPE_FLOAT: number;
  27100. /** HALF_FLOAT */
  27101. static readonly TEXTURETYPE_HALF_FLOAT: number;
  27102. /** BYTE */
  27103. static readonly TEXTURETYPE_BYTE: number;
  27104. /** SHORT */
  27105. static readonly TEXTURETYPE_SHORT: number;
  27106. /** UNSIGNED_SHORT */
  27107. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  27108. /** INT */
  27109. static readonly TEXTURETYPE_INT: number;
  27110. /** UNSIGNED_INT */
  27111. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  27112. /** UNSIGNED_SHORT_4_4_4_4 */
  27113. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  27114. /** UNSIGNED_SHORT_5_5_5_1 */
  27115. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  27116. /** UNSIGNED_SHORT_5_6_5 */
  27117. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  27118. /** UNSIGNED_INT_2_10_10_10_REV */
  27119. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  27120. /** UNSIGNED_INT_24_8 */
  27121. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  27122. /** UNSIGNED_INT_10F_11F_11F_REV */
  27123. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  27124. /** UNSIGNED_INT_5_9_9_9_REV */
  27125. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  27126. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  27127. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  27128. /** nearest is mag = nearest and min = nearest and mip = linear */
  27129. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  27130. /** Bilinear is mag = linear and min = linear and mip = nearest */
  27131. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  27132. /** Trilinear is mag = linear and min = linear and mip = linear */
  27133. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  27134. /** nearest is mag = nearest and min = nearest and mip = linear */
  27135. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  27136. /** Bilinear is mag = linear and min = linear and mip = nearest */
  27137. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  27138. /** Trilinear is mag = linear and min = linear and mip = linear */
  27139. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  27140. /** mag = nearest and min = nearest and mip = nearest */
  27141. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  27142. /** mag = nearest and min = linear and mip = nearest */
  27143. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  27144. /** mag = nearest and min = linear and mip = linear */
  27145. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  27146. /** mag = nearest and min = linear and mip = none */
  27147. static readonly TEXTURE_NEAREST_LINEAR: number;
  27148. /** mag = nearest and min = nearest and mip = none */
  27149. static readonly TEXTURE_NEAREST_NEAREST: number;
  27150. /** mag = linear and min = nearest and mip = nearest */
  27151. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  27152. /** mag = linear and min = nearest and mip = linear */
  27153. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  27154. /** mag = linear and min = linear and mip = none */
  27155. static readonly TEXTURE_LINEAR_LINEAR: number;
  27156. /** mag = linear and min = nearest and mip = none */
  27157. static readonly TEXTURE_LINEAR_NEAREST: number;
  27158. /** Explicit coordinates mode */
  27159. static readonly TEXTURE_EXPLICIT_MODE: number;
  27160. /** Spherical coordinates mode */
  27161. static readonly TEXTURE_SPHERICAL_MODE: number;
  27162. /** Planar coordinates mode */
  27163. static readonly TEXTURE_PLANAR_MODE: number;
  27164. /** Cubic coordinates mode */
  27165. static readonly TEXTURE_CUBIC_MODE: number;
  27166. /** Projection coordinates mode */
  27167. static readonly TEXTURE_PROJECTION_MODE: number;
  27168. /** Skybox coordinates mode */
  27169. static readonly TEXTURE_SKYBOX_MODE: number;
  27170. /** Inverse Cubic coordinates mode */
  27171. static readonly TEXTURE_INVCUBIC_MODE: number;
  27172. /** Equirectangular coordinates mode */
  27173. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  27174. /** Equirectangular Fixed coordinates mode */
  27175. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  27176. /** Equirectangular Fixed Mirrored coordinates mode */
  27177. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  27178. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  27179. static readonly SCALEMODE_FLOOR: number;
  27180. /** Defines that texture rescaling will look for the nearest power of 2 size */
  27181. static readonly SCALEMODE_NEAREST: number;
  27182. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  27183. static readonly SCALEMODE_CEILING: number;
  27184. /**
  27185. * Returns the current version of the framework
  27186. */
  27187. static readonly Version: string;
  27188. /**
  27189. * Returns a string describing the current engine
  27190. */
  27191. readonly description: string;
  27192. /**
  27193. * Gets or sets the epsilon value used by collision engine
  27194. */
  27195. static CollisionsEpsilon: number;
  27196. /**
  27197. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  27198. */
  27199. static ShadersRepository: string;
  27200. /**
  27201. * Method called to create the default loading screen.
  27202. * This can be overriden in your own app.
  27203. * @param canvas The rendering canvas element
  27204. * @returns The loading screen
  27205. */
  27206. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  27207. /**
  27208. * Method called to create the default rescale post process on each engine.
  27209. */
  27210. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  27211. /**
  27212. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  27213. */
  27214. forcePOTTextures: boolean;
  27215. /**
  27216. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  27217. */
  27218. isFullscreen: boolean;
  27219. /**
  27220. * Gets a boolean indicating if the pointer is currently locked
  27221. */
  27222. isPointerLock: boolean;
  27223. /**
  27224. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  27225. */
  27226. cullBackFaces: boolean;
  27227. /**
  27228. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  27229. */
  27230. renderEvenInBackground: boolean;
  27231. /**
  27232. * Gets or sets a boolean indicating that cache can be kept between frames
  27233. */
  27234. preventCacheWipeBetweenFrames: boolean;
  27235. /**
  27236. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  27237. **/
  27238. enableOfflineSupport: boolean;
  27239. /**
  27240. * 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)
  27241. **/
  27242. disableManifestCheck: boolean;
  27243. /**
  27244. * Gets the list of created scenes
  27245. */
  27246. scenes: Scene[];
  27247. /**
  27248. * Event raised when a new scene is created
  27249. */
  27250. onNewSceneAddedObservable: Observable<Scene>;
  27251. /**
  27252. * Gets the list of created postprocesses
  27253. */
  27254. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  27255. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  27256. validateShaderPrograms: boolean;
  27257. /**
  27258. * Observable event triggered each time the rendering canvas is resized
  27259. */
  27260. onResizeObservable: Observable<Engine>;
  27261. /**
  27262. * Observable event triggered each time the canvas loses focus
  27263. */
  27264. onCanvasBlurObservable: Observable<Engine>;
  27265. /**
  27266. * Observable event triggered each time the canvas gains focus
  27267. */
  27268. onCanvasFocusObservable: Observable<Engine>;
  27269. /**
  27270. * Observable event triggered each time the canvas receives pointerout event
  27271. */
  27272. onCanvasPointerOutObservable: Observable<PointerEvent>;
  27273. /**
  27274. * Observable event triggered before each texture is initialized
  27275. */
  27276. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  27277. private _vrDisplay;
  27278. private _vrSupported;
  27279. private _oldSize;
  27280. private _oldHardwareScaleFactor;
  27281. private _vrExclusivePointerMode;
  27282. private _webVRInitPromise;
  27283. /**
  27284. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  27285. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  27286. */
  27287. readonly isInVRExclusivePointerMode: boolean;
  27288. /**
  27289. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  27290. */
  27291. disableUniformBuffers: boolean;
  27292. /** @hidden */
  27293. _uniformBuffers: UniformBuffer[];
  27294. /**
  27295. * Gets a boolean indicating that the engine supports uniform buffers
  27296. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27297. */
  27298. readonly supportsUniformBuffers: boolean;
  27299. /**
  27300. * Observable raised when the engine begins a new frame
  27301. */
  27302. onBeginFrameObservable: Observable<Engine>;
  27303. /**
  27304. * If set, will be used to request the next animation frame for the render loop
  27305. */
  27306. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  27307. /**
  27308. * Observable raised when the engine ends the current frame
  27309. */
  27310. onEndFrameObservable: Observable<Engine>;
  27311. /**
  27312. * Observable raised when the engine is about to compile a shader
  27313. */
  27314. onBeforeShaderCompilationObservable: Observable<Engine>;
  27315. /**
  27316. * Observable raised when the engine has jsut compiled a shader
  27317. */
  27318. onAfterShaderCompilationObservable: Observable<Engine>;
  27319. /** @hidden */
  27320. _gl: WebGLRenderingContext;
  27321. private _renderingCanvas;
  27322. private _windowIsBackground;
  27323. private _webGLVersion;
  27324. /**
  27325. * Gets a boolean indicating that only power of 2 textures are supported
  27326. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  27327. */
  27328. readonly needPOTTextures: boolean;
  27329. /** @hidden */
  27330. _badOS: boolean;
  27331. /** @hidden */
  27332. _badDesktopOS: boolean;
  27333. /**
  27334. * Gets or sets a value indicating if we want to disable texture binding optimization.
  27335. * This could be required on some buggy drivers which wants to have textures bound in a progressive order.
  27336. * By default Babylon.js will try to let textures bound where they are and only update the samplers to point where the texture is
  27337. */
  27338. disableTextureBindingOptimization: boolean;
  27339. /**
  27340. * Gets the audio engine
  27341. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27342. * @ignorenaming
  27343. */
  27344. static audioEngine: IAudioEngine;
  27345. /**
  27346. * Default AudioEngine factory responsible of creating the Audio Engine.
  27347. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  27348. */
  27349. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  27350. /**
  27351. * Default offline support factory responsible of creating a tool used to store data locally.
  27352. * By default, this will create a Database object if the workload has been embedded.
  27353. */
  27354. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  27355. private _onFocus;
  27356. private _onBlur;
  27357. private _onCanvasPointerOut;
  27358. private _onCanvasBlur;
  27359. private _onCanvasFocus;
  27360. private _onFullscreenChange;
  27361. private _onPointerLockChange;
  27362. private _onVRDisplayPointerRestricted;
  27363. private _onVRDisplayPointerUnrestricted;
  27364. private _onVrDisplayConnect;
  27365. private _onVrDisplayDisconnect;
  27366. private _onVrDisplayPresentChange;
  27367. /**
  27368. * Observable signaled when VR display mode changes
  27369. */
  27370. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  27371. /**
  27372. * Observable signaled when VR request present is complete
  27373. */
  27374. onVRRequestPresentComplete: Observable<boolean>;
  27375. /**
  27376. * Observable signaled when VR request present starts
  27377. */
  27378. onVRRequestPresentStart: Observable<Engine>;
  27379. private _hardwareScalingLevel;
  27380. /** @hidden */
  27381. protected _caps: EngineCapabilities;
  27382. private _pointerLockRequested;
  27383. private _isStencilEnable;
  27384. private _colorWrite;
  27385. private _loadingScreen;
  27386. /** @hidden */
  27387. _drawCalls: PerfCounter;
  27388. /** @hidden */
  27389. _textureCollisions: PerfCounter;
  27390. private _glVersion;
  27391. private _glRenderer;
  27392. private _glVendor;
  27393. private _videoTextureSupported;
  27394. private _renderingQueueLaunched;
  27395. private _activeRenderLoops;
  27396. private _deterministicLockstep;
  27397. private _lockstepMaxSteps;
  27398. /**
  27399. * Observable signaled when a context lost event is raised
  27400. */
  27401. onContextLostObservable: Observable<Engine>;
  27402. /**
  27403. * Observable signaled when a context restored event is raised
  27404. */
  27405. onContextRestoredObservable: Observable<Engine>;
  27406. private _onContextLost;
  27407. private _onContextRestored;
  27408. private _contextWasLost;
  27409. private _doNotHandleContextLost;
  27410. /**
  27411. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  27412. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  27413. */
  27414. doNotHandleContextLost: boolean;
  27415. private _performanceMonitor;
  27416. private _fps;
  27417. private _deltaTime;
  27418. /**
  27419. * Turn this value on if you want to pause FPS computation when in background
  27420. */
  27421. disablePerformanceMonitorInBackground: boolean;
  27422. /**
  27423. * Gets the performance monitor attached to this engine
  27424. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  27425. */
  27426. readonly performanceMonitor: PerformanceMonitor;
  27427. /** @hidden */
  27428. protected _depthCullingState: _DepthCullingState;
  27429. /** @hidden */
  27430. protected _stencilState: _StencilState;
  27431. /** @hidden */
  27432. protected _alphaState: _AlphaState;
  27433. /** @hidden */
  27434. protected _alphaMode: number;
  27435. protected _internalTexturesCache: InternalTexture[];
  27436. /** @hidden */
  27437. protected _activeChannel: number;
  27438. private _currentTextureChannel;
  27439. /** @hidden */
  27440. protected _boundTexturesCache: {
  27441. [key: string]: Nullable<InternalTexture>;
  27442. };
  27443. /** @hidden */
  27444. protected _currentEffect: Nullable<Effect>;
  27445. /** @hidden */
  27446. protected _currentProgram: Nullable<WebGLProgram>;
  27447. private _compiledEffects;
  27448. private _vertexAttribArraysEnabled;
  27449. /** @hidden */
  27450. protected _cachedViewport: Nullable<Viewport>;
  27451. private _cachedVertexArrayObject;
  27452. /** @hidden */
  27453. protected _cachedVertexBuffers: any;
  27454. /** @hidden */
  27455. protected _cachedIndexBuffer: Nullable<WebGLBuffer>;
  27456. /** @hidden */
  27457. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  27458. /** @hidden */
  27459. protected _currentRenderTarget: Nullable<InternalTexture>;
  27460. private _uintIndicesCurrentlySet;
  27461. private _currentBoundBuffer;
  27462. /** @hidden */
  27463. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  27464. private _currentBufferPointers;
  27465. private _currentInstanceLocations;
  27466. private _currentInstanceBuffers;
  27467. private _textureUnits;
  27468. private _firstBoundInternalTextureTracker;
  27469. private _lastBoundInternalTextureTracker;
  27470. private _workingCanvas;
  27471. private _workingContext;
  27472. private _rescalePostProcess;
  27473. private _dummyFramebuffer;
  27474. private _externalData;
  27475. private _bindedRenderFunction;
  27476. private _vaoRecordInProgress;
  27477. private _mustWipeVertexAttributes;
  27478. private _emptyTexture;
  27479. private _emptyCubeTexture;
  27480. private _emptyTexture3D;
  27481. /** @hidden */
  27482. _frameHandler: number;
  27483. private _nextFreeTextureSlots;
  27484. private _maxSimultaneousTextures;
  27485. private _activeRequests;
  27486. private _texturesSupported;
  27487. private _textureFormatInUse;
  27488. /**
  27489. * Gets the list of texture formats supported
  27490. */
  27491. readonly texturesSupported: Array<string>;
  27492. /**
  27493. * Gets the list of texture formats in use
  27494. */
  27495. readonly textureFormatInUse: Nullable<string>;
  27496. /**
  27497. * Gets the current viewport
  27498. */
  27499. readonly currentViewport: Nullable<Viewport>;
  27500. /**
  27501. * Gets the default empty texture
  27502. */
  27503. readonly emptyTexture: InternalTexture;
  27504. /**
  27505. * Gets the default empty 3D texture
  27506. */
  27507. readonly emptyTexture3D: InternalTexture;
  27508. /**
  27509. * Gets the default empty cube texture
  27510. */
  27511. readonly emptyCubeTexture: InternalTexture;
  27512. /**
  27513. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  27514. */
  27515. readonly premultipliedAlpha: boolean;
  27516. /**
  27517. * Creates a new engine
  27518. * @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
  27519. * @param antialias defines enable antialiasing (default: false)
  27520. * @param options defines further options to be sent to the getContext() function
  27521. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  27522. */
  27523. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  27524. private _disableTouchAction;
  27525. private _rebuildInternalTextures;
  27526. private _rebuildEffects;
  27527. /**
  27528. * Gets a boolean indicating if all created effects are ready
  27529. * @returns true if all effects are ready
  27530. */
  27531. areAllEffectsReady(): boolean;
  27532. private _rebuildBuffers;
  27533. private _initGLContext;
  27534. /**
  27535. * Gets version of the current webGL context
  27536. */
  27537. readonly webGLVersion: number;
  27538. /**
  27539. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  27540. */
  27541. readonly isStencilEnable: boolean;
  27542. private _prepareWorkingCanvas;
  27543. /**
  27544. * Reset the texture cache to empty state
  27545. */
  27546. resetTextureCache(): void;
  27547. /**
  27548. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  27549. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27550. * @returns true if engine is in deterministic lock step mode
  27551. */
  27552. isDeterministicLockStep(): boolean;
  27553. /**
  27554. * Gets the max steps when engine is running in deterministic lock step
  27555. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27556. * @returns the max steps
  27557. */
  27558. getLockstepMaxSteps(): number;
  27559. /**
  27560. * Gets an object containing information about the current webGL context
  27561. * @returns an object containing the vender, the renderer and the version of the current webGL context
  27562. */
  27563. getGlInfo(): {
  27564. vendor: string;
  27565. renderer: string;
  27566. version: string;
  27567. };
  27568. /**
  27569. * Gets current aspect ratio
  27570. * @param camera defines the camera to use to get the aspect ratio
  27571. * @param useScreen defines if screen size must be used (or the current render target if any)
  27572. * @returns a number defining the aspect ratio
  27573. */
  27574. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  27575. /**
  27576. * Gets current screen aspect ratio
  27577. * @returns a number defining the aspect ratio
  27578. */
  27579. getScreenAspectRatio(): number;
  27580. /**
  27581. * Gets the current render width
  27582. * @param useScreen defines if screen size must be used (or the current render target if any)
  27583. * @returns a number defining the current render width
  27584. */
  27585. getRenderWidth(useScreen?: boolean): number;
  27586. /**
  27587. * Gets the current render height
  27588. * @param useScreen defines if screen size must be used (or the current render target if any)
  27589. * @returns a number defining the current render height
  27590. */
  27591. getRenderHeight(useScreen?: boolean): number;
  27592. /**
  27593. * Gets the HTML canvas attached with the current webGL context
  27594. * @returns a HTML canvas
  27595. */
  27596. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  27597. /**
  27598. * Gets the client rect of the HTML canvas attached with the current webGL context
  27599. * @returns a client rectanglee
  27600. */
  27601. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  27602. /**
  27603. * Defines the hardware scaling level.
  27604. * By default the hardware scaling level is computed from the window device ratio.
  27605. * 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.
  27606. * @param level defines the level to use
  27607. */
  27608. setHardwareScalingLevel(level: number): void;
  27609. /**
  27610. * Gets the current hardware scaling level.
  27611. * By default the hardware scaling level is computed from the window device ratio.
  27612. * 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.
  27613. * @returns a number indicating the current hardware scaling level
  27614. */
  27615. getHardwareScalingLevel(): number;
  27616. /**
  27617. * Gets the list of loaded textures
  27618. * @returns an array containing all loaded textures
  27619. */
  27620. getLoadedTexturesCache(): InternalTexture[];
  27621. /**
  27622. * Gets the object containing all engine capabilities
  27623. * @returns the EngineCapabilities object
  27624. */
  27625. getCaps(): EngineCapabilities;
  27626. /**
  27627. * Gets the current depth function
  27628. * @returns a number defining the depth function
  27629. */
  27630. getDepthFunction(): Nullable<number>;
  27631. /**
  27632. * Sets the current depth function
  27633. * @param depthFunc defines the function to use
  27634. */
  27635. setDepthFunction(depthFunc: number): void;
  27636. /**
  27637. * Sets the current depth function to GREATER
  27638. */
  27639. setDepthFunctionToGreater(): void;
  27640. /**
  27641. * Sets the current depth function to GEQUAL
  27642. */
  27643. setDepthFunctionToGreaterOrEqual(): void;
  27644. /**
  27645. * Sets the current depth function to LESS
  27646. */
  27647. setDepthFunctionToLess(): void;
  27648. /**
  27649. * Sets the current depth function to LEQUAL
  27650. */
  27651. setDepthFunctionToLessOrEqual(): void;
  27652. /**
  27653. * Gets a boolean indicating if stencil buffer is enabled
  27654. * @returns the current stencil buffer state
  27655. */
  27656. getStencilBuffer(): boolean;
  27657. /**
  27658. * Enable or disable the stencil buffer
  27659. * @param enable defines if the stencil buffer must be enabled or disabled
  27660. */
  27661. setStencilBuffer(enable: boolean): void;
  27662. /**
  27663. * Gets the current stencil mask
  27664. * @returns a number defining the new stencil mask to use
  27665. */
  27666. getStencilMask(): number;
  27667. /**
  27668. * Sets the current stencil mask
  27669. * @param mask defines the new stencil mask to use
  27670. */
  27671. setStencilMask(mask: number): void;
  27672. /**
  27673. * Gets the current stencil function
  27674. * @returns a number defining the stencil function to use
  27675. */
  27676. getStencilFunction(): number;
  27677. /**
  27678. * Gets the current stencil reference value
  27679. * @returns a number defining the stencil reference value to use
  27680. */
  27681. getStencilFunctionReference(): number;
  27682. /**
  27683. * Gets the current stencil mask
  27684. * @returns a number defining the stencil mask to use
  27685. */
  27686. getStencilFunctionMask(): number;
  27687. /**
  27688. * Sets the current stencil function
  27689. * @param stencilFunc defines the new stencil function to use
  27690. */
  27691. setStencilFunction(stencilFunc: number): void;
  27692. /**
  27693. * Sets the current stencil reference
  27694. * @param reference defines the new stencil reference to use
  27695. */
  27696. setStencilFunctionReference(reference: number): void;
  27697. /**
  27698. * Sets the current stencil mask
  27699. * @param mask defines the new stencil mask to use
  27700. */
  27701. setStencilFunctionMask(mask: number): void;
  27702. /**
  27703. * Gets the current stencil operation when stencil fails
  27704. * @returns a number defining stencil operation to use when stencil fails
  27705. */
  27706. getStencilOperationFail(): number;
  27707. /**
  27708. * Gets the current stencil operation when depth fails
  27709. * @returns a number defining stencil operation to use when depth fails
  27710. */
  27711. getStencilOperationDepthFail(): number;
  27712. /**
  27713. * Gets the current stencil operation when stencil passes
  27714. * @returns a number defining stencil operation to use when stencil passes
  27715. */
  27716. getStencilOperationPass(): number;
  27717. /**
  27718. * Sets the stencil operation to use when stencil fails
  27719. * @param operation defines the stencil operation to use when stencil fails
  27720. */
  27721. setStencilOperationFail(operation: number): void;
  27722. /**
  27723. * Sets the stencil operation to use when depth fails
  27724. * @param operation defines the stencil operation to use when depth fails
  27725. */
  27726. setStencilOperationDepthFail(operation: number): void;
  27727. /**
  27728. * Sets the stencil operation to use when stencil passes
  27729. * @param operation defines the stencil operation to use when stencil passes
  27730. */
  27731. setStencilOperationPass(operation: number): void;
  27732. /**
  27733. * Sets a boolean indicating if the dithering state is enabled or disabled
  27734. * @param value defines the dithering state
  27735. */
  27736. setDitheringState(value: boolean): void;
  27737. /**
  27738. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  27739. * @param value defines the rasterizer state
  27740. */
  27741. setRasterizerState(value: boolean): void;
  27742. /**
  27743. * stop executing a render loop function and remove it from the execution array
  27744. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  27745. */
  27746. stopRenderLoop(renderFunction?: () => void): void;
  27747. /** @hidden */
  27748. _renderLoop(): void;
  27749. /**
  27750. * Register and execute a render loop. The engine can have more than one render function
  27751. * @param renderFunction defines the function to continuously execute
  27752. */
  27753. runRenderLoop(renderFunction: () => void): void;
  27754. /**
  27755. * Toggle full screen mode
  27756. * @param requestPointerLock defines if a pointer lock should be requested from the user
  27757. */
  27758. switchFullscreen(requestPointerLock: boolean): void;
  27759. /**
  27760. * Enters full screen mode
  27761. * @param requestPointerLock defines if a pointer lock should be requested from the user
  27762. */
  27763. enterFullscreen(requestPointerLock: boolean): void;
  27764. /**
  27765. * Exits full screen mode
  27766. */
  27767. exitFullscreen(): void;
  27768. /**
  27769. * Clear the current render buffer or the current render target (if any is set up)
  27770. * @param color defines the color to use
  27771. * @param backBuffer defines if the back buffer must be cleared
  27772. * @param depth defines if the depth buffer must be cleared
  27773. * @param stencil defines if the stencil buffer must be cleared
  27774. */
  27775. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  27776. /**
  27777. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  27778. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  27779. * @param y defines the y-coordinate of the corner of the clear rectangle
  27780. * @param width defines the width of the clear rectangle
  27781. * @param height defines the height of the clear rectangle
  27782. * @param clearColor defines the clear color
  27783. */
  27784. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  27785. /**
  27786. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  27787. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  27788. * @param y defines the y-coordinate of the corner of the clear rectangle
  27789. * @param width defines the width of the clear rectangle
  27790. * @param height defines the height of the clear rectangle
  27791. */
  27792. enableScissor(x: number, y: number, width: number, height: number): void;
  27793. /**
  27794. * Disable previously set scissor test rectangle
  27795. */
  27796. disableScissor(): void;
  27797. private _viewportCached;
  27798. /** @hidden */
  27799. _viewport(x: number, y: number, width: number, height: number): void;
  27800. /**
  27801. * Set the WebGL's viewport
  27802. * @param viewport defines the viewport element to be used
  27803. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  27804. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  27805. */
  27806. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  27807. /**
  27808. * Directly set the WebGL Viewport
  27809. * @param x defines the x coordinate of the viewport (in screen space)
  27810. * @param y defines the y coordinate of the viewport (in screen space)
  27811. * @param width defines the width of the viewport (in screen space)
  27812. * @param height defines the height of the viewport (in screen space)
  27813. * @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
  27814. */
  27815. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  27816. /**
  27817. * Begin a new frame
  27818. */
  27819. beginFrame(): void;
  27820. /**
  27821. * Enf the current frame
  27822. */
  27823. endFrame(): void;
  27824. /**
  27825. * Resize the view according to the canvas' size
  27826. */
  27827. resize(): void;
  27828. /**
  27829. * Force a specific size of the canvas
  27830. * @param width defines the new canvas' width
  27831. * @param height defines the new canvas' height
  27832. */
  27833. setSize(width: number, height: number): void;
  27834. /**
  27835. * Gets a boolean indicating if a webVR device was detected
  27836. * @returns true if a webVR device was detected
  27837. */
  27838. isVRDevicePresent(): boolean;
  27839. /**
  27840. * Gets the current webVR device
  27841. * @returns the current webVR device (or null)
  27842. */
  27843. getVRDevice(): any;
  27844. /**
  27845. * Initializes a webVR display and starts listening to display change events
  27846. * The onVRDisplayChangedObservable will be notified upon these changes
  27847. * @returns The onVRDisplayChangedObservable
  27848. */
  27849. initWebVR(): Observable<IDisplayChangedEventArgs>;
  27850. /**
  27851. * Initializes a webVR display and starts listening to display change events
  27852. * The onVRDisplayChangedObservable will be notified upon these changes
  27853. * @returns A promise containing a VRDisplay and if vr is supported
  27854. */
  27855. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  27856. /**
  27857. * Call this function to switch to webVR mode
  27858. * Will do nothing if webVR is not supported or if there is no webVR device
  27859. * @see http://doc.babylonjs.com/how_to/webvr_camera
  27860. */
  27861. enableVR(): void;
  27862. /**
  27863. * Call this function to leave webVR mode
  27864. * Will do nothing if webVR is not supported or if there is no webVR device
  27865. * @see http://doc.babylonjs.com/how_to/webvr_camera
  27866. */
  27867. disableVR(): void;
  27868. private _onVRFullScreenTriggered;
  27869. private _getVRDisplaysAsync;
  27870. /**
  27871. * Binds the frame buffer to the specified texture.
  27872. * @param texture The texture to render to or null for the default canvas
  27873. * @param faceIndex The face of the texture to render to in case of cube texture
  27874. * @param requiredWidth The width of the target to render to
  27875. * @param requiredHeight The height of the target to render to
  27876. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  27877. * @param depthStencilTexture The depth stencil texture to use to render
  27878. * @param lodLevel defines le lod level to bind to the frame buffer
  27879. */
  27880. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  27881. private bindUnboundFramebuffer;
  27882. /**
  27883. * Unbind the current render target texture from the webGL context
  27884. * @param texture defines the render target texture to unbind
  27885. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  27886. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  27887. */
  27888. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  27889. /**
  27890. * Unbind a list of render target textures from the webGL context
  27891. * This is used only when drawBuffer extension or webGL2 are active
  27892. * @param textures defines the render target textures to unbind
  27893. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  27894. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  27895. */
  27896. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  27897. /**
  27898. * Force the mipmap generation for the given render target texture
  27899. * @param texture defines the render target texture to use
  27900. */
  27901. generateMipMapsForCubemap(texture: InternalTexture): void;
  27902. /**
  27903. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  27904. */
  27905. flushFramebuffer(): void;
  27906. /**
  27907. * Unbind the current render target and bind the default framebuffer
  27908. */
  27909. restoreDefaultFramebuffer(): void;
  27910. /**
  27911. * Create an uniform buffer
  27912. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27913. * @param elements defines the content of the uniform buffer
  27914. * @returns the webGL uniform buffer
  27915. */
  27916. createUniformBuffer(elements: FloatArray): WebGLBuffer;
  27917. /**
  27918. * Create a dynamic uniform buffer
  27919. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27920. * @param elements defines the content of the uniform buffer
  27921. * @returns the webGL uniform buffer
  27922. */
  27923. createDynamicUniformBuffer(elements: FloatArray): WebGLBuffer;
  27924. /**
  27925. * Update an existing uniform buffer
  27926. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27927. * @param uniformBuffer defines the target uniform buffer
  27928. * @param elements defines the content to update
  27929. * @param offset defines the offset in the uniform buffer where update should start
  27930. * @param count defines the size of the data to update
  27931. */
  27932. updateUniformBuffer(uniformBuffer: WebGLBuffer, elements: FloatArray, offset?: number, count?: number): void;
  27933. private _resetVertexBufferBinding;
  27934. /**
  27935. * Creates a vertex buffer
  27936. * @param data the data for the vertex buffer
  27937. * @returns the new WebGL static buffer
  27938. */
  27939. createVertexBuffer(data: DataArray): WebGLBuffer;
  27940. /**
  27941. * Creates a dynamic vertex buffer
  27942. * @param data the data for the dynamic vertex buffer
  27943. * @returns the new WebGL dynamic buffer
  27944. */
  27945. createDynamicVertexBuffer(data: DataArray): WebGLBuffer;
  27946. /**
  27947. * Update a dynamic index buffer
  27948. * @param indexBuffer defines the target index buffer
  27949. * @param indices defines the data to update
  27950. * @param offset defines the offset in the target index buffer where update should start
  27951. */
  27952. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  27953. /**
  27954. * Updates a dynamic vertex buffer.
  27955. * @param vertexBuffer the vertex buffer to update
  27956. * @param data the data used to update the vertex buffer
  27957. * @param byteOffset the byte offset of the data
  27958. * @param byteLength the byte length of the data
  27959. */
  27960. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  27961. private _resetIndexBufferBinding;
  27962. /**
  27963. * Creates a new index buffer
  27964. * @param indices defines the content of the index buffer
  27965. * @param updatable defines if the index buffer must be updatable
  27966. * @returns a new webGL buffer
  27967. */
  27968. createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer;
  27969. /**
  27970. * Bind a webGL buffer to the webGL context
  27971. * @param buffer defines the buffer to bind
  27972. */
  27973. bindArrayBuffer(buffer: Nullable<WebGLBuffer>): void;
  27974. /**
  27975. * Bind an uniform buffer to the current webGL context
  27976. * @param buffer defines the buffer to bind
  27977. */
  27978. bindUniformBuffer(buffer: Nullable<WebGLBuffer>): void;
  27979. /**
  27980. * Bind a buffer to the current webGL context at a given location
  27981. * @param buffer defines the buffer to bind
  27982. * @param location defines the index where to bind the buffer
  27983. */
  27984. bindUniformBufferBase(buffer: WebGLBuffer, location: number): void;
  27985. /**
  27986. * Bind a specific block at a given index in a specific shader program
  27987. * @param shaderProgram defines the shader program
  27988. * @param blockName defines the block name
  27989. * @param index defines the index where to bind the block
  27990. */
  27991. bindUniformBlock(shaderProgram: WebGLProgram, blockName: string, index: number): void;
  27992. private bindIndexBuffer;
  27993. private bindBuffer;
  27994. /**
  27995. * update the bound buffer with the given data
  27996. * @param data defines the data to update
  27997. */
  27998. updateArrayBuffer(data: Float32Array): void;
  27999. private _vertexAttribPointer;
  28000. private _bindIndexBufferWithCache;
  28001. private _bindVertexBuffersAttributes;
  28002. /**
  28003. * Records a vertex array object
  28004. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  28005. * @param vertexBuffers defines the list of vertex buffers to store
  28006. * @param indexBuffer defines the index buffer to store
  28007. * @param effect defines the effect to store
  28008. * @returns the new vertex array object
  28009. */
  28010. recordVertexArrayObject(vertexBuffers: {
  28011. [key: string]: VertexBuffer;
  28012. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): WebGLVertexArrayObject;
  28013. /**
  28014. * Bind a specific vertex array object
  28015. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  28016. * @param vertexArrayObject defines the vertex array object to bind
  28017. * @param indexBuffer defines the index buffer to bind
  28018. */
  28019. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<WebGLBuffer>): void;
  28020. /**
  28021. * Bind webGl buffers directly to the webGL context
  28022. * @param vertexBuffer defines the vertex buffer to bind
  28023. * @param indexBuffer defines the index buffer to bind
  28024. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  28025. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  28026. * @param effect defines the effect associated with the vertex buffer
  28027. */
  28028. bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  28029. private _unbindVertexArrayObject;
  28030. /**
  28031. * Bind a list of vertex buffers to the webGL context
  28032. * @param vertexBuffers defines the list of vertex buffers to bind
  28033. * @param indexBuffer defines the index buffer to bind
  28034. * @param effect defines the effect associated with the vertex buffers
  28035. */
  28036. bindBuffers(vertexBuffers: {
  28037. [key: string]: Nullable<VertexBuffer>;
  28038. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): void;
  28039. /**
  28040. * Unbind all instance attributes
  28041. */
  28042. unbindInstanceAttributes(): void;
  28043. /**
  28044. * Release and free the memory of a vertex array object
  28045. * @param vao defines the vertex array object to delete
  28046. */
  28047. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  28048. /** @hidden */
  28049. _releaseBuffer(buffer: WebGLBuffer): boolean;
  28050. /**
  28051. * Creates a webGL buffer to use with instanciation
  28052. * @param capacity defines the size of the buffer
  28053. * @returns the webGL buffer
  28054. */
  28055. createInstancesBuffer(capacity: number): WebGLBuffer;
  28056. /**
  28057. * Delete a webGL buffer used with instanciation
  28058. * @param buffer defines the webGL buffer to delete
  28059. */
  28060. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  28061. /**
  28062. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  28063. * @param instancesBuffer defines the webGL buffer to update and bind
  28064. * @param data defines the data to store in the buffer
  28065. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  28066. */
  28067. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  28068. /**
  28069. * Apply all cached states (depth, culling, stencil and alpha)
  28070. */
  28071. applyStates(): void;
  28072. /**
  28073. * Send a draw order
  28074. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  28075. * @param indexStart defines the starting index
  28076. * @param indexCount defines the number of index to draw
  28077. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28078. */
  28079. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  28080. /**
  28081. * Draw a list of points
  28082. * @param verticesStart defines the index of first vertex to draw
  28083. * @param verticesCount defines the count of vertices to draw
  28084. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28085. */
  28086. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28087. /**
  28088. * Draw a list of unindexed primitives
  28089. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  28090. * @param verticesStart defines the index of first vertex to draw
  28091. * @param verticesCount defines the count of vertices to draw
  28092. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28093. */
  28094. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28095. /**
  28096. * Draw a list of indexed primitives
  28097. * @param fillMode defines the primitive to use
  28098. * @param indexStart defines the starting index
  28099. * @param indexCount defines the number of index to draw
  28100. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28101. */
  28102. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  28103. /**
  28104. * Draw a list of unindexed primitives
  28105. * @param fillMode defines the primitive to use
  28106. * @param verticesStart defines the index of first vertex to draw
  28107. * @param verticesCount defines the count of vertices to draw
  28108. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28109. */
  28110. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28111. private _drawMode;
  28112. /** @hidden */
  28113. _releaseEffect(effect: Effect): void;
  28114. /** @hidden */
  28115. _deleteProgram(program: WebGLProgram): void;
  28116. /**
  28117. * Create a new effect (used to store vertex/fragment shaders)
  28118. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  28119. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  28120. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  28121. * @param samplers defines an array of string used to represent textures
  28122. * @param defines defines the string containing the defines to use to compile the shaders
  28123. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  28124. * @param onCompiled defines a function to call when the effect creation is successful
  28125. * @param onError defines a function to call when the effect creation has failed
  28126. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  28127. * @returns the new Effect
  28128. */
  28129. 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;
  28130. private _compileShader;
  28131. private _compileRawShader;
  28132. /**
  28133. * Directly creates a webGL program
  28134. * @param vertexCode defines the vertex shader code to use
  28135. * @param fragmentCode defines the fragment shader code to use
  28136. * @param context defines the webGL context to use (if not set, the current one will be used)
  28137. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  28138. * @returns the new webGL program
  28139. */
  28140. createRawShaderProgram(vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  28141. /**
  28142. * Creates a webGL program
  28143. * @param vertexCode defines the vertex shader code to use
  28144. * @param fragmentCode defines the fragment shader code to use
  28145. * @param defines defines the string containing the defines to use to compile the shaders
  28146. * @param context defines the webGL context to use (if not set, the current one will be used)
  28147. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  28148. * @returns the new webGL program
  28149. */
  28150. createShaderProgram(vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  28151. private _createShaderProgram;
  28152. private _finalizeProgram;
  28153. /** @hidden */
  28154. _isProgramCompiled(shaderProgram: WebGLProgram): boolean;
  28155. /** @hidden */
  28156. _executeWhenProgramIsCompiled(shaderProgram: WebGLProgram, action: () => void): void;
  28157. /**
  28158. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  28159. * @param shaderProgram defines the webGL program to use
  28160. * @param uniformsNames defines the list of uniform names
  28161. * @returns an array of webGL uniform locations
  28162. */
  28163. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  28164. /**
  28165. * Gets the lsit of active attributes for a given webGL program
  28166. * @param shaderProgram defines the webGL program to use
  28167. * @param attributesNames defines the list of attribute names to get
  28168. * @returns an array of indices indicating the offset of each attribute
  28169. */
  28170. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  28171. /**
  28172. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  28173. * @param effect defines the effect to activate
  28174. */
  28175. enableEffect(effect: Nullable<Effect>): void;
  28176. /**
  28177. * Set the value of an uniform to an array of int32
  28178. * @param uniform defines the webGL uniform location where to store the value
  28179. * @param array defines the array of int32 to store
  28180. */
  28181. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28182. /**
  28183. * Set the value of an uniform to an array of int32 (stored as vec2)
  28184. * @param uniform defines the webGL uniform location where to store the value
  28185. * @param array defines the array of int32 to store
  28186. */
  28187. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28188. /**
  28189. * Set the value of an uniform to an array of int32 (stored as vec3)
  28190. * @param uniform defines the webGL uniform location where to store the value
  28191. * @param array defines the array of int32 to store
  28192. */
  28193. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28194. /**
  28195. * Set the value of an uniform to an array of int32 (stored as vec4)
  28196. * @param uniform defines the webGL uniform location where to store the value
  28197. * @param array defines the array of int32 to store
  28198. */
  28199. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28200. /**
  28201. * Set the value of an uniform to an array of float32
  28202. * @param uniform defines the webGL uniform location where to store the value
  28203. * @param array defines the array of float32 to store
  28204. */
  28205. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28206. /**
  28207. * Set the value of an uniform to an array of float32 (stored as vec2)
  28208. * @param uniform defines the webGL uniform location where to store the value
  28209. * @param array defines the array of float32 to store
  28210. */
  28211. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28212. /**
  28213. * Set the value of an uniform to an array of float32 (stored as vec3)
  28214. * @param uniform defines the webGL uniform location where to store the value
  28215. * @param array defines the array of float32 to store
  28216. */
  28217. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28218. /**
  28219. * Set the value of an uniform to an array of float32 (stored as vec4)
  28220. * @param uniform defines the webGL uniform location where to store the value
  28221. * @param array defines the array of float32 to store
  28222. */
  28223. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28224. /**
  28225. * Set the value of an uniform to an array of number
  28226. * @param uniform defines the webGL uniform location where to store the value
  28227. * @param array defines the array of number to store
  28228. */
  28229. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28230. /**
  28231. * Set the value of an uniform to an array of number (stored as vec2)
  28232. * @param uniform defines the webGL uniform location where to store the value
  28233. * @param array defines the array of number to store
  28234. */
  28235. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28236. /**
  28237. * Set the value of an uniform to an array of number (stored as vec3)
  28238. * @param uniform defines the webGL uniform location where to store the value
  28239. * @param array defines the array of number to store
  28240. */
  28241. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28242. /**
  28243. * Set the value of an uniform to an array of number (stored as vec4)
  28244. * @param uniform defines the webGL uniform location where to store the value
  28245. * @param array defines the array of number to store
  28246. */
  28247. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28248. /**
  28249. * Set the value of an uniform to an array of float32 (stored as matrices)
  28250. * @param uniform defines the webGL uniform location where to store the value
  28251. * @param matrices defines the array of float32 to store
  28252. */
  28253. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  28254. /**
  28255. * Set the value of an uniform to a matrix
  28256. * @param uniform defines the webGL uniform location where to store the value
  28257. * @param matrix defines the matrix to store
  28258. */
  28259. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  28260. /**
  28261. * Set the value of an uniform to a matrix (3x3)
  28262. * @param uniform defines the webGL uniform location where to store the value
  28263. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  28264. */
  28265. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  28266. /**
  28267. * Set the value of an uniform to a matrix (2x2)
  28268. * @param uniform defines the webGL uniform location where to store the value
  28269. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  28270. */
  28271. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  28272. /**
  28273. * Set the value of an uniform to a number (int)
  28274. * @param uniform defines the webGL uniform location where to store the value
  28275. * @param value defines the int number to store
  28276. */
  28277. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  28278. /**
  28279. * Set the value of an uniform to a number (float)
  28280. * @param uniform defines the webGL uniform location where to store the value
  28281. * @param value defines the float number to store
  28282. */
  28283. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  28284. /**
  28285. * Set the value of an uniform to a vec2
  28286. * @param uniform defines the webGL uniform location where to store the value
  28287. * @param x defines the 1st component of the value
  28288. * @param y defines the 2nd component of the value
  28289. */
  28290. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  28291. /**
  28292. * Set the value of an uniform to a vec3
  28293. * @param uniform defines the webGL uniform location where to store the value
  28294. * @param x defines the 1st component of the value
  28295. * @param y defines the 2nd component of the value
  28296. * @param z defines the 3rd component of the value
  28297. */
  28298. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  28299. /**
  28300. * Set the value of an uniform to a boolean
  28301. * @param uniform defines the webGL uniform location where to store the value
  28302. * @param bool defines the boolean to store
  28303. */
  28304. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  28305. /**
  28306. * Set the value of an uniform to a vec4
  28307. * @param uniform defines the webGL uniform location where to store the value
  28308. * @param x defines the 1st component of the value
  28309. * @param y defines the 2nd component of the value
  28310. * @param z defines the 3rd component of the value
  28311. * @param w defines the 4th component of the value
  28312. */
  28313. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  28314. /**
  28315. * Set the value of an uniform to a Color3
  28316. * @param uniform defines the webGL uniform location where to store the value
  28317. * @param color3 defines the color to store
  28318. */
  28319. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  28320. /**
  28321. * Set the value of an uniform to a Color3 and an alpha value
  28322. * @param uniform defines the webGL uniform location where to store the value
  28323. * @param color3 defines the color to store
  28324. * @param alpha defines the alpha component to store
  28325. */
  28326. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  28327. /**
  28328. * Sets a Color4 on a uniform variable
  28329. * @param uniform defines the uniform location
  28330. * @param color4 defines the value to be set
  28331. */
  28332. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  28333. /**
  28334. * Set various states to the webGL context
  28335. * @param culling defines backface culling state
  28336. * @param zOffset defines the value to apply to zOffset (0 by default)
  28337. * @param force defines if states must be applied even if cache is up to date
  28338. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  28339. */
  28340. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  28341. /**
  28342. * Set the z offset to apply to current rendering
  28343. * @param value defines the offset to apply
  28344. */
  28345. setZOffset(value: number): void;
  28346. /**
  28347. * Gets the current value of the zOffset
  28348. * @returns the current zOffset state
  28349. */
  28350. getZOffset(): number;
  28351. /**
  28352. * Enable or disable depth buffering
  28353. * @param enable defines the state to set
  28354. */
  28355. setDepthBuffer(enable: boolean): void;
  28356. /**
  28357. * Gets a boolean indicating if depth writing is enabled
  28358. * @returns the current depth writing state
  28359. */
  28360. getDepthWrite(): boolean;
  28361. /**
  28362. * Enable or disable depth writing
  28363. * @param enable defines the state to set
  28364. */
  28365. setDepthWrite(enable: boolean): void;
  28366. /**
  28367. * Enable or disable color writing
  28368. * @param enable defines the state to set
  28369. */
  28370. setColorWrite(enable: boolean): void;
  28371. /**
  28372. * Gets a boolean indicating if color writing is enabled
  28373. * @returns the current color writing state
  28374. */
  28375. getColorWrite(): boolean;
  28376. /**
  28377. * Sets alpha constants used by some alpha blending modes
  28378. * @param r defines the red component
  28379. * @param g defines the green component
  28380. * @param b defines the blue component
  28381. * @param a defines the alpha component
  28382. */
  28383. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  28384. /**
  28385. * Sets the current alpha mode
  28386. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  28387. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  28388. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  28389. */
  28390. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  28391. /**
  28392. * Gets the current alpha mode
  28393. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  28394. * @returns the current alpha mode
  28395. */
  28396. getAlphaMode(): number;
  28397. /**
  28398. * Clears the list of texture accessible through engine.
  28399. * This can help preventing texture load conflict due to name collision.
  28400. */
  28401. clearInternalTexturesCache(): void;
  28402. /**
  28403. * Force the entire cache to be cleared
  28404. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  28405. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  28406. */
  28407. wipeCaches(bruteForce?: boolean): void;
  28408. /**
  28409. * Set the compressed texture format to use, based on the formats you have, and the formats
  28410. * supported by the hardware / browser.
  28411. *
  28412. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  28413. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  28414. * to API arguments needed to compressed textures. This puts the burden on the container
  28415. * generator to house the arcane code for determining these for current & future formats.
  28416. *
  28417. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  28418. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  28419. *
  28420. * Note: The result of this call is not taken into account when a texture is base64.
  28421. *
  28422. * @param formatsAvailable defines the list of those format families you have created
  28423. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  28424. *
  28425. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  28426. * @returns The extension selected.
  28427. */
  28428. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  28429. private _getSamplingParameters;
  28430. private _partialLoadImg;
  28431. private _cascadeLoadImgs;
  28432. /** @hidden */
  28433. _createTexture(): WebGLTexture;
  28434. /**
  28435. * Usually called from Texture.ts.
  28436. * Passed information to create a WebGLTexture
  28437. * @param urlArg defines a value which contains one of the following:
  28438. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  28439. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  28440. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  28441. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  28442. * @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)
  28443. * @param scene needed for loading to the correct scene
  28444. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  28445. * @param onLoad optional callback to be called upon successful completion
  28446. * @param onError optional callback to be called upon failure
  28447. * @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
  28448. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  28449. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  28450. * @param forcedExtension defines the extension to use to pick the right loader
  28451. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  28452. * @returns a InternalTexture for assignment back into BABYLON.Texture
  28453. */
  28454. 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;
  28455. private _rescaleTexture;
  28456. /**
  28457. * Update a raw texture
  28458. * @param texture defines the texture to update
  28459. * @param data defines the data to store in the texture
  28460. * @param format defines the format of the data
  28461. * @param invertY defines if data must be stored with Y axis inverted
  28462. * @param compression defines the compression used (null by default)
  28463. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  28464. */
  28465. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  28466. /**
  28467. * Creates a raw texture
  28468. * @param data defines the data to store in the texture
  28469. * @param width defines the width of the texture
  28470. * @param height defines the height of the texture
  28471. * @param format defines the format of the data
  28472. * @param generateMipMaps defines if the engine should generate the mip levels
  28473. * @param invertY defines if data must be stored with Y axis inverted
  28474. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  28475. * @param compression defines the compression used (null by default)
  28476. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  28477. * @returns the raw texture inside an InternalTexture
  28478. */
  28479. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  28480. private _unpackFlipYCached;
  28481. /**
  28482. * In case you are sharing the context with other applications, it might
  28483. * be interested to not cache the unpack flip y state to ensure a consistent
  28484. * value would be set.
  28485. */
  28486. enableUnpackFlipYCached: boolean;
  28487. /** @hidden */
  28488. _unpackFlipY(value: boolean): void;
  28489. /** @hidden */
  28490. _getUnpackAlignement(): number;
  28491. /**
  28492. * Creates a dynamic texture
  28493. * @param width defines the width of the texture
  28494. * @param height defines the height of the texture
  28495. * @param generateMipMaps defines if the engine should generate the mip levels
  28496. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  28497. * @returns the dynamic texture inside an InternalTexture
  28498. */
  28499. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  28500. /**
  28501. * Update the sampling mode of a given texture
  28502. * @param samplingMode defines the required sampling mode
  28503. * @param texture defines the texture to update
  28504. */
  28505. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  28506. /**
  28507. * Update the content of a dynamic texture
  28508. * @param texture defines the texture to update
  28509. * @param canvas defines the canvas containing the source
  28510. * @param invertY defines if data must be stored with Y axis inverted
  28511. * @param premulAlpha defines if alpha is stored as premultiplied
  28512. * @param format defines the format of the data
  28513. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  28514. */
  28515. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  28516. /**
  28517. * Update a video texture
  28518. * @param texture defines the texture to update
  28519. * @param video defines the video element to use
  28520. * @param invertY defines if data must be stored with Y axis inverted
  28521. */
  28522. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  28523. /**
  28524. * Updates a depth texture Comparison Mode and Function.
  28525. * If the comparison Function is equal to 0, the mode will be set to none.
  28526. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  28527. * @param texture The texture to set the comparison function for
  28528. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  28529. */
  28530. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  28531. private _setupDepthStencilTexture;
  28532. /**
  28533. * Creates a depth stencil texture.
  28534. * This is only available in WebGL 2 or with the depth texture extension available.
  28535. * @param size The size of face edge in the texture.
  28536. * @param options The options defining the texture.
  28537. * @returns The texture
  28538. */
  28539. createDepthStencilTexture(size: number | {
  28540. width: number;
  28541. height: number;
  28542. }, options: DepthTextureCreationOptions): InternalTexture;
  28543. /**
  28544. * Creates a depth stencil texture.
  28545. * This is only available in WebGL 2 or with the depth texture extension available.
  28546. * @param size The size of face edge in the texture.
  28547. * @param options The options defining the texture.
  28548. * @returns The texture
  28549. */
  28550. private _createDepthStencilTexture;
  28551. /**
  28552. * Creates a depth stencil cube texture.
  28553. * This is only available in WebGL 2.
  28554. * @param size The size of face edge in the cube texture.
  28555. * @param options The options defining the cube texture.
  28556. * @returns The cube texture
  28557. */
  28558. private _createDepthStencilCubeTexture;
  28559. /**
  28560. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  28561. * @param renderTarget The render target to set the frame buffer for
  28562. */
  28563. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  28564. /**
  28565. * Creates a new render target texture
  28566. * @param size defines the size of the texture
  28567. * @param options defines the options used to create the texture
  28568. * @returns a new render target texture stored in an InternalTexture
  28569. */
  28570. createRenderTargetTexture(size: number | {
  28571. width: number;
  28572. height: number;
  28573. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  28574. /**
  28575. * Create a multi render target texture
  28576. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  28577. * @param size defines the size of the texture
  28578. * @param options defines the creation options
  28579. * @returns the cube texture as an InternalTexture
  28580. */
  28581. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  28582. private _setupFramebufferDepthAttachments;
  28583. /**
  28584. * Updates the sample count of a render target texture
  28585. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  28586. * @param texture defines the texture to update
  28587. * @param samples defines the sample count to set
  28588. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  28589. */
  28590. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  28591. /**
  28592. * Update the sample count for a given multiple render target texture
  28593. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  28594. * @param textures defines the textures to update
  28595. * @param samples defines the sample count to set
  28596. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  28597. */
  28598. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  28599. /** @hidden */
  28600. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  28601. /** @hidden */
  28602. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  28603. /** @hidden */
  28604. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  28605. /** @hidden */
  28606. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  28607. /**
  28608. * Creates a new render target cube texture
  28609. * @param size defines the size of the texture
  28610. * @param options defines the options used to create the texture
  28611. * @returns a new render target cube texture stored in an InternalTexture
  28612. */
  28613. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  28614. /**
  28615. * Creates a cube texture
  28616. * @param rootUrl defines the url where the files to load is located
  28617. * @param scene defines the current scene
  28618. * @param files defines the list of files to load (1 per face)
  28619. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  28620. * @param onLoad defines an optional callback raised when the texture is loaded
  28621. * @param onError defines an optional callback raised if there is an issue to load the texture
  28622. * @param format defines the format of the data
  28623. * @param forcedExtension defines the extension to use to pick the right loader
  28624. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  28625. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  28626. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  28627. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  28628. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  28629. * @returns the cube texture as an InternalTexture
  28630. */
  28631. 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;
  28632. /**
  28633. * @hidden
  28634. */
  28635. _setCubeMapTextureParams(loadMipmap: boolean): void;
  28636. /**
  28637. * Update a raw cube texture
  28638. * @param texture defines the texture to udpdate
  28639. * @param data defines the data to store
  28640. * @param format defines the data format
  28641. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  28642. * @param invertY defines if data must be stored with Y axis inverted
  28643. * @param compression defines the compression used (null by default)
  28644. * @param level defines which level of the texture to update
  28645. */
  28646. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  28647. /**
  28648. * Creates a new raw cube texture
  28649. * @param data defines the array of data to use to create each face
  28650. * @param size defines the size of the textures
  28651. * @param format defines the format of the data
  28652. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  28653. * @param generateMipMaps defines if the engine should generate the mip levels
  28654. * @param invertY defines if data must be stored with Y axis inverted
  28655. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  28656. * @param compression defines the compression used (null by default)
  28657. * @returns the cube texture as an InternalTexture
  28658. */
  28659. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  28660. /**
  28661. * Creates a new raw cube texture from a specified url
  28662. * @param url defines the url where the data is located
  28663. * @param scene defines the current scene
  28664. * @param size defines the size of the textures
  28665. * @param format defines the format of the data
  28666. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  28667. * @param noMipmap defines if the engine should avoid generating the mip levels
  28668. * @param callback defines a callback used to extract texture data from loaded data
  28669. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  28670. * @param onLoad defines a callback called when texture is loaded
  28671. * @param onError defines a callback called if there is an error
  28672. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  28673. * @param invertY defines if data must be stored with Y axis inverted
  28674. * @returns the cube texture as an InternalTexture
  28675. */
  28676. 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;
  28677. /**
  28678. * Update a raw 3D texture
  28679. * @param texture defines the texture to update
  28680. * @param data defines the data to store
  28681. * @param format defines the data format
  28682. * @param invertY defines if data must be stored with Y axis inverted
  28683. * @param compression defines the used compression (can be null)
  28684. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  28685. */
  28686. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  28687. /**
  28688. * Creates a new raw 3D texture
  28689. * @param data defines the data used to create the texture
  28690. * @param width defines the width of the texture
  28691. * @param height defines the height of the texture
  28692. * @param depth defines the depth of the texture
  28693. * @param format defines the format of the texture
  28694. * @param generateMipMaps defines if the engine must generate mip levels
  28695. * @param invertY defines if data must be stored with Y axis inverted
  28696. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  28697. * @param compression defines the compressed used (can be null)
  28698. * @param textureType defines the compressed used (can be null)
  28699. * @returns a new raw 3D texture (stored in an InternalTexture)
  28700. */
  28701. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  28702. private _prepareWebGLTextureContinuation;
  28703. private _prepareWebGLTexture;
  28704. private _convertRGBtoRGBATextureData;
  28705. /** @hidden */
  28706. _releaseFramebufferObjects(texture: InternalTexture): void;
  28707. /** @hidden */
  28708. _releaseTexture(texture: InternalTexture): void;
  28709. private setProgram;
  28710. private _boundUniforms;
  28711. /**
  28712. * Binds an effect to the webGL context
  28713. * @param effect defines the effect to bind
  28714. */
  28715. bindSamplers(effect: Effect): void;
  28716. private _moveBoundTextureOnTop;
  28717. private _getCorrectTextureChannel;
  28718. private _linkTrackers;
  28719. private _removeDesignatedSlot;
  28720. private _activateCurrentTexture;
  28721. /** @hidden */
  28722. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  28723. /** @hidden */
  28724. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  28725. /**
  28726. * Sets a texture to the webGL context from a postprocess
  28727. * @param channel defines the channel to use
  28728. * @param postProcess defines the source postprocess
  28729. */
  28730. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  28731. /**
  28732. * Binds the output of the passed in post process to the texture channel specified
  28733. * @param channel The channel the texture should be bound to
  28734. * @param postProcess The post process which's output should be bound
  28735. */
  28736. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  28737. /**
  28738. * Unbind all textures from the webGL context
  28739. */
  28740. unbindAllTextures(): void;
  28741. /**
  28742. * Sets a texture to the according uniform.
  28743. * @param channel The texture channel
  28744. * @param uniform The uniform to set
  28745. * @param texture The texture to apply
  28746. */
  28747. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  28748. /**
  28749. * Sets a depth stencil texture from a render target to the according uniform.
  28750. * @param channel The texture channel
  28751. * @param uniform The uniform to set
  28752. * @param texture The render target texture containing the depth stencil texture to apply
  28753. */
  28754. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  28755. private _bindSamplerUniformToChannel;
  28756. private _getTextureWrapMode;
  28757. private _setTexture;
  28758. /**
  28759. * Sets an array of texture to the webGL context
  28760. * @param channel defines the channel where the texture array must be set
  28761. * @param uniform defines the associated uniform location
  28762. * @param textures defines the array of textures to bind
  28763. */
  28764. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  28765. /** @hidden */
  28766. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  28767. private _setTextureParameterFloat;
  28768. private _setTextureParameterInteger;
  28769. /**
  28770. * Reads pixels from the current frame buffer. Please note that this function can be slow
  28771. * @param x defines the x coordinate of the rectangle where pixels must be read
  28772. * @param y defines the y coordinate of the rectangle where pixels must be read
  28773. * @param width defines the width of the rectangle where pixels must be read
  28774. * @param height defines the height of the rectangle where pixels must be read
  28775. * @returns a Uint8Array containing RGBA colors
  28776. */
  28777. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  28778. /**
  28779. * Add an externaly attached data from its key.
  28780. * This method call will fail and return false, if such key already exists.
  28781. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  28782. * @param key the unique key that identifies the data
  28783. * @param data the data object to associate to the key for this Engine instance
  28784. * @return true if no such key were already present and the data was added successfully, false otherwise
  28785. */
  28786. addExternalData<T>(key: string, data: T): boolean;
  28787. /**
  28788. * Get an externaly attached data from its key
  28789. * @param key the unique key that identifies the data
  28790. * @return the associated data, if present (can be null), or undefined if not present
  28791. */
  28792. getExternalData<T>(key: string): T;
  28793. /**
  28794. * Get an externaly attached data from its key, create it using a factory if it's not already present
  28795. * @param key the unique key that identifies the data
  28796. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  28797. * @return the associated data, can be null if the factory returned null.
  28798. */
  28799. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  28800. /**
  28801. * Remove an externaly attached data from the Engine instance
  28802. * @param key the unique key that identifies the data
  28803. * @return true if the data was successfully removed, false if it doesn't exist
  28804. */
  28805. removeExternalData(key: string): boolean;
  28806. /**
  28807. * Unbind all vertex attributes from the webGL context
  28808. */
  28809. unbindAllAttributes(): void;
  28810. /**
  28811. * 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
  28812. */
  28813. releaseEffects(): void;
  28814. /**
  28815. * Dispose and release all associated resources
  28816. */
  28817. dispose(): void;
  28818. /**
  28819. * Display the loading screen
  28820. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28821. */
  28822. displayLoadingUI(): void;
  28823. /**
  28824. * Hide the loading screen
  28825. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28826. */
  28827. hideLoadingUI(): void;
  28828. /**
  28829. * Gets the current loading screen object
  28830. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28831. */
  28832. /**
  28833. * Sets the current loading screen object
  28834. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28835. */
  28836. loadingScreen: ILoadingScreen;
  28837. /**
  28838. * Sets the current loading screen text
  28839. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28840. */
  28841. loadingUIText: string;
  28842. /**
  28843. * Sets the current loading screen background color
  28844. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28845. */
  28846. loadingUIBackgroundColor: string;
  28847. /**
  28848. * Attach a new callback raised when context lost event is fired
  28849. * @param callback defines the callback to call
  28850. */
  28851. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  28852. /**
  28853. * Attach a new callback raised when context restored event is fired
  28854. * @param callback defines the callback to call
  28855. */
  28856. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  28857. /**
  28858. * Gets the source code of the vertex shader associated with a specific webGL program
  28859. * @param program defines the program to use
  28860. * @returns a string containing the source code of the vertex shader associated with the program
  28861. */
  28862. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  28863. /**
  28864. * Gets the source code of the fragment shader associated with a specific webGL program
  28865. * @param program defines the program to use
  28866. * @returns a string containing the source code of the fragment shader associated with the program
  28867. */
  28868. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  28869. /**
  28870. * Get the current error code of the webGL context
  28871. * @returns the error code
  28872. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  28873. */
  28874. getError(): number;
  28875. /**
  28876. * Gets the current framerate
  28877. * @returns a number representing the framerate
  28878. */
  28879. getFps(): number;
  28880. /**
  28881. * Gets the time spent between current and previous frame
  28882. * @returns a number representing the delta time in ms
  28883. */
  28884. getDeltaTime(): number;
  28885. private _measureFps;
  28886. /** @hidden */
  28887. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  28888. private _canRenderToFloatFramebuffer;
  28889. private _canRenderToHalfFloatFramebuffer;
  28890. private _canRenderToFramebuffer;
  28891. /** @hidden */
  28892. _getWebGLTextureType(type: number): number;
  28893. private _getInternalFormat;
  28894. /** @hidden */
  28895. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  28896. /** @hidden */
  28897. _getRGBAMultiSampleBufferFormat(type: number): number;
  28898. /** @hidden */
  28899. _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;
  28900. /** @hidden */
  28901. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  28902. private _partialLoadFile;
  28903. private _cascadeLoadFiles;
  28904. /**
  28905. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  28906. * @returns true if the engine can be created
  28907. * @ignorenaming
  28908. */
  28909. static isSupported(): boolean;
  28910. }
  28911. }
  28912. declare module "babylonjs/Materials/effect" {
  28913. import { Observable } from "babylonjs/Misc/observable";
  28914. import { Nullable } from "babylonjs/types";
  28915. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  28916. import { Engine } from "babylonjs/Engines/engine";
  28917. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  28918. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  28919. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  28920. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  28921. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28922. /**
  28923. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  28924. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  28925. */
  28926. export class EffectFallbacks {
  28927. private _defines;
  28928. private _currentRank;
  28929. private _maxRank;
  28930. private _mesh;
  28931. /**
  28932. * Removes the fallback from the bound mesh.
  28933. */
  28934. unBindMesh(): void;
  28935. /**
  28936. * Adds a fallback on the specified property.
  28937. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  28938. * @param define The name of the define in the shader
  28939. */
  28940. addFallback(rank: number, define: string): void;
  28941. /**
  28942. * Sets the mesh to use CPU skinning when needing to fallback.
  28943. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  28944. * @param mesh The mesh to use the fallbacks.
  28945. */
  28946. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  28947. /**
  28948. * Checks to see if more fallbacks are still availible.
  28949. */
  28950. readonly isMoreFallbacks: boolean;
  28951. /**
  28952. * Removes the defines that shoould be removed when falling back.
  28953. * @param currentDefines defines the current define statements for the shader.
  28954. * @param effect defines the current effect we try to compile
  28955. * @returns The resulting defines with defines of the current rank removed.
  28956. */
  28957. reduce(currentDefines: string, effect: Effect): string;
  28958. }
  28959. /**
  28960. * Options to be used when creating an effect.
  28961. */
  28962. export class EffectCreationOptions {
  28963. /**
  28964. * Atrributes that will be used in the shader.
  28965. */
  28966. attributes: string[];
  28967. /**
  28968. * Uniform varible names that will be set in the shader.
  28969. */
  28970. uniformsNames: string[];
  28971. /**
  28972. * Uniform buffer varible names that will be set in the shader.
  28973. */
  28974. uniformBuffersNames: string[];
  28975. /**
  28976. * Sampler texture variable names that will be set in the shader.
  28977. */
  28978. samplers: string[];
  28979. /**
  28980. * Define statements that will be set in the shader.
  28981. */
  28982. defines: any;
  28983. /**
  28984. * Possible fallbacks for this effect to improve performance when needed.
  28985. */
  28986. fallbacks: Nullable<EffectFallbacks>;
  28987. /**
  28988. * Callback that will be called when the shader is compiled.
  28989. */
  28990. onCompiled: Nullable<(effect: Effect) => void>;
  28991. /**
  28992. * Callback that will be called if an error occurs during shader compilation.
  28993. */
  28994. onError: Nullable<(effect: Effect, errors: string) => void>;
  28995. /**
  28996. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  28997. */
  28998. indexParameters: any;
  28999. /**
  29000. * Max number of lights that can be used in the shader.
  29001. */
  29002. maxSimultaneousLights: number;
  29003. /**
  29004. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  29005. */
  29006. transformFeedbackVaryings: Nullable<string[]>;
  29007. }
  29008. /**
  29009. * Effect containing vertex and fragment shader that can be executed on an object.
  29010. */
  29011. export class Effect {
  29012. /**
  29013. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29014. */
  29015. static ShadersRepository: string;
  29016. /**
  29017. * Name of the effect.
  29018. */
  29019. name: any;
  29020. /**
  29021. * String container all the define statements that should be set on the shader.
  29022. */
  29023. defines: string;
  29024. /**
  29025. * Callback that will be called when the shader is compiled.
  29026. */
  29027. onCompiled: Nullable<(effect: Effect) => void>;
  29028. /**
  29029. * Callback that will be called if an error occurs during shader compilation.
  29030. */
  29031. onError: Nullable<(effect: Effect, errors: string) => void>;
  29032. /**
  29033. * Callback that will be called when effect is bound.
  29034. */
  29035. onBind: Nullable<(effect: Effect) => void>;
  29036. /**
  29037. * Unique ID of the effect.
  29038. */
  29039. uniqueId: number;
  29040. /**
  29041. * Observable that will be called when the shader is compiled.
  29042. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  29043. */
  29044. onCompileObservable: Observable<Effect>;
  29045. /**
  29046. * Observable that will be called if an error occurs during shader compilation.
  29047. */
  29048. onErrorObservable: Observable<Effect>;
  29049. /** @hidden */
  29050. _onBindObservable: Nullable<Observable<Effect>>;
  29051. /**
  29052. * Observable that will be called when effect is bound.
  29053. */
  29054. readonly onBindObservable: Observable<Effect>;
  29055. /** @hidden */
  29056. _bonesComputationForcedToCPU: boolean;
  29057. private static _uniqueIdSeed;
  29058. private _engine;
  29059. private _uniformBuffersNames;
  29060. private _uniformsNames;
  29061. private _samplers;
  29062. private _isReady;
  29063. private _compilationError;
  29064. private _attributesNames;
  29065. private _attributes;
  29066. private _uniforms;
  29067. /**
  29068. * Key for the effect.
  29069. * @hidden
  29070. */
  29071. _key: string;
  29072. private _indexParameters;
  29073. private _fallbacks;
  29074. private _vertexSourceCode;
  29075. private _fragmentSourceCode;
  29076. private _vertexSourceCodeOverride;
  29077. private _fragmentSourceCodeOverride;
  29078. private _transformFeedbackVaryings;
  29079. /**
  29080. * Compiled shader to webGL program.
  29081. * @hidden
  29082. */
  29083. _program: WebGLProgram;
  29084. private _valueCache;
  29085. private static _baseCache;
  29086. /**
  29087. * Instantiates an effect.
  29088. * An effect can be used to create/manage/execute vertex and fragment shaders.
  29089. * @param baseName Name of the effect.
  29090. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  29091. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  29092. * @param samplers List of sampler variables that will be passed to the shader.
  29093. * @param engine Engine to be used to render the effect
  29094. * @param defines Define statements to be added to the shader.
  29095. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  29096. * @param onCompiled Callback that will be called when the shader is compiled.
  29097. * @param onError Callback that will be called if an error occurs during shader compilation.
  29098. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29099. */
  29100. 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);
  29101. /**
  29102. * Unique key for this effect
  29103. */
  29104. readonly key: string;
  29105. /**
  29106. * If the effect has been compiled and prepared.
  29107. * @returns if the effect is compiled and prepared.
  29108. */
  29109. isReady(): boolean;
  29110. /**
  29111. * The engine the effect was initialized with.
  29112. * @returns the engine.
  29113. */
  29114. getEngine(): Engine;
  29115. /**
  29116. * The compiled webGL program for the effect
  29117. * @returns the webGL program.
  29118. */
  29119. getProgram(): WebGLProgram;
  29120. /**
  29121. * The set of names of attribute variables for the shader.
  29122. * @returns An array of attribute names.
  29123. */
  29124. getAttributesNames(): string[];
  29125. /**
  29126. * Returns the attribute at the given index.
  29127. * @param index The index of the attribute.
  29128. * @returns The location of the attribute.
  29129. */
  29130. getAttributeLocation(index: number): number;
  29131. /**
  29132. * Returns the attribute based on the name of the variable.
  29133. * @param name of the attribute to look up.
  29134. * @returns the attribute location.
  29135. */
  29136. getAttributeLocationByName(name: string): number;
  29137. /**
  29138. * The number of attributes.
  29139. * @returns the numnber of attributes.
  29140. */
  29141. getAttributesCount(): number;
  29142. /**
  29143. * Gets the index of a uniform variable.
  29144. * @param uniformName of the uniform to look up.
  29145. * @returns the index.
  29146. */
  29147. getUniformIndex(uniformName: string): number;
  29148. /**
  29149. * Returns the attribute based on the name of the variable.
  29150. * @param uniformName of the uniform to look up.
  29151. * @returns the location of the uniform.
  29152. */
  29153. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  29154. /**
  29155. * Returns an array of sampler variable names
  29156. * @returns The array of sampler variable neames.
  29157. */
  29158. getSamplers(): string[];
  29159. /**
  29160. * The error from the last compilation.
  29161. * @returns the error string.
  29162. */
  29163. getCompilationError(): string;
  29164. /**
  29165. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  29166. * @param func The callback to be used.
  29167. */
  29168. executeWhenCompiled(func: (effect: Effect) => void): void;
  29169. private _checkIsReady;
  29170. /** @hidden */
  29171. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  29172. /** @hidden */
  29173. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  29174. /** @hidden */
  29175. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  29176. private _processShaderConversion;
  29177. private _processIncludes;
  29178. private _processPrecision;
  29179. /**
  29180. * Recompiles the webGL program
  29181. * @param vertexSourceCode The source code for the vertex shader.
  29182. * @param fragmentSourceCode The source code for the fragment shader.
  29183. * @param onCompiled Callback called when completed.
  29184. * @param onError Callback called on error.
  29185. * @hidden
  29186. */
  29187. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void): void;
  29188. /**
  29189. * Gets the uniform locations of the the specified variable names
  29190. * @param names THe names of the variables to lookup.
  29191. * @returns Array of locations in the same order as variable names.
  29192. */
  29193. getSpecificUniformLocations(names: string[]): Nullable<WebGLUniformLocation>[];
  29194. /**
  29195. * Prepares the effect
  29196. * @hidden
  29197. */
  29198. _prepareEffect(): void;
  29199. /**
  29200. * Checks if the effect is supported. (Must be called after compilation)
  29201. */
  29202. readonly isSupported: boolean;
  29203. /**
  29204. * Binds a texture to the engine to be used as output of the shader.
  29205. * @param channel Name of the output variable.
  29206. * @param texture Texture to bind.
  29207. * @hidden
  29208. */
  29209. _bindTexture(channel: string, texture: InternalTexture): void;
  29210. /**
  29211. * Sets a texture on the engine to be used in the shader.
  29212. * @param channel Name of the sampler variable.
  29213. * @param texture Texture to set.
  29214. */
  29215. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  29216. /**
  29217. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  29218. * @param channel Name of the sampler variable.
  29219. * @param texture Texture to set.
  29220. */
  29221. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  29222. /**
  29223. * Sets an array of textures on the engine to be used in the shader.
  29224. * @param channel Name of the variable.
  29225. * @param textures Textures to set.
  29226. */
  29227. setTextureArray(channel: string, textures: BaseTexture[]): void;
  29228. /**
  29229. * 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)
  29230. * @param channel Name of the sampler variable.
  29231. * @param postProcess Post process to get the input texture from.
  29232. */
  29233. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  29234. /**
  29235. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  29236. * 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)
  29237. * @param channel Name of the sampler variable.
  29238. * @param postProcess Post process to get the output texture from.
  29239. */
  29240. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  29241. /** @hidden */
  29242. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  29243. /** @hidden */
  29244. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  29245. /** @hidden */
  29246. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  29247. /** @hidden */
  29248. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  29249. /**
  29250. * Binds a buffer to a uniform.
  29251. * @param buffer Buffer to bind.
  29252. * @param name Name of the uniform variable to bind to.
  29253. */
  29254. bindUniformBuffer(buffer: WebGLBuffer, name: string): void;
  29255. /**
  29256. * Binds block to a uniform.
  29257. * @param blockName Name of the block to bind.
  29258. * @param index Index to bind.
  29259. */
  29260. bindUniformBlock(blockName: string, index: number): void;
  29261. /**
  29262. * Sets an interger value on a uniform variable.
  29263. * @param uniformName Name of the variable.
  29264. * @param value Value to be set.
  29265. * @returns this effect.
  29266. */
  29267. setInt(uniformName: string, value: number): Effect;
  29268. /**
  29269. * Sets an int array on a uniform variable.
  29270. * @param uniformName Name of the variable.
  29271. * @param array array to be set.
  29272. * @returns this effect.
  29273. */
  29274. setIntArray(uniformName: string, array: Int32Array): Effect;
  29275. /**
  29276. * 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)
  29277. * @param uniformName Name of the variable.
  29278. * @param array array to be set.
  29279. * @returns this effect.
  29280. */
  29281. setIntArray2(uniformName: string, array: Int32Array): Effect;
  29282. /**
  29283. * 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)
  29284. * @param uniformName Name of the variable.
  29285. * @param array array to be set.
  29286. * @returns this effect.
  29287. */
  29288. setIntArray3(uniformName: string, array: Int32Array): Effect;
  29289. /**
  29290. * 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)
  29291. * @param uniformName Name of the variable.
  29292. * @param array array to be set.
  29293. * @returns this effect.
  29294. */
  29295. setIntArray4(uniformName: string, array: Int32Array): Effect;
  29296. /**
  29297. * Sets an float array on a uniform variable.
  29298. * @param uniformName Name of the variable.
  29299. * @param array array to be set.
  29300. * @returns this effect.
  29301. */
  29302. setFloatArray(uniformName: string, array: Float32Array): Effect;
  29303. /**
  29304. * 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)
  29305. * @param uniformName Name of the variable.
  29306. * @param array array to be set.
  29307. * @returns this effect.
  29308. */
  29309. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  29310. /**
  29311. * 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)
  29312. * @param uniformName Name of the variable.
  29313. * @param array array to be set.
  29314. * @returns this effect.
  29315. */
  29316. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  29317. /**
  29318. * 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)
  29319. * @param uniformName Name of the variable.
  29320. * @param array array to be set.
  29321. * @returns this effect.
  29322. */
  29323. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  29324. /**
  29325. * Sets an array on a uniform variable.
  29326. * @param uniformName Name of the variable.
  29327. * @param array array to be set.
  29328. * @returns this effect.
  29329. */
  29330. setArray(uniformName: string, array: number[]): Effect;
  29331. /**
  29332. * 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)
  29333. * @param uniformName Name of the variable.
  29334. * @param array array to be set.
  29335. * @returns this effect.
  29336. */
  29337. setArray2(uniformName: string, array: number[]): Effect;
  29338. /**
  29339. * 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)
  29340. * @param uniformName Name of the variable.
  29341. * @param array array to be set.
  29342. * @returns this effect.
  29343. */
  29344. setArray3(uniformName: string, array: number[]): Effect;
  29345. /**
  29346. * 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)
  29347. * @param uniformName Name of the variable.
  29348. * @param array array to be set.
  29349. * @returns this effect.
  29350. */
  29351. setArray4(uniformName: string, array: number[]): Effect;
  29352. /**
  29353. * Sets matrices on a uniform variable.
  29354. * @param uniformName Name of the variable.
  29355. * @param matrices matrices to be set.
  29356. * @returns this effect.
  29357. */
  29358. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  29359. /**
  29360. * Sets matrix on a uniform variable.
  29361. * @param uniformName Name of the variable.
  29362. * @param matrix matrix to be set.
  29363. * @returns this effect.
  29364. */
  29365. setMatrix(uniformName: string, matrix: Matrix): Effect;
  29366. /**
  29367. * 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)
  29368. * @param uniformName Name of the variable.
  29369. * @param matrix matrix to be set.
  29370. * @returns this effect.
  29371. */
  29372. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  29373. /**
  29374. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  29375. * @param uniformName Name of the variable.
  29376. * @param matrix matrix to be set.
  29377. * @returns this effect.
  29378. */
  29379. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  29380. /**
  29381. * Sets a float on a uniform variable.
  29382. * @param uniformName Name of the variable.
  29383. * @param value value to be set.
  29384. * @returns this effect.
  29385. */
  29386. setFloat(uniformName: string, value: number): Effect;
  29387. /**
  29388. * Sets a boolean on a uniform variable.
  29389. * @param uniformName Name of the variable.
  29390. * @param bool value to be set.
  29391. * @returns this effect.
  29392. */
  29393. setBool(uniformName: string, bool: boolean): Effect;
  29394. /**
  29395. * Sets a Vector2 on a uniform variable.
  29396. * @param uniformName Name of the variable.
  29397. * @param vector2 vector2 to be set.
  29398. * @returns this effect.
  29399. */
  29400. setVector2(uniformName: string, vector2: Vector2): Effect;
  29401. /**
  29402. * Sets a float2 on a uniform variable.
  29403. * @param uniformName Name of the variable.
  29404. * @param x First float in float2.
  29405. * @param y Second float in float2.
  29406. * @returns this effect.
  29407. */
  29408. setFloat2(uniformName: string, x: number, y: number): Effect;
  29409. /**
  29410. * Sets a Vector3 on a uniform variable.
  29411. * @param uniformName Name of the variable.
  29412. * @param vector3 Value to be set.
  29413. * @returns this effect.
  29414. */
  29415. setVector3(uniformName: string, vector3: Vector3): Effect;
  29416. /**
  29417. * Sets a float3 on a uniform variable.
  29418. * @param uniformName Name of the variable.
  29419. * @param x First float in float3.
  29420. * @param y Second float in float3.
  29421. * @param z Third float in float3.
  29422. * @returns this effect.
  29423. */
  29424. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  29425. /**
  29426. * Sets a Vector4 on a uniform variable.
  29427. * @param uniformName Name of the variable.
  29428. * @param vector4 Value to be set.
  29429. * @returns this effect.
  29430. */
  29431. setVector4(uniformName: string, vector4: Vector4): Effect;
  29432. /**
  29433. * Sets a float4 on a uniform variable.
  29434. * @param uniformName Name of the variable.
  29435. * @param x First float in float4.
  29436. * @param y Second float in float4.
  29437. * @param z Third float in float4.
  29438. * @param w Fourth float in float4.
  29439. * @returns this effect.
  29440. */
  29441. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  29442. /**
  29443. * Sets a Color3 on a uniform variable.
  29444. * @param uniformName Name of the variable.
  29445. * @param color3 Value to be set.
  29446. * @returns this effect.
  29447. */
  29448. setColor3(uniformName: string, color3: Color3): Effect;
  29449. /**
  29450. * Sets a Color4 on a uniform variable.
  29451. * @param uniformName Name of the variable.
  29452. * @param color3 Value to be set.
  29453. * @param alpha Alpha value to be set.
  29454. * @returns this effect.
  29455. */
  29456. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  29457. /**
  29458. * Sets a Color4 on a uniform variable
  29459. * @param uniformName defines the name of the variable
  29460. * @param color4 defines the value to be set
  29461. * @returns this effect.
  29462. */
  29463. setDirectColor4(uniformName: string, color4: Color4): Effect;
  29464. /**
  29465. * This function will add a new shader to the shader store
  29466. * @param name the name of the shader
  29467. * @param pixelShader optional pixel shader content
  29468. * @param vertexShader optional vertex shader content
  29469. */
  29470. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  29471. /**
  29472. * Store of each shader (The can be looked up using effect.key)
  29473. */
  29474. static ShadersStore: {
  29475. [key: string]: string;
  29476. };
  29477. /**
  29478. * Store of each included file for a shader (The can be looked up using effect.key)
  29479. */
  29480. static IncludesShadersStore: {
  29481. [key: string]: string;
  29482. };
  29483. /**
  29484. * Resets the cache of effects.
  29485. */
  29486. static ResetCache(): void;
  29487. }
  29488. }
  29489. declare module "babylonjs/Materials/colorCurves" {
  29490. import { Effect } from "babylonjs/Materials/effect";
  29491. /**
  29492. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  29493. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  29494. * 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;
  29495. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  29496. */
  29497. export class ColorCurves {
  29498. private _dirty;
  29499. private _tempColor;
  29500. private _globalCurve;
  29501. private _highlightsCurve;
  29502. private _midtonesCurve;
  29503. private _shadowsCurve;
  29504. private _positiveCurve;
  29505. private _negativeCurve;
  29506. private _globalHue;
  29507. private _globalDensity;
  29508. private _globalSaturation;
  29509. private _globalExposure;
  29510. /**
  29511. * Gets the global Hue value.
  29512. * 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).
  29513. */
  29514. /**
  29515. * Sets the global Hue value.
  29516. * 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).
  29517. */
  29518. globalHue: number;
  29519. /**
  29520. * Gets the global Density value.
  29521. * 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.
  29522. * Values less than zero provide a filter of opposite hue.
  29523. */
  29524. /**
  29525. * Sets the global Density value.
  29526. * 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.
  29527. * Values less than zero provide a filter of opposite hue.
  29528. */
  29529. globalDensity: number;
  29530. /**
  29531. * Gets the global Saturation value.
  29532. * 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.
  29533. */
  29534. /**
  29535. * Sets the global Saturation value.
  29536. * 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.
  29537. */
  29538. globalSaturation: number;
  29539. /**
  29540. * Gets the global Exposure value.
  29541. * 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.
  29542. */
  29543. /**
  29544. * Sets the global Exposure value.
  29545. * 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.
  29546. */
  29547. globalExposure: number;
  29548. private _highlightsHue;
  29549. private _highlightsDensity;
  29550. private _highlightsSaturation;
  29551. private _highlightsExposure;
  29552. /**
  29553. * Gets the highlights Hue value.
  29554. * 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).
  29555. */
  29556. /**
  29557. * Sets the highlights Hue value.
  29558. * 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).
  29559. */
  29560. highlightsHue: number;
  29561. /**
  29562. * Gets the highlights Density value.
  29563. * 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.
  29564. * Values less than zero provide a filter of opposite hue.
  29565. */
  29566. /**
  29567. * Sets the highlights Density value.
  29568. * 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.
  29569. * Values less than zero provide a filter of opposite hue.
  29570. */
  29571. highlightsDensity: number;
  29572. /**
  29573. * Gets the highlights Saturation value.
  29574. * 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.
  29575. */
  29576. /**
  29577. * Sets the highlights Saturation value.
  29578. * 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.
  29579. */
  29580. highlightsSaturation: number;
  29581. /**
  29582. * Gets the highlights Exposure value.
  29583. * 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.
  29584. */
  29585. /**
  29586. * Sets the highlights Exposure value.
  29587. * 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.
  29588. */
  29589. highlightsExposure: number;
  29590. private _midtonesHue;
  29591. private _midtonesDensity;
  29592. private _midtonesSaturation;
  29593. private _midtonesExposure;
  29594. /**
  29595. * Gets the midtones Hue value.
  29596. * 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).
  29597. */
  29598. /**
  29599. * Sets the midtones Hue value.
  29600. * 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).
  29601. */
  29602. midtonesHue: number;
  29603. /**
  29604. * Gets the midtones Density value.
  29605. * 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.
  29606. * Values less than zero provide a filter of opposite hue.
  29607. */
  29608. /**
  29609. * Sets the midtones Density value.
  29610. * 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.
  29611. * Values less than zero provide a filter of opposite hue.
  29612. */
  29613. midtonesDensity: number;
  29614. /**
  29615. * Gets the midtones Saturation value.
  29616. * 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.
  29617. */
  29618. /**
  29619. * Sets the midtones Saturation value.
  29620. * 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.
  29621. */
  29622. midtonesSaturation: number;
  29623. /**
  29624. * Gets the midtones Exposure value.
  29625. * 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.
  29626. */
  29627. /**
  29628. * Sets the midtones Exposure value.
  29629. * 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.
  29630. */
  29631. midtonesExposure: number;
  29632. private _shadowsHue;
  29633. private _shadowsDensity;
  29634. private _shadowsSaturation;
  29635. private _shadowsExposure;
  29636. /**
  29637. * Gets the shadows Hue value.
  29638. * 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).
  29639. */
  29640. /**
  29641. * Sets the shadows Hue value.
  29642. * 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).
  29643. */
  29644. shadowsHue: number;
  29645. /**
  29646. * Gets the shadows Density value.
  29647. * 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.
  29648. * Values less than zero provide a filter of opposite hue.
  29649. */
  29650. /**
  29651. * Sets the shadows Density value.
  29652. * 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.
  29653. * Values less than zero provide a filter of opposite hue.
  29654. */
  29655. shadowsDensity: number;
  29656. /**
  29657. * Gets the shadows Saturation value.
  29658. * 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.
  29659. */
  29660. /**
  29661. * Sets the shadows Saturation value.
  29662. * 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.
  29663. */
  29664. shadowsSaturation: number;
  29665. /**
  29666. * Gets the shadows Exposure value.
  29667. * 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.
  29668. */
  29669. /**
  29670. * Sets the shadows Exposure value.
  29671. * 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.
  29672. */
  29673. shadowsExposure: number;
  29674. /**
  29675. * Returns the class name
  29676. * @returns The class name
  29677. */
  29678. getClassName(): string;
  29679. /**
  29680. * Binds the color curves to the shader.
  29681. * @param colorCurves The color curve to bind
  29682. * @param effect The effect to bind to
  29683. * @param positiveUniform The positive uniform shader parameter
  29684. * @param neutralUniform The neutral uniform shader parameter
  29685. * @param negativeUniform The negative uniform shader parameter
  29686. */
  29687. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  29688. /**
  29689. * Prepare the list of uniforms associated with the ColorCurves effects.
  29690. * @param uniformsList The list of uniforms used in the effect
  29691. */
  29692. static PrepareUniforms(uniformsList: string[]): void;
  29693. /**
  29694. * Returns color grading data based on a hue, density, saturation and exposure value.
  29695. * @param filterHue The hue of the color filter.
  29696. * @param filterDensity The density of the color filter.
  29697. * @param saturation The saturation.
  29698. * @param exposure The exposure.
  29699. * @param result The result data container.
  29700. */
  29701. private getColorGradingDataToRef;
  29702. /**
  29703. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  29704. * @param value The input slider value in range [-100,100].
  29705. * @returns Adjusted value.
  29706. */
  29707. private static applyColorGradingSliderNonlinear;
  29708. /**
  29709. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  29710. * @param hue The hue (H) input.
  29711. * @param saturation The saturation (S) input.
  29712. * @param brightness The brightness (B) input.
  29713. * @result An RGBA color represented as Vector4.
  29714. */
  29715. private static fromHSBToRef;
  29716. /**
  29717. * Returns a value clamped between min and max
  29718. * @param value The value to clamp
  29719. * @param min The minimum of value
  29720. * @param max The maximum of value
  29721. * @returns The clamped value.
  29722. */
  29723. private static clamp;
  29724. /**
  29725. * Clones the current color curve instance.
  29726. * @return The cloned curves
  29727. */
  29728. clone(): ColorCurves;
  29729. /**
  29730. * Serializes the current color curve instance to a json representation.
  29731. * @return a JSON representation
  29732. */
  29733. serialize(): any;
  29734. /**
  29735. * Parses the color curve from a json representation.
  29736. * @param source the JSON source to parse
  29737. * @return The parsed curves
  29738. */
  29739. static Parse(source: any): ColorCurves;
  29740. }
  29741. }
  29742. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  29743. import { Observable } from "babylonjs/Misc/observable";
  29744. import { Nullable } from "babylonjs/types";
  29745. import { Color4 } from "babylonjs/Maths/math";
  29746. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  29747. import { Effect } from "babylonjs/Materials/effect";
  29748. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  29749. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  29750. /**
  29751. * Interface to follow in your material defines to integrate easily the
  29752. * Image proccessing functions.
  29753. * @hidden
  29754. */
  29755. export interface IImageProcessingConfigurationDefines {
  29756. IMAGEPROCESSING: boolean;
  29757. VIGNETTE: boolean;
  29758. VIGNETTEBLENDMODEMULTIPLY: boolean;
  29759. VIGNETTEBLENDMODEOPAQUE: boolean;
  29760. TONEMAPPING: boolean;
  29761. TONEMAPPING_ACES: boolean;
  29762. CONTRAST: boolean;
  29763. EXPOSURE: boolean;
  29764. COLORCURVES: boolean;
  29765. COLORGRADING: boolean;
  29766. COLORGRADING3D: boolean;
  29767. SAMPLER3DGREENDEPTH: boolean;
  29768. SAMPLER3DBGRMAP: boolean;
  29769. IMAGEPROCESSINGPOSTPROCESS: boolean;
  29770. }
  29771. /**
  29772. * @hidden
  29773. */
  29774. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  29775. IMAGEPROCESSING: boolean;
  29776. VIGNETTE: boolean;
  29777. VIGNETTEBLENDMODEMULTIPLY: boolean;
  29778. VIGNETTEBLENDMODEOPAQUE: boolean;
  29779. TONEMAPPING: boolean;
  29780. TONEMAPPING_ACES: boolean;
  29781. CONTRAST: boolean;
  29782. COLORCURVES: boolean;
  29783. COLORGRADING: boolean;
  29784. COLORGRADING3D: boolean;
  29785. SAMPLER3DGREENDEPTH: boolean;
  29786. SAMPLER3DBGRMAP: boolean;
  29787. IMAGEPROCESSINGPOSTPROCESS: boolean;
  29788. EXPOSURE: boolean;
  29789. constructor();
  29790. }
  29791. /**
  29792. * This groups together the common properties used for image processing either in direct forward pass
  29793. * or through post processing effect depending on the use of the image processing pipeline in your scene
  29794. * or not.
  29795. */
  29796. export class ImageProcessingConfiguration {
  29797. /**
  29798. * Default tone mapping applied in BabylonJS.
  29799. */
  29800. static readonly TONEMAPPING_STANDARD: number;
  29801. /**
  29802. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  29803. * to other engines rendering to increase portability.
  29804. */
  29805. static readonly TONEMAPPING_ACES: number;
  29806. /**
  29807. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  29808. */
  29809. colorCurves: Nullable<ColorCurves>;
  29810. private _colorCurvesEnabled;
  29811. /**
  29812. * Gets wether the color curves effect is enabled.
  29813. */
  29814. /**
  29815. * Sets wether the color curves effect is enabled.
  29816. */
  29817. colorCurvesEnabled: boolean;
  29818. private _colorGradingTexture;
  29819. /**
  29820. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  29821. */
  29822. /**
  29823. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  29824. */
  29825. colorGradingTexture: Nullable<BaseTexture>;
  29826. private _colorGradingEnabled;
  29827. /**
  29828. * Gets wether the color grading effect is enabled.
  29829. */
  29830. /**
  29831. * Sets wether the color grading effect is enabled.
  29832. */
  29833. colorGradingEnabled: boolean;
  29834. private _colorGradingWithGreenDepth;
  29835. /**
  29836. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  29837. */
  29838. /**
  29839. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  29840. */
  29841. colorGradingWithGreenDepth: boolean;
  29842. private _colorGradingBGR;
  29843. /**
  29844. * Gets wether the color grading texture contains BGR values.
  29845. */
  29846. /**
  29847. * Sets wether the color grading texture contains BGR values.
  29848. */
  29849. colorGradingBGR: boolean;
  29850. /** @hidden */
  29851. _exposure: number;
  29852. /**
  29853. * Gets the Exposure used in the effect.
  29854. */
  29855. /**
  29856. * Sets the Exposure used in the effect.
  29857. */
  29858. exposure: number;
  29859. private _toneMappingEnabled;
  29860. /**
  29861. * Gets wether the tone mapping effect is enabled.
  29862. */
  29863. /**
  29864. * Sets wether the tone mapping effect is enabled.
  29865. */
  29866. toneMappingEnabled: boolean;
  29867. private _toneMappingType;
  29868. /**
  29869. * Gets the type of tone mapping effect.
  29870. */
  29871. /**
  29872. * Sets the type of tone mapping effect used in BabylonJS.
  29873. */
  29874. toneMappingType: number;
  29875. protected _contrast: number;
  29876. /**
  29877. * Gets the contrast used in the effect.
  29878. */
  29879. /**
  29880. * Sets the contrast used in the effect.
  29881. */
  29882. contrast: number;
  29883. /**
  29884. * Vignette stretch size.
  29885. */
  29886. vignetteStretch: number;
  29887. /**
  29888. * Vignette centre X Offset.
  29889. */
  29890. vignetteCentreX: number;
  29891. /**
  29892. * Vignette centre Y Offset.
  29893. */
  29894. vignetteCentreY: number;
  29895. /**
  29896. * Vignette weight or intensity of the vignette effect.
  29897. */
  29898. vignetteWeight: number;
  29899. /**
  29900. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  29901. * if vignetteEnabled is set to true.
  29902. */
  29903. vignetteColor: Color4;
  29904. /**
  29905. * Camera field of view used by the Vignette effect.
  29906. */
  29907. vignetteCameraFov: number;
  29908. private _vignetteBlendMode;
  29909. /**
  29910. * Gets the vignette blend mode allowing different kind of effect.
  29911. */
  29912. /**
  29913. * Sets the vignette blend mode allowing different kind of effect.
  29914. */
  29915. vignetteBlendMode: number;
  29916. private _vignetteEnabled;
  29917. /**
  29918. * Gets wether the vignette effect is enabled.
  29919. */
  29920. /**
  29921. * Sets wether the vignette effect is enabled.
  29922. */
  29923. vignetteEnabled: boolean;
  29924. private _applyByPostProcess;
  29925. /**
  29926. * Gets wether the image processing is applied through a post process or not.
  29927. */
  29928. /**
  29929. * Sets wether the image processing is applied through a post process or not.
  29930. */
  29931. applyByPostProcess: boolean;
  29932. private _isEnabled;
  29933. /**
  29934. * Gets wether the image processing is enabled or not.
  29935. */
  29936. /**
  29937. * Sets wether the image processing is enabled or not.
  29938. */
  29939. isEnabled: boolean;
  29940. /**
  29941. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  29942. */
  29943. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  29944. /**
  29945. * Method called each time the image processing information changes requires to recompile the effect.
  29946. */
  29947. protected _updateParameters(): void;
  29948. /**
  29949. * Gets the current class name.
  29950. * @return "ImageProcessingConfiguration"
  29951. */
  29952. getClassName(): string;
  29953. /**
  29954. * Prepare the list of uniforms associated with the Image Processing effects.
  29955. * @param uniforms The list of uniforms used in the effect
  29956. * @param defines the list of defines currently in use
  29957. */
  29958. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  29959. /**
  29960. * Prepare the list of samplers associated with the Image Processing effects.
  29961. * @param samplersList The list of uniforms used in the effect
  29962. * @param defines the list of defines currently in use
  29963. */
  29964. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  29965. /**
  29966. * Prepare the list of defines associated to the shader.
  29967. * @param defines the list of defines to complete
  29968. * @param forPostProcess Define if we are currently in post process mode or not
  29969. */
  29970. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  29971. /**
  29972. * Returns true if all the image processing information are ready.
  29973. * @returns True if ready, otherwise, false
  29974. */
  29975. isReady(): boolean;
  29976. /**
  29977. * Binds the image processing to the shader.
  29978. * @param effect The effect to bind to
  29979. * @param aspectRatio Define the current aspect ratio of the effect
  29980. */
  29981. bind(effect: Effect, aspectRatio?: number): void;
  29982. /**
  29983. * Clones the current image processing instance.
  29984. * @return The cloned image processing
  29985. */
  29986. clone(): ImageProcessingConfiguration;
  29987. /**
  29988. * Serializes the current image processing instance to a json representation.
  29989. * @return a JSON representation
  29990. */
  29991. serialize(): any;
  29992. /**
  29993. * Parses the image processing from a json representation.
  29994. * @param source the JSON source to parse
  29995. * @return The parsed image processing
  29996. */
  29997. static Parse(source: any): ImageProcessingConfiguration;
  29998. private static _VIGNETTEMODE_MULTIPLY;
  29999. private static _VIGNETTEMODE_OPAQUE;
  30000. /**
  30001. * Used to apply the vignette as a mix with the pixel color.
  30002. */
  30003. static readonly VIGNETTEMODE_MULTIPLY: number;
  30004. /**
  30005. * Used to apply the vignette as a replacement of the pixel color.
  30006. */
  30007. static readonly VIGNETTEMODE_OPAQUE: number;
  30008. }
  30009. }
  30010. declare module "babylonjs/Materials/fresnelParameters" {
  30011. import { Color3 } from "babylonjs/Maths/math";
  30012. /**
  30013. * This represents all the required information to add a fresnel effect on a material:
  30014. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30015. */
  30016. export class FresnelParameters {
  30017. private _isEnabled;
  30018. /**
  30019. * Define if the fresnel effect is enable or not.
  30020. */
  30021. isEnabled: boolean;
  30022. /**
  30023. * Define the color used on edges (grazing angle)
  30024. */
  30025. leftColor: Color3;
  30026. /**
  30027. * Define the color used on center
  30028. */
  30029. rightColor: Color3;
  30030. /**
  30031. * Define bias applied to computed fresnel term
  30032. */
  30033. bias: number;
  30034. /**
  30035. * Defined the power exponent applied to fresnel term
  30036. */
  30037. power: number;
  30038. /**
  30039. * Clones the current fresnel and its valuues
  30040. * @returns a clone fresnel configuration
  30041. */
  30042. clone(): FresnelParameters;
  30043. /**
  30044. * Serializes the current fresnel parameters to a JSON representation.
  30045. * @return the JSON serialization
  30046. */
  30047. serialize(): any;
  30048. /**
  30049. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  30050. * @param parsedFresnelParameters Define the JSON representation
  30051. * @returns the parsed parameters
  30052. */
  30053. static Parse(parsedFresnelParameters: any): FresnelParameters;
  30054. }
  30055. }
  30056. declare module "babylonjs/Misc/decorators" {
  30057. import { Nullable } from "babylonjs/types";
  30058. import { Scene } from "babylonjs/scene";
  30059. import { IAnimatable } from "babylonjs/Misc/tools";
  30060. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  30061. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30062. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30063. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30064. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30065. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30066. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30067. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30068. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30069. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30070. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30071. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30072. /**
  30073. * Decorator used to define property that can be serialized as reference to a camera
  30074. * @param sourceName defines the name of the property to decorate
  30075. */
  30076. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30077. /**
  30078. * Class used to help serialization objects
  30079. */
  30080. export class SerializationHelper {
  30081. /** hidden */
  30082. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  30083. /** hidden */
  30084. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  30085. /** hidden */
  30086. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  30087. /** hidden */
  30088. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  30089. /**
  30090. * Appends the serialized animations from the source animations
  30091. * @param source Source containing the animations
  30092. * @param destination Target to store the animations
  30093. */
  30094. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  30095. /**
  30096. * Static function used to serialized a specific entity
  30097. * @param entity defines the entity to serialize
  30098. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  30099. * @returns a JSON compatible object representing the serialization of the entity
  30100. */
  30101. static Serialize<T>(entity: T, serializationObject?: any): any;
  30102. /**
  30103. * Creates a new entity from a serialization data object
  30104. * @param creationFunction defines a function used to instanciated the new entity
  30105. * @param source defines the source serialization data
  30106. * @param scene defines the hosting scene
  30107. * @param rootUrl defines the root url for resources
  30108. * @returns a new entity
  30109. */
  30110. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  30111. /**
  30112. * Clones an object
  30113. * @param creationFunction defines the function used to instanciate the new object
  30114. * @param source defines the source object
  30115. * @returns the cloned object
  30116. */
  30117. static Clone<T>(creationFunction: () => T, source: T): T;
  30118. /**
  30119. * Instanciates a new object based on a source one (some data will be shared between both object)
  30120. * @param creationFunction defines the function used to instanciate the new object
  30121. * @param source defines the source object
  30122. * @returns the new object
  30123. */
  30124. static Instanciate<T>(creationFunction: () => T, source: T): T;
  30125. }
  30126. }
  30127. declare module "babylonjs/Cameras/camera" {
  30128. import { SmartArray } from "babylonjs/Misc/smartArray";
  30129. import { Observable } from "babylonjs/Misc/observable";
  30130. import { Nullable } from "babylonjs/types";
  30131. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  30132. import { Scene } from "babylonjs/scene";
  30133. import { Matrix, Vector3, Viewport } from "babylonjs/Maths/math";
  30134. import { Node } from "babylonjs/node";
  30135. import { Mesh } from "babylonjs/Meshes/mesh";
  30136. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  30137. import { ICullable } from "babylonjs/Culling/boundingInfo";
  30138. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  30139. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30140. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  30141. import { Ray } from "babylonjs/Culling/ray";
  30142. /**
  30143. * This is the base class of all the camera used in the application.
  30144. * @see http://doc.babylonjs.com/features/cameras
  30145. */
  30146. export class Camera extends Node {
  30147. /** @hidden */
  30148. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  30149. /**
  30150. * This is the default projection mode used by the cameras.
  30151. * It helps recreating a feeling of perspective and better appreciate depth.
  30152. * This is the best way to simulate real life cameras.
  30153. */
  30154. static readonly PERSPECTIVE_CAMERA: number;
  30155. /**
  30156. * This helps creating camera with an orthographic mode.
  30157. * 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.
  30158. */
  30159. static readonly ORTHOGRAPHIC_CAMERA: number;
  30160. /**
  30161. * This is the default FOV mode for perspective cameras.
  30162. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  30163. */
  30164. static readonly FOVMODE_VERTICAL_FIXED: number;
  30165. /**
  30166. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  30167. */
  30168. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  30169. /**
  30170. * This specifies ther is no need for a camera rig.
  30171. * Basically only one eye is rendered corresponding to the camera.
  30172. */
  30173. static readonly RIG_MODE_NONE: number;
  30174. /**
  30175. * Simulates a camera Rig with one blue eye and one red eye.
  30176. * This can be use with 3d blue and red glasses.
  30177. */
  30178. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  30179. /**
  30180. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  30181. */
  30182. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  30183. /**
  30184. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  30185. */
  30186. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  30187. /**
  30188. * Defines that both eyes of the camera will be rendered over under each other.
  30189. */
  30190. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  30191. /**
  30192. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  30193. */
  30194. static readonly RIG_MODE_VR: number;
  30195. /**
  30196. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  30197. */
  30198. static readonly RIG_MODE_WEBVR: number;
  30199. /**
  30200. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  30201. */
  30202. static readonly RIG_MODE_CUSTOM: number;
  30203. /**
  30204. * Defines if by default attaching controls should prevent the default javascript event to continue.
  30205. */
  30206. static ForceAttachControlToAlwaysPreventDefault: boolean;
  30207. /**
  30208. * @hidden
  30209. * Might be removed once multiview will be a thing
  30210. */
  30211. static UseAlternateWebVRRendering: boolean;
  30212. /**
  30213. * Define the input manager associated with the camera.
  30214. */
  30215. inputs: CameraInputsManager<Camera>;
  30216. /** @hidden */
  30217. _position: Vector3;
  30218. /**
  30219. * Define the current local position of the camera in the scene
  30220. */
  30221. position: Vector3;
  30222. /**
  30223. * The vector the camera should consider as up.
  30224. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  30225. */
  30226. upVector: Vector3;
  30227. /**
  30228. * Define the current limit on the left side for an orthographic camera
  30229. * In scene unit
  30230. */
  30231. orthoLeft: Nullable<number>;
  30232. /**
  30233. * Define the current limit on the right side for an orthographic camera
  30234. * In scene unit
  30235. */
  30236. orthoRight: Nullable<number>;
  30237. /**
  30238. * Define the current limit on the bottom side for an orthographic camera
  30239. * In scene unit
  30240. */
  30241. orthoBottom: Nullable<number>;
  30242. /**
  30243. * Define the current limit on the top side for an orthographic camera
  30244. * In scene unit
  30245. */
  30246. orthoTop: Nullable<number>;
  30247. /**
  30248. * Field Of View is set in Radians. (default is 0.8)
  30249. */
  30250. fov: number;
  30251. /**
  30252. * Define the minimum distance the camera can see from.
  30253. * This is important to note that the depth buffer are not infinite and the closer it starts
  30254. * the more your scene might encounter depth fighting issue.
  30255. */
  30256. minZ: number;
  30257. /**
  30258. * Define the maximum distance the camera can see to.
  30259. * This is important to note that the depth buffer are not infinite and the further it end
  30260. * the more your scene might encounter depth fighting issue.
  30261. */
  30262. maxZ: number;
  30263. /**
  30264. * Define the default inertia of the camera.
  30265. * This helps giving a smooth feeling to the camera movement.
  30266. */
  30267. inertia: number;
  30268. /**
  30269. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  30270. */
  30271. mode: number;
  30272. /**
  30273. * Define wether the camera is intermediate.
  30274. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  30275. */
  30276. isIntermediate: boolean;
  30277. /**
  30278. * Define the viewport of the camera.
  30279. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  30280. */
  30281. viewport: Viewport;
  30282. /**
  30283. * Restricts the camera to viewing objects with the same layerMask.
  30284. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  30285. */
  30286. layerMask: number;
  30287. /**
  30288. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  30289. */
  30290. fovMode: number;
  30291. /**
  30292. * Rig mode of the camera.
  30293. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  30294. * This is normally controlled byt the camera themselves as internal use.
  30295. */
  30296. cameraRigMode: number;
  30297. /**
  30298. * Defines the distance between both "eyes" in case of a RIG
  30299. */
  30300. interaxialDistance: number;
  30301. /**
  30302. * Defines if stereoscopic rendering is done side by side or over under.
  30303. */
  30304. isStereoscopicSideBySide: boolean;
  30305. /**
  30306. * 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
  30307. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  30308. * else in the scene.
  30309. */
  30310. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  30311. /**
  30312. * When set, the camera will render to this render target instead of the default canvas
  30313. */
  30314. outputRenderTarget: Nullable<RenderTargetTexture>;
  30315. /**
  30316. * Observable triggered when the camera view matrix has changed.
  30317. */
  30318. onViewMatrixChangedObservable: Observable<Camera>;
  30319. /**
  30320. * Observable triggered when the camera Projection matrix has changed.
  30321. */
  30322. onProjectionMatrixChangedObservable: Observable<Camera>;
  30323. /**
  30324. * Observable triggered when the inputs have been processed.
  30325. */
  30326. onAfterCheckInputsObservable: Observable<Camera>;
  30327. /**
  30328. * Observable triggered when reset has been called and applied to the camera.
  30329. */
  30330. onRestoreStateObservable: Observable<Camera>;
  30331. /** @hidden */
  30332. _cameraRigParams: any;
  30333. /** @hidden */
  30334. _rigCameras: Camera[];
  30335. /** @hidden */
  30336. _rigPostProcess: Nullable<PostProcess>;
  30337. protected _webvrViewMatrix: Matrix;
  30338. /** @hidden */
  30339. _skipRendering: boolean;
  30340. /** @hidden */
  30341. _alternateCamera: Camera;
  30342. /** @hidden */
  30343. _projectionMatrix: Matrix;
  30344. /** @hidden */
  30345. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  30346. /** @hidden */
  30347. _activeMeshes: SmartArray<AbstractMesh>;
  30348. protected _globalPosition: Vector3;
  30349. /** hidden */
  30350. _computedViewMatrix: Matrix;
  30351. private _doNotComputeProjectionMatrix;
  30352. private _transformMatrix;
  30353. private _frustumPlanes;
  30354. private _refreshFrustumPlanes;
  30355. private _storedFov;
  30356. private _stateStored;
  30357. /**
  30358. * Instantiates a new camera object.
  30359. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  30360. * @see http://doc.babylonjs.com/features/cameras
  30361. * @param name Defines the name of the camera in the scene
  30362. * @param position Defines the position of the camera
  30363. * @param scene Defines the scene the camera belongs too
  30364. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  30365. */
  30366. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  30367. /**
  30368. * Store current camera state (fov, position, etc..)
  30369. * @returns the camera
  30370. */
  30371. storeState(): Camera;
  30372. /**
  30373. * Restores the camera state values if it has been stored. You must call storeState() first
  30374. */
  30375. protected _restoreStateValues(): boolean;
  30376. /**
  30377. * Restored camera state. You must call storeState() first.
  30378. * @returns true if restored and false otherwise
  30379. */
  30380. restoreState(): boolean;
  30381. /**
  30382. * Gets the class name of the camera.
  30383. * @returns the class name
  30384. */
  30385. getClassName(): string;
  30386. /** @hidden */
  30387. readonly _isCamera: boolean;
  30388. /**
  30389. * Gets a string representation of the camera useful for debug purpose.
  30390. * @param fullDetails Defines that a more verboe level of logging is required
  30391. * @returns the string representation
  30392. */
  30393. toString(fullDetails?: boolean): string;
  30394. /**
  30395. * Gets the current world space position of the camera.
  30396. */
  30397. readonly globalPosition: Vector3;
  30398. /**
  30399. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  30400. * @returns the active meshe list
  30401. */
  30402. getActiveMeshes(): SmartArray<AbstractMesh>;
  30403. /**
  30404. * Check wether a mesh is part of the current active mesh list of the camera
  30405. * @param mesh Defines the mesh to check
  30406. * @returns true if active, false otherwise
  30407. */
  30408. isActiveMesh(mesh: Mesh): boolean;
  30409. /**
  30410. * Is this camera ready to be used/rendered
  30411. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  30412. * @return true if the camera is ready
  30413. */
  30414. isReady(completeCheck?: boolean): boolean;
  30415. /** @hidden */
  30416. _initCache(): void;
  30417. /** @hidden */
  30418. _updateCache(ignoreParentClass?: boolean): void;
  30419. /** @hidden */
  30420. _isSynchronized(): boolean;
  30421. /** @hidden */
  30422. _isSynchronizedViewMatrix(): boolean;
  30423. /** @hidden */
  30424. _isSynchronizedProjectionMatrix(): boolean;
  30425. /**
  30426. * Attach the input controls to a specific dom element to get the input from.
  30427. * @param element Defines the element the controls should be listened from
  30428. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  30429. */
  30430. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  30431. /**
  30432. * Detach the current controls from the specified dom element.
  30433. * @param element Defines the element to stop listening the inputs from
  30434. */
  30435. detachControl(element: HTMLElement): void;
  30436. /**
  30437. * Update the camera state according to the different inputs gathered during the frame.
  30438. */
  30439. update(): void;
  30440. /** @hidden */
  30441. _checkInputs(): void;
  30442. /** @hidden */
  30443. readonly rigCameras: Camera[];
  30444. /**
  30445. * Gets the post process used by the rig cameras
  30446. */
  30447. readonly rigPostProcess: Nullable<PostProcess>;
  30448. /**
  30449. * Internal, gets the first post proces.
  30450. * @returns the first post process to be run on this camera.
  30451. */
  30452. _getFirstPostProcess(): Nullable<PostProcess>;
  30453. private _cascadePostProcessesToRigCams;
  30454. /**
  30455. * Attach a post process to the camera.
  30456. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  30457. * @param postProcess The post process to attach to the camera
  30458. * @param insertAt The position of the post process in case several of them are in use in the scene
  30459. * @returns the position the post process has been inserted at
  30460. */
  30461. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  30462. /**
  30463. * Detach a post process to the camera.
  30464. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  30465. * @param postProcess The post process to detach from the camera
  30466. */
  30467. detachPostProcess(postProcess: PostProcess): void;
  30468. /**
  30469. * Gets the current world matrix of the camera
  30470. */
  30471. getWorldMatrix(): Matrix;
  30472. /** @hidden */
  30473. _getViewMatrix(): Matrix;
  30474. /**
  30475. * Gets the current view matrix of the camera.
  30476. * @param force forces the camera to recompute the matrix without looking at the cached state
  30477. * @returns the view matrix
  30478. */
  30479. getViewMatrix(force?: boolean): Matrix;
  30480. /**
  30481. * Freeze the projection matrix.
  30482. * It will prevent the cache check of the camera projection compute and can speed up perf
  30483. * if no parameter of the camera are meant to change
  30484. * @param projection Defines manually a projection if necessary
  30485. */
  30486. freezeProjectionMatrix(projection?: Matrix): void;
  30487. /**
  30488. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  30489. */
  30490. unfreezeProjectionMatrix(): void;
  30491. /**
  30492. * Gets the current projection matrix of the camera.
  30493. * @param force forces the camera to recompute the matrix without looking at the cached state
  30494. * @returns the projection matrix
  30495. */
  30496. getProjectionMatrix(force?: boolean): Matrix;
  30497. /**
  30498. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  30499. * @returns a Matrix
  30500. */
  30501. getTransformationMatrix(): Matrix;
  30502. private _updateFrustumPlanes;
  30503. /**
  30504. * Checks if a cullable object (mesh...) is in the camera frustum
  30505. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  30506. * @param target The object to check
  30507. * @returns true if the object is in frustum otherwise false
  30508. */
  30509. isInFrustum(target: ICullable): boolean;
  30510. /**
  30511. * Checks if a cullable object (mesh...) is in the camera frustum
  30512. * Unlike isInFrustum this cheks the full bounding box
  30513. * @param target The object to check
  30514. * @returns true if the object is in frustum otherwise false
  30515. */
  30516. isCompletelyInFrustum(target: ICullable): boolean;
  30517. /**
  30518. * Gets a ray in the forward direction from the camera.
  30519. * @param length Defines the length of the ray to create
  30520. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  30521. * @param origin Defines the start point of the ray which defaults to the camera position
  30522. * @returns the forward ray
  30523. */
  30524. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  30525. /**
  30526. * Releases resources associated with this node.
  30527. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  30528. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  30529. */
  30530. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  30531. /** @hidden */
  30532. _isLeftCamera: boolean;
  30533. /**
  30534. * Gets the left camera of a rig setup in case of Rigged Camera
  30535. */
  30536. readonly isLeftCamera: boolean;
  30537. /** @hidden */
  30538. _isRightCamera: boolean;
  30539. /**
  30540. * Gets the right camera of a rig setup in case of Rigged Camera
  30541. */
  30542. readonly isRightCamera: boolean;
  30543. /**
  30544. * Gets the left camera of a rig setup in case of Rigged Camera
  30545. */
  30546. readonly leftCamera: Nullable<FreeCamera>;
  30547. /**
  30548. * Gets the right camera of a rig setup in case of Rigged Camera
  30549. */
  30550. readonly rightCamera: Nullable<FreeCamera>;
  30551. /**
  30552. * Gets the left camera target of a rig setup in case of Rigged Camera
  30553. * @returns the target position
  30554. */
  30555. getLeftTarget(): Nullable<Vector3>;
  30556. /**
  30557. * Gets the right camera target of a rig setup in case of Rigged Camera
  30558. * @returns the target position
  30559. */
  30560. getRightTarget(): Nullable<Vector3>;
  30561. /**
  30562. * @hidden
  30563. */
  30564. setCameraRigMode(mode: number, rigParams: any): void;
  30565. /** @hidden */
  30566. static _setStereoscopicRigMode(camera: Camera): void;
  30567. /** @hidden */
  30568. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  30569. /** @hidden */
  30570. static _setVRRigMode(camera: Camera, rigParams: any): void;
  30571. /** @hidden */
  30572. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  30573. /** @hidden */
  30574. _getVRProjectionMatrix(): Matrix;
  30575. protected _updateCameraRotationMatrix(): void;
  30576. protected _updateWebVRCameraRotationMatrix(): void;
  30577. /**
  30578. * This function MUST be overwritten by the different WebVR cameras available.
  30579. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  30580. * @hidden
  30581. */
  30582. _getWebVRProjectionMatrix(): Matrix;
  30583. /**
  30584. * This function MUST be overwritten by the different WebVR cameras available.
  30585. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  30586. * @hidden
  30587. */
  30588. _getWebVRViewMatrix(): Matrix;
  30589. /** @hidden */
  30590. setCameraRigParameter(name: string, value: any): void;
  30591. /**
  30592. * needs to be overridden by children so sub has required properties to be copied
  30593. * @hidden
  30594. */
  30595. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  30596. /**
  30597. * May need to be overridden by children
  30598. * @hidden
  30599. */
  30600. _updateRigCameras(): void;
  30601. /** @hidden */
  30602. _setupInputs(): void;
  30603. /**
  30604. * Serialiaze the camera setup to a json represention
  30605. * @returns the JSON representation
  30606. */
  30607. serialize(): any;
  30608. /**
  30609. * Clones the current camera.
  30610. * @param name The cloned camera name
  30611. * @returns the cloned camera
  30612. */
  30613. clone(name: string): Camera;
  30614. /**
  30615. * Gets the direction of the camera relative to a given local axis.
  30616. * @param localAxis Defines the reference axis to provide a relative direction.
  30617. * @return the direction
  30618. */
  30619. getDirection(localAxis: Vector3): Vector3;
  30620. /**
  30621. * Gets the direction of the camera relative to a given local axis into a passed vector.
  30622. * @param localAxis Defines the reference axis to provide a relative direction.
  30623. * @param result Defines the vector to store the result in
  30624. */
  30625. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  30626. /**
  30627. * Gets a camera constructor for a given camera type
  30628. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  30629. * @param name The name of the camera the result will be able to instantiate
  30630. * @param scene The scene the result will construct the camera in
  30631. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  30632. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  30633. * @returns a factory method to construc the camera
  30634. */
  30635. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  30636. /**
  30637. * Compute the world matrix of the camera.
  30638. * @returns the camera workd matrix
  30639. */
  30640. computeWorldMatrix(): Matrix;
  30641. /**
  30642. * Parse a JSON and creates the camera from the parsed information
  30643. * @param parsedCamera The JSON to parse
  30644. * @param scene The scene to instantiate the camera in
  30645. * @returns the newly constructed camera
  30646. */
  30647. static Parse(parsedCamera: any, scene: Scene): Camera;
  30648. }
  30649. }
  30650. declare module "babylonjs/Misc/tools" {
  30651. import { FloatArray, IndicesArray, Nullable } from "babylonjs/types";
  30652. import { Color4, Color3, Vector2, Vector3 } from "babylonjs/Maths/math";
  30653. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  30654. import { Observable } from "babylonjs/Misc/observable";
  30655. import { DomManagement } from "babylonjs/Misc/domManagement";
  30656. import { Camera } from "babylonjs/Cameras/camera";
  30657. import { Engine } from "babylonjs/Engines/engine";
  30658. import { Animation } from "babylonjs/Animations/animation";
  30659. /**
  30660. * Interface for any object that can request an animation frame
  30661. */
  30662. export interface ICustomAnimationFrameRequester {
  30663. /**
  30664. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  30665. */
  30666. renderFunction?: Function;
  30667. /**
  30668. * Called to request the next frame to render to
  30669. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  30670. */
  30671. requestAnimationFrame: Function;
  30672. /**
  30673. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  30674. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  30675. */
  30676. requestID?: number;
  30677. }
  30678. /**
  30679. * Interface containing an array of animations
  30680. */
  30681. export interface IAnimatable {
  30682. /**
  30683. * Array of animations
  30684. */
  30685. animations: Array<Animation>;
  30686. }
  30687. /** Interface used by value gradients (color, factor, ...) */
  30688. export interface IValueGradient {
  30689. /**
  30690. * Gets or sets the gradient value (between 0 and 1)
  30691. */
  30692. gradient: number;
  30693. }
  30694. /** Class used to store color4 gradient */
  30695. export class ColorGradient implements IValueGradient {
  30696. /**
  30697. * Gets or sets the gradient value (between 0 and 1)
  30698. */
  30699. gradient: number;
  30700. /**
  30701. * Gets or sets first associated color
  30702. */
  30703. color1: Color4;
  30704. /**
  30705. * Gets or sets second associated color
  30706. */
  30707. color2?: Color4;
  30708. /**
  30709. * Will get a color picked randomly between color1 and color2.
  30710. * If color2 is undefined then color1 will be used
  30711. * @param result defines the target Color4 to store the result in
  30712. */
  30713. getColorToRef(result: Color4): void;
  30714. }
  30715. /** Class used to store color 3 gradient */
  30716. export class Color3Gradient implements IValueGradient {
  30717. /**
  30718. * Gets or sets the gradient value (between 0 and 1)
  30719. */
  30720. gradient: number;
  30721. /**
  30722. * Gets or sets the associated color
  30723. */
  30724. color: Color3;
  30725. }
  30726. /** Class used to store factor gradient */
  30727. export class FactorGradient implements IValueGradient {
  30728. /**
  30729. * Gets or sets the gradient value (between 0 and 1)
  30730. */
  30731. gradient: number;
  30732. /**
  30733. * Gets or sets first associated factor
  30734. */
  30735. factor1: number;
  30736. /**
  30737. * Gets or sets second associated factor
  30738. */
  30739. factor2?: number;
  30740. /**
  30741. * Will get a number picked randomly between factor1 and factor2.
  30742. * If factor2 is undefined then factor1 will be used
  30743. * @returns the picked number
  30744. */
  30745. getFactor(): number;
  30746. }
  30747. /**
  30748. * @ignore
  30749. * Application error to support additional information when loading a file
  30750. */
  30751. export class LoadFileError extends Error {
  30752. /** defines the optional XHR request */
  30753. request?: XMLHttpRequest | undefined;
  30754. private static _setPrototypeOf;
  30755. /**
  30756. * Creates a new LoadFileError
  30757. * @param message defines the message of the error
  30758. * @param request defines the optional XHR request
  30759. */
  30760. constructor(message: string,
  30761. /** defines the optional XHR request */
  30762. request?: XMLHttpRequest | undefined);
  30763. }
  30764. /**
  30765. * Class used to define a retry strategy when error happens while loading assets
  30766. */
  30767. export class RetryStrategy {
  30768. /**
  30769. * Function used to defines an exponential back off strategy
  30770. * @param maxRetries defines the maximum number of retries (3 by default)
  30771. * @param baseInterval defines the interval between retries
  30772. * @returns the strategy function to use
  30773. */
  30774. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  30775. }
  30776. /**
  30777. * File request interface
  30778. */
  30779. export interface IFileRequest {
  30780. /**
  30781. * Raised when the request is complete (success or error).
  30782. */
  30783. onCompleteObservable: Observable<IFileRequest>;
  30784. /**
  30785. * Aborts the request for a file.
  30786. */
  30787. abort: () => void;
  30788. }
  30789. /**
  30790. * Class containing a set of static utilities functions
  30791. */
  30792. export class Tools {
  30793. /**
  30794. * Gets or sets the base URL to use to load assets
  30795. */
  30796. static BaseUrl: string;
  30797. /**
  30798. * Enable/Disable Custom HTTP Request Headers globally.
  30799. * default = false
  30800. * @see CustomRequestHeaders
  30801. */
  30802. static UseCustomRequestHeaders: boolean;
  30803. /**
  30804. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  30805. * i.e. when loading files, where the server/service expects an Authorization header.
  30806. * @see InjectCustomRequestHeaders injects them to an XMLHttpRequest
  30807. */
  30808. static CustomRequestHeaders: {
  30809. [key: string]: string;
  30810. };
  30811. /**
  30812. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  30813. */
  30814. static DefaultRetryStrategy: (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  30815. /**
  30816. * Default behaviour for cors in the application.
  30817. * It can be a string if the expected behavior is identical in the entire app.
  30818. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  30819. */
  30820. static CorsBehavior: string | ((url: string | string[]) => string);
  30821. /**
  30822. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  30823. * @ignorenaming
  30824. */
  30825. static UseFallbackTexture: boolean;
  30826. /**
  30827. * Use this object to register external classes like custom textures or material
  30828. * to allow the laoders to instantiate them
  30829. */
  30830. static RegisteredExternalClasses: {
  30831. [key: string]: Object;
  30832. };
  30833. /**
  30834. * Texture content used if a texture cannot loaded
  30835. * @ignorenaming
  30836. */
  30837. static fallbackTexture: string;
  30838. /**
  30839. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  30840. * @param u defines the coordinate on X axis
  30841. * @param v defines the coordinate on Y axis
  30842. * @param width defines the width of the source data
  30843. * @param height defines the height of the source data
  30844. * @param pixels defines the source byte array
  30845. * @param color defines the output color
  30846. */
  30847. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  30848. /**
  30849. * Interpolates between a and b via alpha
  30850. * @param a The lower value (returned when alpha = 0)
  30851. * @param b The upper value (returned when alpha = 1)
  30852. * @param alpha The interpolation-factor
  30853. * @return The mixed value
  30854. */
  30855. static Mix(a: number, b: number, alpha: number): number;
  30856. /**
  30857. * Tries to instantiate a new object from a given class name
  30858. * @param className defines the class name to instantiate
  30859. * @returns the new object or null if the system was not able to do the instantiation
  30860. */
  30861. static Instantiate(className: string): any;
  30862. /**
  30863. * Provides a slice function that will work even on IE
  30864. * @param data defines the array to slice
  30865. * @param start defines the start of the data (optional)
  30866. * @param end defines the end of the data (optional)
  30867. * @returns the new sliced array
  30868. */
  30869. static Slice<T>(data: T, start?: number, end?: number): T;
  30870. /**
  30871. * Polyfill for setImmediate
  30872. * @param action defines the action to execute after the current execution block
  30873. */
  30874. static SetImmediate(action: () => void): void;
  30875. /**
  30876. * Function indicating if a number is an exponent of 2
  30877. * @param value defines the value to test
  30878. * @returns true if the value is an exponent of 2
  30879. */
  30880. static IsExponentOfTwo(value: number): boolean;
  30881. private static _tmpFloatArray;
  30882. /**
  30883. * Returns the nearest 32-bit single precision float representation of a Number
  30884. * @param value A Number. If the parameter is of a different type, it will get converted
  30885. * to a number or to NaN if it cannot be converted
  30886. * @returns number
  30887. */
  30888. static FloatRound(value: number): number;
  30889. /**
  30890. * Find the next highest power of two.
  30891. * @param x Number to start search from.
  30892. * @return Next highest power of two.
  30893. */
  30894. static CeilingPOT(x: number): number;
  30895. /**
  30896. * Find the next lowest power of two.
  30897. * @param x Number to start search from.
  30898. * @return Next lowest power of two.
  30899. */
  30900. static FloorPOT(x: number): number;
  30901. /**
  30902. * Find the nearest power of two.
  30903. * @param x Number to start search from.
  30904. * @return Next nearest power of two.
  30905. */
  30906. static NearestPOT(x: number): number;
  30907. /**
  30908. * Get the closest exponent of two
  30909. * @param value defines the value to approximate
  30910. * @param max defines the maximum value to return
  30911. * @param mode defines how to define the closest value
  30912. * @returns closest exponent of two of the given value
  30913. */
  30914. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  30915. /**
  30916. * Extracts the filename from a path
  30917. * @param path defines the path to use
  30918. * @returns the filename
  30919. */
  30920. static GetFilename(path: string): string;
  30921. /**
  30922. * Extracts the "folder" part of a path (everything before the filename).
  30923. * @param uri The URI to extract the info from
  30924. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  30925. * @returns The "folder" part of the path
  30926. */
  30927. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  30928. /**
  30929. * Extracts text content from a DOM element hierarchy
  30930. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  30931. */
  30932. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  30933. /**
  30934. * Convert an angle in radians to degrees
  30935. * @param angle defines the angle to convert
  30936. * @returns the angle in degrees
  30937. */
  30938. static ToDegrees(angle: number): number;
  30939. /**
  30940. * Convert an angle in degrees to radians
  30941. * @param angle defines the angle to convert
  30942. * @returns the angle in radians
  30943. */
  30944. static ToRadians(angle: number): number;
  30945. /**
  30946. * Encode a buffer to a base64 string
  30947. * @param buffer defines the buffer to encode
  30948. * @returns the encoded string
  30949. */
  30950. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  30951. /**
  30952. * Extracts minimum and maximum values from a list of indexed positions
  30953. * @param positions defines the positions to use
  30954. * @param indices defines the indices to the positions
  30955. * @param indexStart defines the start index
  30956. * @param indexCount defines the end index
  30957. * @param bias defines bias value to add to the result
  30958. * @return minimum and maximum values
  30959. */
  30960. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  30961. minimum: Vector3;
  30962. maximum: Vector3;
  30963. };
  30964. /**
  30965. * Extracts minimum and maximum values from a list of positions
  30966. * @param positions defines the positions to use
  30967. * @param start defines the start index in the positions array
  30968. * @param count defines the number of positions to handle
  30969. * @param bias defines bias value to add to the result
  30970. * @param stride defines the stride size to use (distance between two positions in the positions array)
  30971. * @return minimum and maximum values
  30972. */
  30973. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  30974. minimum: Vector3;
  30975. maximum: Vector3;
  30976. };
  30977. /**
  30978. * Returns an array if obj is not an array
  30979. * @param obj defines the object to evaluate as an array
  30980. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  30981. * @returns either obj directly if obj is an array or a new array containing obj
  30982. */
  30983. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  30984. /**
  30985. * Gets the pointer prefix to use
  30986. * @returns "pointer" if touch is enabled. Else returns "mouse"
  30987. */
  30988. static GetPointerPrefix(): string;
  30989. /**
  30990. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  30991. * @param func - the function to be called
  30992. * @param requester - the object that will request the next frame. Falls back to window.
  30993. * @returns frame number
  30994. */
  30995. static QueueNewFrame(func: () => void, requester?: any): number;
  30996. /**
  30997. * Ask the browser to promote the current element to fullscreen rendering mode
  30998. * @param element defines the DOM element to promote
  30999. */
  31000. static RequestFullscreen(element: HTMLElement): void;
  31001. /**
  31002. * Asks the browser to exit fullscreen mode
  31003. */
  31004. static ExitFullscreen(): void;
  31005. /**
  31006. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  31007. * @param url define the url we are trying
  31008. * @param element define the dom element where to configure the cors policy
  31009. */
  31010. static SetCorsBehavior(url: string | string[], element: {
  31011. crossOrigin: string | null;
  31012. }): void;
  31013. /**
  31014. * Removes unwanted characters from an url
  31015. * @param url defines the url to clean
  31016. * @returns the cleaned url
  31017. */
  31018. static CleanUrl(url: string): string;
  31019. /**
  31020. * Gets or sets a function used to pre-process url before using them to load assets
  31021. */
  31022. static PreprocessUrl: (url: string) => string;
  31023. /**
  31024. * Loads an image as an HTMLImageElement.
  31025. * @param input url string, ArrayBuffer, or Blob to load
  31026. * @param onLoad callback called when the image successfully loads
  31027. * @param onError callback called when the image fails to load
  31028. * @param offlineProvider offline provider for caching
  31029. * @returns the HTMLImageElement of the loaded image
  31030. */
  31031. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  31032. /**
  31033. * Loads a file
  31034. * @param url url string, ArrayBuffer, or Blob to load
  31035. * @param onSuccess callback called when the file successfully loads
  31036. * @param onProgress callback called while file is loading (if the server supports this mode)
  31037. * @param offlineProvider defines the offline provider for caching
  31038. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  31039. * @param onError callback called when the file fails to load
  31040. * @returns a file request object
  31041. */
  31042. 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;
  31043. /**
  31044. * Load a script (identified by an url). When the url returns, the
  31045. * content of this file is added into a new script element, attached to the DOM (body element)
  31046. * @param scriptUrl defines the url of the script to laod
  31047. * @param onSuccess defines the callback called when the script is loaded
  31048. * @param onError defines the callback to call if an error occurs
  31049. */
  31050. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void): void;
  31051. /**
  31052. * Loads a file from a blob
  31053. * @param fileToLoad defines the blob to use
  31054. * @param callback defines the callback to call when data is loaded
  31055. * @param progressCallback defines the callback to call during loading process
  31056. * @returns a file request object
  31057. */
  31058. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  31059. /**
  31060. * Loads a file
  31061. * @param fileToLoad defines the file to load
  31062. * @param callback defines the callback to call when data is loaded
  31063. * @param progressCallBack defines the callback to call during loading process
  31064. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  31065. * @returns a file request object
  31066. */
  31067. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  31068. /**
  31069. * Creates a data url from a given string content
  31070. * @param content defines the content to convert
  31071. * @returns the new data url link
  31072. */
  31073. static FileAsURL(content: string): string;
  31074. /**
  31075. * Format the given number to a specific decimal format
  31076. * @param value defines the number to format
  31077. * @param decimals defines the number of decimals to use
  31078. * @returns the formatted string
  31079. */
  31080. static Format(value: number, decimals?: number): string;
  31081. /**
  31082. * Checks if a given vector is inside a specific range
  31083. * @param v defines the vector to test
  31084. * @param min defines the minimum range
  31085. * @param max defines the maximum range
  31086. */
  31087. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  31088. /**
  31089. * Tries to copy an object by duplicating every property
  31090. * @param source defines the source object
  31091. * @param destination defines the target object
  31092. * @param doNotCopyList defines a list of properties to avoid
  31093. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  31094. */
  31095. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  31096. /**
  31097. * Gets a boolean indicating if the given object has no own property
  31098. * @param obj defines the object to test
  31099. * @returns true if object has no own property
  31100. */
  31101. static IsEmpty(obj: any): boolean;
  31102. /**
  31103. * Function used to register events at window level
  31104. * @param events defines the events to register
  31105. */
  31106. static RegisterTopRootEvents(events: {
  31107. name: string;
  31108. handler: Nullable<(e: FocusEvent) => any>;
  31109. }[]): void;
  31110. /**
  31111. * Function used to unregister events from window level
  31112. * @param events defines the events to unregister
  31113. */
  31114. static UnregisterTopRootEvents(events: {
  31115. name: string;
  31116. handler: Nullable<(e: FocusEvent) => any>;
  31117. }[]): void;
  31118. /**
  31119. * @ignore
  31120. */
  31121. static _ScreenshotCanvas: HTMLCanvasElement;
  31122. /**
  31123. * Dumps the current bound framebuffer
  31124. * @param width defines the rendering width
  31125. * @param height defines the rendering height
  31126. * @param engine defines the hosting engine
  31127. * @param successCallback defines the callback triggered once the data are available
  31128. * @param mimeType defines the mime type of the result
  31129. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  31130. */
  31131. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31132. /**
  31133. * Converts the canvas data to blob.
  31134. * This acts as a polyfill for browsers not supporting the to blob function.
  31135. * @param canvas Defines the canvas to extract the data from
  31136. * @param successCallback Defines the callback triggered once the data are available
  31137. * @param mimeType Defines the mime type of the result
  31138. */
  31139. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  31140. /**
  31141. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  31142. * @param successCallback defines the callback triggered once the data are available
  31143. * @param mimeType defines the mime type of the result
  31144. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  31145. */
  31146. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31147. /**
  31148. * Downloads a blob in the browser
  31149. * @param blob defines the blob to download
  31150. * @param fileName defines the name of the downloaded file
  31151. */
  31152. static Download(blob: Blob, fileName: string): void;
  31153. /**
  31154. * Captures a screenshot of the current rendering
  31155. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31156. * @param engine defines the rendering engine
  31157. * @param camera defines the source camera
  31158. * @param size This parameter can be set to a single number or to an object with the
  31159. * following (optional) properties: precision, width, height. If a single number is passed,
  31160. * it will be used for both width and height. If an object is passed, the screenshot size
  31161. * will be derived from the parameters. The precision property is a multiplier allowing
  31162. * rendering at a higher or lower resolution
  31163. * @param successCallback defines the callback receives a single parameter which contains the
  31164. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31165. * src parameter of an <img> to display it
  31166. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  31167. * Check your browser for supported MIME types
  31168. */
  31169. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  31170. /**
  31171. * Generates an image screenshot from the specified camera.
  31172. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31173. * @param engine The engine to use for rendering
  31174. * @param camera The camera to use for rendering
  31175. * @param size This parameter can be set to a single number or to an object with the
  31176. * following (optional) properties: precision, width, height. If a single number is passed,
  31177. * it will be used for both width and height. If an object is passed, the screenshot size
  31178. * will be derived from the parameters. The precision property is a multiplier allowing
  31179. * rendering at a higher or lower resolution
  31180. * @param successCallback The callback receives a single parameter which contains the
  31181. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31182. * src parameter of an <img> to display it
  31183. * @param mimeType The MIME type of the screenshot image (default: image/png).
  31184. * Check your browser for supported MIME types
  31185. * @param samples Texture samples (default: 1)
  31186. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  31187. * @param fileName A name for for the downloaded file.
  31188. */
  31189. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  31190. /**
  31191. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  31192. * Be aware Math.random() could cause collisions, but:
  31193. * "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"
  31194. * @returns a pseudo random id
  31195. */
  31196. static RandomId(): string;
  31197. /**
  31198. * Test if the given uri is a base64 string
  31199. * @param uri The uri to test
  31200. * @return True if the uri is a base64 string or false otherwise
  31201. */
  31202. static IsBase64(uri: string): boolean;
  31203. /**
  31204. * Decode the given base64 uri.
  31205. * @param uri The uri to decode
  31206. * @return The decoded base64 data.
  31207. */
  31208. static DecodeBase64(uri: string): ArrayBuffer;
  31209. /**
  31210. * No log
  31211. */
  31212. static readonly NoneLogLevel: number;
  31213. /**
  31214. * Only message logs
  31215. */
  31216. static readonly MessageLogLevel: number;
  31217. /**
  31218. * Only warning logs
  31219. */
  31220. static readonly WarningLogLevel: number;
  31221. /**
  31222. * Only error logs
  31223. */
  31224. static readonly ErrorLogLevel: number;
  31225. /**
  31226. * All logs
  31227. */
  31228. static readonly AllLogLevel: number;
  31229. /**
  31230. * Gets a value indicating the number of loading errors
  31231. * @ignorenaming
  31232. */
  31233. static readonly errorsCount: number;
  31234. /**
  31235. * Callback called when a new log is added
  31236. */
  31237. static OnNewCacheEntry: (entry: string) => void;
  31238. /**
  31239. * Log a message to the console
  31240. * @param message defines the message to log
  31241. */
  31242. static Log(message: string): void;
  31243. /**
  31244. * Write a warning message to the console
  31245. * @param message defines the message to log
  31246. */
  31247. static Warn(message: string): void;
  31248. /**
  31249. * Write an error message to the console
  31250. * @param message defines the message to log
  31251. */
  31252. static Error(message: string): void;
  31253. /**
  31254. * Gets current log cache (list of logs)
  31255. */
  31256. static readonly LogCache: string;
  31257. /**
  31258. * Clears the log cache
  31259. */
  31260. static ClearLogCache(): void;
  31261. /**
  31262. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  31263. */
  31264. static LogLevels: number;
  31265. /**
  31266. * Checks if the loaded document was accessed via `file:`-Protocol.
  31267. * @returns boolean
  31268. */
  31269. static IsFileURL(): boolean;
  31270. /**
  31271. * Checks if the window object exists
  31272. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  31273. */
  31274. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  31275. /**
  31276. * No performance log
  31277. */
  31278. static readonly PerformanceNoneLogLevel: number;
  31279. /**
  31280. * Use user marks to log performance
  31281. */
  31282. static readonly PerformanceUserMarkLogLevel: number;
  31283. /**
  31284. * Log performance to the console
  31285. */
  31286. static readonly PerformanceConsoleLogLevel: number;
  31287. private static _performance;
  31288. /**
  31289. * Sets the current performance log level
  31290. */
  31291. static PerformanceLogLevel: number;
  31292. private static _StartPerformanceCounterDisabled;
  31293. private static _EndPerformanceCounterDisabled;
  31294. private static _StartUserMark;
  31295. private static _EndUserMark;
  31296. private static _StartPerformanceConsole;
  31297. private static _EndPerformanceConsole;
  31298. /**
  31299. * Injects the @see CustomRequestHeaders into the given request
  31300. * @param request the request that should be used for injection
  31301. */
  31302. static InjectCustomRequestHeaders(request: XMLHttpRequest): void;
  31303. /**
  31304. * Starts a performance counter
  31305. */
  31306. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  31307. /**
  31308. * Ends a specific performance coutner
  31309. */
  31310. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  31311. /**
  31312. * Gets either window.performance.now() if supported or Date.now() else
  31313. */
  31314. static readonly Now: number;
  31315. /**
  31316. * This method will return the name of the class used to create the instance of the given object.
  31317. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  31318. * @param object the object to get the class name from
  31319. * @param isType defines if the object is actually a type
  31320. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  31321. */
  31322. static GetClassName(object: any, isType?: boolean): string;
  31323. /**
  31324. * Gets the first element of an array satisfying a given predicate
  31325. * @param array defines the array to browse
  31326. * @param predicate defines the predicate to use
  31327. * @returns null if not found or the element
  31328. */
  31329. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  31330. /**
  31331. * This method will return the name of the full name of the class, including its owning module (if any).
  31332. * 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).
  31333. * @param object the object to get the class name from
  31334. * @param isType defines if the object is actually a type
  31335. * @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.
  31336. * @ignorenaming
  31337. */
  31338. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  31339. /**
  31340. * Returns a promise that resolves after the given amount of time.
  31341. * @param delay Number of milliseconds to delay
  31342. * @returns Promise that resolves after the given amount of time
  31343. */
  31344. static DelayAsync(delay: number): Promise<void>;
  31345. /**
  31346. * Gets the current gradient from an array of IValueGradient
  31347. * @param ratio defines the current ratio to get
  31348. * @param gradients defines the array of IValueGradient
  31349. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  31350. */
  31351. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  31352. }
  31353. /**
  31354. * This class is used to track a performance counter which is number based.
  31355. * The user has access to many properties which give statistics of different nature.
  31356. *
  31357. * The implementer can track two kinds of Performance Counter: time and count.
  31358. * 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.
  31359. * 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.
  31360. */
  31361. export class PerfCounter {
  31362. /**
  31363. * Gets or sets a global boolean to turn on and off all the counters
  31364. */
  31365. static Enabled: boolean;
  31366. /**
  31367. * Returns the smallest value ever
  31368. */
  31369. readonly min: number;
  31370. /**
  31371. * Returns the biggest value ever
  31372. */
  31373. readonly max: number;
  31374. /**
  31375. * Returns the average value since the performance counter is running
  31376. */
  31377. readonly average: number;
  31378. /**
  31379. * Returns the average value of the last second the counter was monitored
  31380. */
  31381. readonly lastSecAverage: number;
  31382. /**
  31383. * Returns the current value
  31384. */
  31385. readonly current: number;
  31386. /**
  31387. * Gets the accumulated total
  31388. */
  31389. readonly total: number;
  31390. /**
  31391. * Gets the total value count
  31392. */
  31393. readonly count: number;
  31394. /**
  31395. * Creates a new counter
  31396. */
  31397. constructor();
  31398. /**
  31399. * Call this method to start monitoring a new frame.
  31400. * 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.
  31401. */
  31402. fetchNewFrame(): void;
  31403. /**
  31404. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  31405. * @param newCount the count value to add to the monitored count
  31406. * @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.
  31407. */
  31408. addCount(newCount: number, fetchResult: boolean): void;
  31409. /**
  31410. * Start monitoring this performance counter
  31411. */
  31412. beginMonitoring(): void;
  31413. /**
  31414. * Compute the time lapsed since the previous beginMonitoring() call.
  31415. * @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
  31416. */
  31417. endMonitoring(newFrame?: boolean): void;
  31418. private _fetchResult;
  31419. private _startMonitoringTime;
  31420. private _min;
  31421. private _max;
  31422. private _average;
  31423. private _current;
  31424. private _totalValueCount;
  31425. private _totalAccumulated;
  31426. private _lastSecAverage;
  31427. private _lastSecAccumulated;
  31428. private _lastSecTime;
  31429. private _lastSecValueCount;
  31430. }
  31431. /**
  31432. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  31433. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  31434. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  31435. * @param name The name of the class, case should be preserved
  31436. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  31437. */
  31438. export function className(name: string, module?: string): (target: Object) => void;
  31439. /**
  31440. * An implementation of a loop for asynchronous functions.
  31441. */
  31442. export class AsyncLoop {
  31443. /**
  31444. * Defines the number of iterations for the loop
  31445. */
  31446. iterations: number;
  31447. /**
  31448. * Defines the current index of the loop.
  31449. */
  31450. index: number;
  31451. private _done;
  31452. private _fn;
  31453. private _successCallback;
  31454. /**
  31455. * Constructor.
  31456. * @param iterations the number of iterations.
  31457. * @param func the function to run each iteration
  31458. * @param successCallback the callback that will be called upon succesful execution
  31459. * @param offset starting offset.
  31460. */
  31461. constructor(
  31462. /**
  31463. * Defines the number of iterations for the loop
  31464. */
  31465. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  31466. /**
  31467. * Execute the next iteration. Must be called after the last iteration was finished.
  31468. */
  31469. executeNext(): void;
  31470. /**
  31471. * Break the loop and run the success callback.
  31472. */
  31473. breakLoop(): void;
  31474. /**
  31475. * Create and run an async loop.
  31476. * @param iterations the number of iterations.
  31477. * @param fn the function to run each iteration
  31478. * @param successCallback the callback that will be called upon succesful execution
  31479. * @param offset starting offset.
  31480. * @returns the created async loop object
  31481. */
  31482. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  31483. /**
  31484. * A for-loop that will run a given number of iterations synchronous and the rest async.
  31485. * @param iterations total number of iterations
  31486. * @param syncedIterations number of synchronous iterations in each async iteration.
  31487. * @param fn the function to call each iteration.
  31488. * @param callback a success call back that will be called when iterating stops.
  31489. * @param breakFunction a break condition (optional)
  31490. * @param timeout timeout settings for the setTimeout function. default - 0.
  31491. * @returns the created async loop object
  31492. */
  31493. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  31494. }
  31495. }
  31496. declare module "babylonjs/Collisions/collisionCoordinator" {
  31497. import { Nullable } from "babylonjs/types";
  31498. import { Scene } from "babylonjs/scene";
  31499. import { Vector3 } from "babylonjs/Maths/math";
  31500. import { Collider } from "babylonjs/Collisions/collider";
  31501. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  31502. /** @hidden */
  31503. export interface ICollisionCoordinator {
  31504. createCollider(): Collider;
  31505. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  31506. init(scene: Scene): void;
  31507. }
  31508. /** @hidden */
  31509. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  31510. private _scene;
  31511. private _scaledPosition;
  31512. private _scaledVelocity;
  31513. private _finalPosition;
  31514. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  31515. createCollider(): Collider;
  31516. init(scene: Scene): void;
  31517. private _collideWithWorld;
  31518. }
  31519. }
  31520. declare module "babylonjs/Animations/animationGroup" {
  31521. import { Animatable } from "babylonjs/Animations/animatable";
  31522. import { Animation } from "babylonjs/Animations/animation";
  31523. import { Scene, IDisposable } from "babylonjs/scene";
  31524. import { Observable } from "babylonjs/Misc/observable";
  31525. import { Nullable } from "babylonjs/types";
  31526. /**
  31527. * This class defines the direct association between an animation and a target
  31528. */
  31529. export class TargetedAnimation {
  31530. /**
  31531. * Animation to perform
  31532. */
  31533. animation: Animation;
  31534. /**
  31535. * Target to animate
  31536. */
  31537. target: any;
  31538. }
  31539. /**
  31540. * Use this class to create coordinated animations on multiple targets
  31541. */
  31542. export class AnimationGroup implements IDisposable {
  31543. /** The name of the animation group */
  31544. name: string;
  31545. private _scene;
  31546. private _targetedAnimations;
  31547. private _animatables;
  31548. private _from;
  31549. private _to;
  31550. private _isStarted;
  31551. private _isPaused;
  31552. private _speedRatio;
  31553. /**
  31554. * Gets or sets the unique id of the node
  31555. */
  31556. uniqueId: number;
  31557. /**
  31558. * This observable will notify when one animation have ended
  31559. */
  31560. onAnimationEndObservable: Observable<TargetedAnimation>;
  31561. /**
  31562. * Observer raised when one animation loops
  31563. */
  31564. onAnimationLoopObservable: Observable<TargetedAnimation>;
  31565. /**
  31566. * This observable will notify when all animations have ended.
  31567. */
  31568. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  31569. /**
  31570. * This observable will notify when all animations have paused.
  31571. */
  31572. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  31573. /**
  31574. * This observable will notify when all animations are playing.
  31575. */
  31576. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  31577. /**
  31578. * Gets the first frame
  31579. */
  31580. readonly from: number;
  31581. /**
  31582. * Gets the last frame
  31583. */
  31584. readonly to: number;
  31585. /**
  31586. * Define if the animations are started
  31587. */
  31588. readonly isStarted: boolean;
  31589. /**
  31590. * Gets a value indicating that the current group is playing
  31591. */
  31592. readonly isPlaying: boolean;
  31593. /**
  31594. * Gets or sets the speed ratio to use for all animations
  31595. */
  31596. /**
  31597. * Gets or sets the speed ratio to use for all animations
  31598. */
  31599. speedRatio: number;
  31600. /**
  31601. * Gets the targeted animations for this animation group
  31602. */
  31603. readonly targetedAnimations: Array<TargetedAnimation>;
  31604. /**
  31605. * returning the list of animatables controlled by this animation group.
  31606. */
  31607. readonly animatables: Array<Animatable>;
  31608. /**
  31609. * Instantiates a new Animation Group.
  31610. * This helps managing several animations at once.
  31611. * @see http://doc.babylonjs.com/how_to/group
  31612. * @param name Defines the name of the group
  31613. * @param scene Defines the scene the group belongs to
  31614. */
  31615. constructor(
  31616. /** The name of the animation group */
  31617. name: string, scene?: Nullable<Scene>);
  31618. /**
  31619. * Add an animation (with its target) in the group
  31620. * @param animation defines the animation we want to add
  31621. * @param target defines the target of the animation
  31622. * @returns the TargetedAnimation object
  31623. */
  31624. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  31625. /**
  31626. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  31627. * It can add constant keys at begin or end
  31628. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  31629. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  31630. * @returns the animation group
  31631. */
  31632. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  31633. /**
  31634. * Start all animations on given targets
  31635. * @param loop defines if animations must loop
  31636. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  31637. * @param from defines the from key (optional)
  31638. * @param to defines the to key (optional)
  31639. * @returns the current animation group
  31640. */
  31641. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  31642. /**
  31643. * Pause all animations
  31644. * @returns the animation group
  31645. */
  31646. pause(): AnimationGroup;
  31647. /**
  31648. * Play all animations to initial state
  31649. * This function will start() the animations if they were not started or will restart() them if they were paused
  31650. * @param loop defines if animations must loop
  31651. * @returns the animation group
  31652. */
  31653. play(loop?: boolean): AnimationGroup;
  31654. /**
  31655. * Reset all animations to initial state
  31656. * @returns the animation group
  31657. */
  31658. reset(): AnimationGroup;
  31659. /**
  31660. * Restart animations from key 0
  31661. * @returns the animation group
  31662. */
  31663. restart(): AnimationGroup;
  31664. /**
  31665. * Stop all animations
  31666. * @returns the animation group
  31667. */
  31668. stop(): AnimationGroup;
  31669. /**
  31670. * Set animation weight for all animatables
  31671. * @param weight defines the weight to use
  31672. * @return the animationGroup
  31673. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  31674. */
  31675. setWeightForAllAnimatables(weight: number): AnimationGroup;
  31676. /**
  31677. * Synchronize and normalize all animatables with a source animatable
  31678. * @param root defines the root animatable to synchronize with
  31679. * @return the animationGroup
  31680. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  31681. */
  31682. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  31683. /**
  31684. * Goes to a specific frame in this animation group
  31685. * @param frame the frame number to go to
  31686. * @return the animationGroup
  31687. */
  31688. goToFrame(frame: number): AnimationGroup;
  31689. /**
  31690. * Dispose all associated resources
  31691. */
  31692. dispose(): void;
  31693. private _checkAnimationGroupEnded;
  31694. /**
  31695. * Clone the current animation group and returns a copy
  31696. * @param newName defines the name of the new group
  31697. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  31698. * @returns the new aniamtion group
  31699. */
  31700. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  31701. /**
  31702. * Returns a new AnimationGroup object parsed from the source provided.
  31703. * @param parsedAnimationGroup defines the source
  31704. * @param scene defines the scene that will receive the animationGroup
  31705. * @returns a new AnimationGroup
  31706. */
  31707. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  31708. /**
  31709. * Returns the string "AnimationGroup"
  31710. * @returns "AnimationGroup"
  31711. */
  31712. getClassName(): string;
  31713. /**
  31714. * Creates a detailled string about the object
  31715. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  31716. * @returns a string representing the object
  31717. */
  31718. toString(fullDetails?: boolean): string;
  31719. }
  31720. }
  31721. declare module "babylonjs/scene" {
  31722. import { Nullable } from "babylonjs/types";
  31723. import { IAnimatable, IFileRequest, PerfCounter } from "babylonjs/Misc/tools";
  31724. import { Observable } from "babylonjs/Misc/observable";
  31725. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  31726. import { Color4, Color3, Plane, Vector2, Vector3, Matrix } from "babylonjs/Maths/math";
  31727. import { Geometry } from "babylonjs/Meshes/geometry";
  31728. import { TransformNode } from "babylonjs/Meshes/transformNode";
  31729. import { SubMesh } from "babylonjs/Meshes/subMesh";
  31730. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  31731. import { Mesh } from "babylonjs/Meshes/mesh";
  31732. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  31733. import { Bone } from "babylonjs/Bones/bone";
  31734. import { Skeleton } from "babylonjs/Bones/skeleton";
  31735. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  31736. import { Camera } from "babylonjs/Cameras/camera";
  31737. import { AbstractScene } from "babylonjs/abstractScene";
  31738. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  31739. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  31740. import { Material } from "babylonjs/Materials/material";
  31741. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  31742. import { Effect } from "babylonjs/Materials/effect";
  31743. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  31744. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  31745. import { Light } from "babylonjs/Lights/light";
  31746. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  31747. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  31748. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  31749. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  31750. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  31751. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  31752. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  31753. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  31754. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction } from "babylonjs/sceneComponent";
  31755. import { Engine } from "babylonjs/Engines/engine";
  31756. import { Node } from "babylonjs/node";
  31757. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  31758. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  31759. import { Ray } from "babylonjs/Culling/ray";
  31760. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  31761. import { Animation } from "babylonjs/Animations/animation";
  31762. import { Animatable } from "babylonjs/Animations/animatable";
  31763. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  31764. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  31765. import { Collider } from "babylonjs/Collisions/collider";
  31766. /**
  31767. * Define an interface for all classes that will hold resources
  31768. */
  31769. export interface IDisposable {
  31770. /**
  31771. * Releases all held resources
  31772. */
  31773. dispose(): void;
  31774. }
  31775. /** Interface defining initialization parameters for Scene class */
  31776. export interface SceneOptions {
  31777. /**
  31778. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  31779. * It will improve performance when the number of geometries becomes important.
  31780. */
  31781. useGeometryUniqueIdsMap?: boolean;
  31782. /**
  31783. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  31784. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  31785. */
  31786. useMaterialMeshMap?: boolean;
  31787. /**
  31788. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  31789. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  31790. */
  31791. useClonedMeshhMap?: boolean;
  31792. }
  31793. /**
  31794. * Represents a scene to be rendered by the engine.
  31795. * @see http://doc.babylonjs.com/features/scene
  31796. */
  31797. export class Scene extends AbstractScene implements IAnimatable {
  31798. private static _uniqueIdCounter;
  31799. /** The fog is deactivated */
  31800. static readonly FOGMODE_NONE: number;
  31801. /** The fog density is following an exponential function */
  31802. static readonly FOGMODE_EXP: number;
  31803. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  31804. static readonly FOGMODE_EXP2: number;
  31805. /** The fog density is following a linear function. */
  31806. static readonly FOGMODE_LINEAR: number;
  31807. /**
  31808. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  31809. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31810. */
  31811. static MinDeltaTime: number;
  31812. /**
  31813. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  31814. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31815. */
  31816. static MaxDeltaTime: number;
  31817. /**
  31818. * Factory used to create the default material.
  31819. * @param name The name of the material to create
  31820. * @param scene The scene to create the material for
  31821. * @returns The default material
  31822. */
  31823. static DefaultMaterialFactory(scene: Scene): Material;
  31824. /**
  31825. * Factory used to create the a collision coordinator.
  31826. * @returns The collision coordinator
  31827. */
  31828. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  31829. /** @hidden */
  31830. readonly _isScene: boolean;
  31831. /**
  31832. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  31833. */
  31834. autoClear: boolean;
  31835. /**
  31836. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  31837. */
  31838. autoClearDepthAndStencil: boolean;
  31839. /**
  31840. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  31841. */
  31842. clearColor: Color4;
  31843. /**
  31844. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  31845. */
  31846. ambientColor: Color3;
  31847. /** @hidden */
  31848. _environmentBRDFTexture: BaseTexture;
  31849. /** @hidden */
  31850. protected _environmentTexture: Nullable<BaseTexture>;
  31851. /**
  31852. * Texture used in all pbr material as the reflection texture.
  31853. * As in the majority of the scene they are the same (exception for multi room and so on),
  31854. * this is easier to reference from here than from all the materials.
  31855. */
  31856. /**
  31857. * Texture used in all pbr material as the reflection texture.
  31858. * As in the majority of the scene they are the same (exception for multi room and so on),
  31859. * this is easier to set here than in all the materials.
  31860. */
  31861. environmentTexture: Nullable<BaseTexture>;
  31862. /** @hidden */
  31863. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  31864. /**
  31865. * Default image processing configuration used either in the rendering
  31866. * Forward main pass or through the imageProcessingPostProcess if present.
  31867. * As in the majority of the scene they are the same (exception for multi camera),
  31868. * this is easier to reference from here than from all the materials and post process.
  31869. *
  31870. * No setter as we it is a shared configuration, you can set the values instead.
  31871. */
  31872. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  31873. private _forceWireframe;
  31874. /**
  31875. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  31876. */
  31877. forceWireframe: boolean;
  31878. private _forcePointsCloud;
  31879. /**
  31880. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  31881. */
  31882. forcePointsCloud: boolean;
  31883. /**
  31884. * Gets or sets the active clipplane 1
  31885. */
  31886. clipPlane: Nullable<Plane>;
  31887. /**
  31888. * Gets or sets the active clipplane 2
  31889. */
  31890. clipPlane2: Nullable<Plane>;
  31891. /**
  31892. * Gets or sets the active clipplane 3
  31893. */
  31894. clipPlane3: Nullable<Plane>;
  31895. /**
  31896. * Gets or sets the active clipplane 4
  31897. */
  31898. clipPlane4: Nullable<Plane>;
  31899. /**
  31900. * Gets or sets a boolean indicating if animations are enabled
  31901. */
  31902. animationsEnabled: boolean;
  31903. private _animationPropertiesOverride;
  31904. /**
  31905. * Gets or sets the animation properties override
  31906. */
  31907. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  31908. /**
  31909. * Gets or sets a boolean indicating if a constant deltatime has to be used
  31910. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  31911. */
  31912. useConstantAnimationDeltaTime: boolean;
  31913. /**
  31914. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  31915. * Please note that it requires to run a ray cast through the scene on every frame
  31916. */
  31917. constantlyUpdateMeshUnderPointer: boolean;
  31918. /**
  31919. * Defines the HTML cursor to use when hovering over interactive elements
  31920. */
  31921. hoverCursor: string;
  31922. /**
  31923. * Defines the HTML default cursor to use (empty by default)
  31924. */
  31925. defaultCursor: string;
  31926. /**
  31927. * This is used to call preventDefault() on pointer down
  31928. * in order to block unwanted artifacts like system double clicks
  31929. */
  31930. preventDefaultOnPointerDown: boolean;
  31931. /**
  31932. * This is used to call preventDefault() on pointer up
  31933. * in order to block unwanted artifacts like system double clicks
  31934. */
  31935. preventDefaultOnPointerUp: boolean;
  31936. /**
  31937. * Gets or sets user defined metadata
  31938. */
  31939. metadata: any;
  31940. /**
  31941. * For internal use only. Please do not use.
  31942. */
  31943. reservedDataStore: any;
  31944. /**
  31945. * Gets the name of the plugin used to load this scene (null by default)
  31946. */
  31947. loadingPluginName: string;
  31948. /**
  31949. * Use this array to add regular expressions used to disable offline support for specific urls
  31950. */
  31951. disableOfflineSupportExceptionRules: RegExp[];
  31952. /**
  31953. * An event triggered when the scene is disposed.
  31954. */
  31955. onDisposeObservable: Observable<Scene>;
  31956. private _onDisposeObserver;
  31957. /** Sets a function to be executed when this scene is disposed. */
  31958. onDispose: () => void;
  31959. /**
  31960. * An event triggered before rendering the scene (right after animations and physics)
  31961. */
  31962. onBeforeRenderObservable: Observable<Scene>;
  31963. private _onBeforeRenderObserver;
  31964. /** Sets a function to be executed before rendering this scene */
  31965. beforeRender: Nullable<() => void>;
  31966. /**
  31967. * An event triggered after rendering the scene
  31968. */
  31969. onAfterRenderObservable: Observable<Scene>;
  31970. private _onAfterRenderObserver;
  31971. /** Sets a function to be executed after rendering this scene */
  31972. afterRender: Nullable<() => void>;
  31973. /**
  31974. * An event triggered before animating the scene
  31975. */
  31976. onBeforeAnimationsObservable: Observable<Scene>;
  31977. /**
  31978. * An event triggered after animations processing
  31979. */
  31980. onAfterAnimationsObservable: Observable<Scene>;
  31981. /**
  31982. * An event triggered before draw calls are ready to be sent
  31983. */
  31984. onBeforeDrawPhaseObservable: Observable<Scene>;
  31985. /**
  31986. * An event triggered after draw calls have been sent
  31987. */
  31988. onAfterDrawPhaseObservable: Observable<Scene>;
  31989. /**
  31990. * An event triggered when the scene is ready
  31991. */
  31992. onReadyObservable: Observable<Scene>;
  31993. /**
  31994. * An event triggered before rendering a camera
  31995. */
  31996. onBeforeCameraRenderObservable: Observable<Camera>;
  31997. private _onBeforeCameraRenderObserver;
  31998. /** Sets a function to be executed before rendering a camera*/
  31999. beforeCameraRender: () => void;
  32000. /**
  32001. * An event triggered after rendering a camera
  32002. */
  32003. onAfterCameraRenderObservable: Observable<Camera>;
  32004. private _onAfterCameraRenderObserver;
  32005. /** Sets a function to be executed after rendering a camera*/
  32006. afterCameraRender: () => void;
  32007. /**
  32008. * An event triggered when active meshes evaluation is about to start
  32009. */
  32010. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  32011. /**
  32012. * An event triggered when active meshes evaluation is done
  32013. */
  32014. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  32015. /**
  32016. * An event triggered when particles rendering is about to start
  32017. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  32018. */
  32019. onBeforeParticlesRenderingObservable: Observable<Scene>;
  32020. /**
  32021. * An event triggered when particles rendering is done
  32022. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  32023. */
  32024. onAfterParticlesRenderingObservable: Observable<Scene>;
  32025. /**
  32026. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  32027. */
  32028. onDataLoadedObservable: Observable<Scene>;
  32029. /**
  32030. * An event triggered when a camera is created
  32031. */
  32032. onNewCameraAddedObservable: Observable<Camera>;
  32033. /**
  32034. * An event triggered when a camera is removed
  32035. */
  32036. onCameraRemovedObservable: Observable<Camera>;
  32037. /**
  32038. * An event triggered when a light is created
  32039. */
  32040. onNewLightAddedObservable: Observable<Light>;
  32041. /**
  32042. * An event triggered when a light is removed
  32043. */
  32044. onLightRemovedObservable: Observable<Light>;
  32045. /**
  32046. * An event triggered when a geometry is created
  32047. */
  32048. onNewGeometryAddedObservable: Observable<Geometry>;
  32049. /**
  32050. * An event triggered when a geometry is removed
  32051. */
  32052. onGeometryRemovedObservable: Observable<Geometry>;
  32053. /**
  32054. * An event triggered when a transform node is created
  32055. */
  32056. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  32057. /**
  32058. * An event triggered when a transform node is removed
  32059. */
  32060. onTransformNodeRemovedObservable: Observable<TransformNode>;
  32061. /**
  32062. * An event triggered when a mesh is created
  32063. */
  32064. onNewMeshAddedObservable: Observable<AbstractMesh>;
  32065. /**
  32066. * An event triggered when a mesh is removed
  32067. */
  32068. onMeshRemovedObservable: Observable<AbstractMesh>;
  32069. /**
  32070. * An event triggered when a material is created
  32071. */
  32072. onNewMaterialAddedObservable: Observable<Material>;
  32073. /**
  32074. * An event triggered when a material is removed
  32075. */
  32076. onMaterialRemovedObservable: Observable<Material>;
  32077. /**
  32078. * An event triggered when a texture is created
  32079. */
  32080. onNewTextureAddedObservable: Observable<BaseTexture>;
  32081. /**
  32082. * An event triggered when a texture is removed
  32083. */
  32084. onTextureRemovedObservable: Observable<BaseTexture>;
  32085. /**
  32086. * An event triggered when render targets are about to be rendered
  32087. * Can happen multiple times per frame.
  32088. */
  32089. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  32090. /**
  32091. * An event triggered when render targets were rendered.
  32092. * Can happen multiple times per frame.
  32093. */
  32094. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  32095. /**
  32096. * An event triggered before calculating deterministic simulation step
  32097. */
  32098. onBeforeStepObservable: Observable<Scene>;
  32099. /**
  32100. * An event triggered after calculating deterministic simulation step
  32101. */
  32102. onAfterStepObservable: Observable<Scene>;
  32103. /**
  32104. * An event triggered when the activeCamera property is updated
  32105. */
  32106. onActiveCameraChanged: Observable<Scene>;
  32107. /**
  32108. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  32109. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  32110. * If you wish to register an Observer only for a given set of renderingGroup, use the mask with a combination of the renderingGroup index elevated to the power of two (1 for renderingGroup 0, 2 for renderingrOup1, 4 for 2 and 8 for 3)
  32111. */
  32112. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  32113. /**
  32114. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  32115. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  32116. * 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)
  32117. */
  32118. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  32119. /**
  32120. * This Observable will when a mesh has been imported into the scene.
  32121. */
  32122. onMeshImportedObservable: Observable<AbstractMesh>;
  32123. /**
  32124. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  32125. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  32126. */
  32127. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  32128. /** @hidden */
  32129. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  32130. /**
  32131. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  32132. */
  32133. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  32134. /**
  32135. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  32136. */
  32137. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  32138. /**
  32139. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  32140. */
  32141. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  32142. private _onPointerMove;
  32143. private _onPointerDown;
  32144. private _onPointerUp;
  32145. /** Callback called when a pointer move is detected */
  32146. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  32147. /** Callback called when a pointer down is detected */
  32148. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  32149. /** Callback called when a pointer up is detected */
  32150. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  32151. /** Callback called when a pointer pick is detected */
  32152. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  32153. /**
  32154. * 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).
  32155. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  32156. */
  32157. onPrePointerObservable: Observable<PointerInfoPre>;
  32158. /**
  32159. * Observable event triggered each time an input event is received from the rendering canvas
  32160. */
  32161. onPointerObservable: Observable<PointerInfo>;
  32162. /**
  32163. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  32164. */
  32165. readonly unTranslatedPointer: Vector2;
  32166. /** The distance in pixel that you have to move to prevent some events */
  32167. static DragMovementThreshold: number;
  32168. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  32169. static LongPressDelay: number;
  32170. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  32171. static DoubleClickDelay: number;
  32172. /** If you need to check double click without raising a single click at first click, enable this flag */
  32173. static ExclusiveDoubleClickMode: boolean;
  32174. private _initClickEvent;
  32175. private _initActionManager;
  32176. private _delayedSimpleClick;
  32177. private _delayedSimpleClickTimeout;
  32178. private _previousDelayedSimpleClickTimeout;
  32179. private _meshPickProceed;
  32180. private _previousButtonPressed;
  32181. private _currentPickResult;
  32182. private _previousPickResult;
  32183. private _totalPointersPressed;
  32184. private _doubleClickOccured;
  32185. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  32186. cameraToUseForPointers: Nullable<Camera>;
  32187. private _pointerX;
  32188. private _pointerY;
  32189. private _unTranslatedPointerX;
  32190. private _unTranslatedPointerY;
  32191. private _startingPointerPosition;
  32192. private _previousStartingPointerPosition;
  32193. private _startingPointerTime;
  32194. private _previousStartingPointerTime;
  32195. private _pointerCaptures;
  32196. private _timeAccumulator;
  32197. private _currentStepId;
  32198. private _currentInternalStep;
  32199. /** @hidden */
  32200. _mirroredCameraPosition: Nullable<Vector3>;
  32201. /**
  32202. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  32203. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  32204. */
  32205. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  32206. /**
  32207. * Observable event triggered each time an keyboard event is received from the hosting window
  32208. */
  32209. onKeyboardObservable: Observable<KeyboardInfo>;
  32210. private _onKeyDown;
  32211. private _onKeyUp;
  32212. private _onCanvasFocusObserver;
  32213. private _onCanvasBlurObserver;
  32214. private _useRightHandedSystem;
  32215. /**
  32216. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  32217. */
  32218. useRightHandedSystem: boolean;
  32219. /**
  32220. * Sets the step Id used by deterministic lock step
  32221. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32222. * @param newStepId defines the step Id
  32223. */
  32224. setStepId(newStepId: number): void;
  32225. /**
  32226. * Gets the step Id used by deterministic lock step
  32227. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32228. * @returns the step Id
  32229. */
  32230. getStepId(): number;
  32231. /**
  32232. * Gets the internal step used by deterministic lock step
  32233. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32234. * @returns the internal step
  32235. */
  32236. getInternalStep(): number;
  32237. private _fogEnabled;
  32238. /**
  32239. * Gets or sets a boolean indicating if fog is enabled on this scene
  32240. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32241. * (Default is true)
  32242. */
  32243. fogEnabled: boolean;
  32244. private _fogMode;
  32245. /**
  32246. * Gets or sets the fog mode to use
  32247. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32248. * | mode | value |
  32249. * | --- | --- |
  32250. * | FOGMODE_NONE | 0 |
  32251. * | FOGMODE_EXP | 1 |
  32252. * | FOGMODE_EXP2 | 2 |
  32253. * | FOGMODE_LINEAR | 3 |
  32254. */
  32255. fogMode: number;
  32256. /**
  32257. * Gets or sets the fog color to use
  32258. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32259. * (Default is Color3(0.2, 0.2, 0.3))
  32260. */
  32261. fogColor: Color3;
  32262. /**
  32263. * Gets or sets the fog density to use
  32264. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32265. * (Default is 0.1)
  32266. */
  32267. fogDensity: number;
  32268. /**
  32269. * Gets or sets the fog start distance to use
  32270. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32271. * (Default is 0)
  32272. */
  32273. fogStart: number;
  32274. /**
  32275. * Gets or sets the fog end distance to use
  32276. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32277. * (Default is 1000)
  32278. */
  32279. fogEnd: number;
  32280. private _shadowsEnabled;
  32281. /**
  32282. * Gets or sets a boolean indicating if shadows are enabled on this scene
  32283. */
  32284. shadowsEnabled: boolean;
  32285. private _lightsEnabled;
  32286. /**
  32287. * Gets or sets a boolean indicating if lights are enabled on this scene
  32288. */
  32289. lightsEnabled: boolean;
  32290. /** All of the active cameras added to this scene. */
  32291. activeCameras: Camera[];
  32292. private _activeCamera;
  32293. /** Gets or sets the current active camera */
  32294. activeCamera: Nullable<Camera>;
  32295. private _defaultMaterial;
  32296. /** The default material used on meshes when no material is affected */
  32297. /** The default material used on meshes when no material is affected */
  32298. defaultMaterial: Material;
  32299. private _texturesEnabled;
  32300. /**
  32301. * Gets or sets a boolean indicating if textures are enabled on this scene
  32302. */
  32303. texturesEnabled: boolean;
  32304. /**
  32305. * Gets or sets a boolean indicating if particles are enabled on this scene
  32306. */
  32307. particlesEnabled: boolean;
  32308. /**
  32309. * Gets or sets a boolean indicating if sprites are enabled on this scene
  32310. */
  32311. spritesEnabled: boolean;
  32312. private _skeletonsEnabled;
  32313. /**
  32314. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  32315. */
  32316. skeletonsEnabled: boolean;
  32317. /**
  32318. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  32319. */
  32320. lensFlaresEnabled: boolean;
  32321. /**
  32322. * Gets or sets a boolean indicating if collisions are enabled on this scene
  32323. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32324. */
  32325. collisionsEnabled: boolean;
  32326. private _collisionCoordinator;
  32327. /** @hidden */
  32328. readonly collisionCoordinator: ICollisionCoordinator;
  32329. /**
  32330. * Defines the gravity applied to this scene (used only for collisions)
  32331. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32332. */
  32333. gravity: Vector3;
  32334. /**
  32335. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  32336. */
  32337. postProcessesEnabled: boolean;
  32338. /**
  32339. * The list of postprocesses added to the scene
  32340. */
  32341. postProcesses: PostProcess[];
  32342. /**
  32343. * Gets the current postprocess manager
  32344. */
  32345. postProcessManager: PostProcessManager;
  32346. /**
  32347. * Gets or sets a boolean indicating if render targets are enabled on this scene
  32348. */
  32349. renderTargetsEnabled: boolean;
  32350. /**
  32351. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  32352. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  32353. */
  32354. dumpNextRenderTargets: boolean;
  32355. /**
  32356. * The list of user defined render targets added to the scene
  32357. */
  32358. customRenderTargets: RenderTargetTexture[];
  32359. /**
  32360. * Defines if texture loading must be delayed
  32361. * If true, textures will only be loaded when they need to be rendered
  32362. */
  32363. useDelayedTextureLoading: boolean;
  32364. /**
  32365. * Gets the list of meshes imported to the scene through SceneLoader
  32366. */
  32367. importedMeshesFiles: String[];
  32368. /**
  32369. * Gets or sets a boolean indicating if probes are enabled on this scene
  32370. */
  32371. probesEnabled: boolean;
  32372. /**
  32373. * Gets or sets the current offline provider to use to store scene data
  32374. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  32375. */
  32376. offlineProvider: IOfflineProvider;
  32377. /**
  32378. * Gets or sets the action manager associated with the scene
  32379. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  32380. */
  32381. actionManager: AbstractActionManager;
  32382. private _meshesForIntersections;
  32383. /**
  32384. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  32385. */
  32386. proceduralTexturesEnabled: boolean;
  32387. private _engine;
  32388. private _totalVertices;
  32389. /** @hidden */
  32390. _activeIndices: PerfCounter;
  32391. /** @hidden */
  32392. _activeParticles: PerfCounter;
  32393. /** @hidden */
  32394. _activeBones: PerfCounter;
  32395. private _animationRatio;
  32396. /** @hidden */
  32397. _animationTimeLast: number;
  32398. /** @hidden */
  32399. _animationTime: number;
  32400. /**
  32401. * Gets or sets a general scale for animation speed
  32402. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  32403. */
  32404. animationTimeScale: number;
  32405. /** @hidden */
  32406. _cachedMaterial: Nullable<Material>;
  32407. /** @hidden */
  32408. _cachedEffect: Nullable<Effect>;
  32409. /** @hidden */
  32410. _cachedVisibility: Nullable<number>;
  32411. private _renderId;
  32412. private _frameId;
  32413. private _executeWhenReadyTimeoutId;
  32414. private _intermediateRendering;
  32415. private _viewUpdateFlag;
  32416. private _projectionUpdateFlag;
  32417. private _alternateViewUpdateFlag;
  32418. private _alternateProjectionUpdateFlag;
  32419. /** @hidden */
  32420. _toBeDisposed: Nullable<IDisposable>[];
  32421. private _activeRequests;
  32422. /** @hidden */
  32423. _pendingData: any[];
  32424. private _isDisposed;
  32425. /**
  32426. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  32427. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  32428. */
  32429. dispatchAllSubMeshesOfActiveMeshes: boolean;
  32430. private _activeMeshes;
  32431. private _processedMaterials;
  32432. private _renderTargets;
  32433. /** @hidden */
  32434. _activeParticleSystems: SmartArray<IParticleSystem>;
  32435. private _activeSkeletons;
  32436. private _softwareSkinnedMeshes;
  32437. private _renderingManager;
  32438. /** @hidden */
  32439. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  32440. private _transformMatrix;
  32441. private _sceneUbo;
  32442. private _alternateSceneUbo;
  32443. private _viewMatrix;
  32444. private _projectionMatrix;
  32445. private _alternateViewMatrix;
  32446. private _alternateProjectionMatrix;
  32447. private _alternateTransformMatrix;
  32448. private _useAlternateCameraConfiguration;
  32449. private _alternateRendering;
  32450. private _wheelEventName;
  32451. /** @hidden */
  32452. _forcedViewPosition: Nullable<Vector3>;
  32453. /** @hidden */
  32454. readonly _isAlternateRenderingEnabled: boolean;
  32455. private _frustumPlanes;
  32456. /**
  32457. * Gets the list of frustum planes (built from the active camera)
  32458. */
  32459. readonly frustumPlanes: Plane[];
  32460. /**
  32461. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  32462. * This is useful if there are more lights that the maximum simulteanous authorized
  32463. */
  32464. requireLightSorting: boolean;
  32465. /** @hidden */
  32466. readonly useMaterialMeshMap: boolean;
  32467. /** @hidden */
  32468. readonly useClonedMeshhMap: boolean;
  32469. private _pointerOverMesh;
  32470. private _pickedDownMesh;
  32471. private _pickedUpMesh;
  32472. private _externalData;
  32473. private _uid;
  32474. /**
  32475. * @hidden
  32476. * Backing store of defined scene components.
  32477. */
  32478. _components: ISceneComponent[];
  32479. /**
  32480. * @hidden
  32481. * Backing store of defined scene components.
  32482. */
  32483. _serializableComponents: ISceneSerializableComponent[];
  32484. /**
  32485. * List of components to register on the next registration step.
  32486. */
  32487. private _transientComponents;
  32488. /**
  32489. * Registers the transient components if needed.
  32490. */
  32491. private _registerTransientComponents;
  32492. /**
  32493. * @hidden
  32494. * Add a component to the scene.
  32495. * Note that the ccomponent could be registered on th next frame if this is called after
  32496. * the register component stage.
  32497. * @param component Defines the component to add to the scene
  32498. */
  32499. _addComponent(component: ISceneComponent): void;
  32500. /**
  32501. * @hidden
  32502. * Gets a component from the scene.
  32503. * @param name defines the name of the component to retrieve
  32504. * @returns the component or null if not present
  32505. */
  32506. _getComponent(name: string): Nullable<ISceneComponent>;
  32507. /**
  32508. * @hidden
  32509. * Defines the actions happening before camera updates.
  32510. */
  32511. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  32512. /**
  32513. * @hidden
  32514. * Defines the actions happening before clear the canvas.
  32515. */
  32516. _beforeClearStage: Stage<SimpleStageAction>;
  32517. /**
  32518. * @hidden
  32519. * Defines the actions when collecting render targets for the frame.
  32520. */
  32521. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  32522. /**
  32523. * @hidden
  32524. * Defines the actions happening for one camera in the frame.
  32525. */
  32526. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  32527. /**
  32528. * @hidden
  32529. * Defines the actions happening during the per mesh ready checks.
  32530. */
  32531. _isReadyForMeshStage: Stage<MeshStageAction>;
  32532. /**
  32533. * @hidden
  32534. * Defines the actions happening before evaluate active mesh checks.
  32535. */
  32536. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  32537. /**
  32538. * @hidden
  32539. * Defines the actions happening during the evaluate sub mesh checks.
  32540. */
  32541. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  32542. /**
  32543. * @hidden
  32544. * Defines the actions happening during the active mesh stage.
  32545. */
  32546. _activeMeshStage: Stage<ActiveMeshStageAction>;
  32547. /**
  32548. * @hidden
  32549. * Defines the actions happening during the per camera render target step.
  32550. */
  32551. _cameraDrawRenderTargetStage: Stage<CameraStageAction>;
  32552. /**
  32553. * @hidden
  32554. * Defines the actions happening just before the active camera is drawing.
  32555. */
  32556. _beforeCameraDrawStage: Stage<CameraStageAction>;
  32557. /**
  32558. * @hidden
  32559. * Defines the actions happening just before a render target is drawing.
  32560. */
  32561. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  32562. /**
  32563. * @hidden
  32564. * Defines the actions happening just before a rendering group is drawing.
  32565. */
  32566. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  32567. /**
  32568. * @hidden
  32569. * Defines the actions happening just before a mesh is drawing.
  32570. */
  32571. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  32572. /**
  32573. * @hidden
  32574. * Defines the actions happening just after a mesh has been drawn.
  32575. */
  32576. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  32577. /**
  32578. * @hidden
  32579. * Defines the actions happening just after a rendering group has been drawn.
  32580. */
  32581. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  32582. /**
  32583. * @hidden
  32584. * Defines the actions happening just after the active camera has been drawn.
  32585. */
  32586. _afterCameraDrawStage: Stage<CameraStageAction>;
  32587. /**
  32588. * @hidden
  32589. * Defines the actions happening just after a render target has been drawn.
  32590. */
  32591. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  32592. /**
  32593. * @hidden
  32594. * Defines the actions happening just after rendering all cameras and computing intersections.
  32595. */
  32596. _afterRenderStage: Stage<SimpleStageAction>;
  32597. /**
  32598. * @hidden
  32599. * Defines the actions happening when a pointer move event happens.
  32600. */
  32601. _pointerMoveStage: Stage<PointerMoveStageAction>;
  32602. /**
  32603. * @hidden
  32604. * Defines the actions happening when a pointer down event happens.
  32605. */
  32606. _pointerDownStage: Stage<PointerUpDownStageAction>;
  32607. /**
  32608. * @hidden
  32609. * Defines the actions happening when a pointer up event happens.
  32610. */
  32611. _pointerUpStage: Stage<PointerUpDownStageAction>;
  32612. /**
  32613. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  32614. */
  32615. private geometriesByUniqueId;
  32616. /**
  32617. * Creates a new Scene
  32618. * @param engine defines the engine to use to render this scene
  32619. * @param options defines the scene options
  32620. */
  32621. constructor(engine: Engine, options?: SceneOptions);
  32622. private _defaultMeshCandidates;
  32623. /**
  32624. * @hidden
  32625. */
  32626. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  32627. private _defaultSubMeshCandidates;
  32628. /**
  32629. * @hidden
  32630. */
  32631. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  32632. /**
  32633. * Sets the default candidate providers for the scene.
  32634. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  32635. * and getCollidingSubMeshCandidates to their default function
  32636. */
  32637. setDefaultCandidateProviders(): void;
  32638. /**
  32639. * Gets the mesh that is currently under the pointer
  32640. */
  32641. readonly meshUnderPointer: Nullable<AbstractMesh>;
  32642. /**
  32643. * Gets or sets the current on-screen X position of the pointer
  32644. */
  32645. pointerX: number;
  32646. /**
  32647. * Gets or sets the current on-screen Y position of the pointer
  32648. */
  32649. pointerY: number;
  32650. /**
  32651. * Gets the cached material (ie. the latest rendered one)
  32652. * @returns the cached material
  32653. */
  32654. getCachedMaterial(): Nullable<Material>;
  32655. /**
  32656. * Gets the cached effect (ie. the latest rendered one)
  32657. * @returns the cached effect
  32658. */
  32659. getCachedEffect(): Nullable<Effect>;
  32660. /**
  32661. * Gets the cached visibility state (ie. the latest rendered one)
  32662. * @returns the cached visibility state
  32663. */
  32664. getCachedVisibility(): Nullable<number>;
  32665. /**
  32666. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  32667. * @param material defines the current material
  32668. * @param effect defines the current effect
  32669. * @param visibility defines the current visibility state
  32670. * @returns true if one parameter is not cached
  32671. */
  32672. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  32673. /**
  32674. * Gets the engine associated with the scene
  32675. * @returns an Engine
  32676. */
  32677. getEngine(): Engine;
  32678. /**
  32679. * Gets the total number of vertices rendered per frame
  32680. * @returns the total number of vertices rendered per frame
  32681. */
  32682. getTotalVertices(): number;
  32683. /**
  32684. * Gets the performance counter for total vertices
  32685. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32686. */
  32687. readonly totalVerticesPerfCounter: PerfCounter;
  32688. /**
  32689. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  32690. * @returns the total number of active indices rendered per frame
  32691. */
  32692. getActiveIndices(): number;
  32693. /**
  32694. * Gets the performance counter for active indices
  32695. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32696. */
  32697. readonly totalActiveIndicesPerfCounter: PerfCounter;
  32698. /**
  32699. * Gets the total number of active particles rendered per frame
  32700. * @returns the total number of active particles rendered per frame
  32701. */
  32702. getActiveParticles(): number;
  32703. /**
  32704. * Gets the performance counter for active particles
  32705. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32706. */
  32707. readonly activeParticlesPerfCounter: PerfCounter;
  32708. /**
  32709. * Gets the total number of active bones rendered per frame
  32710. * @returns the total number of active bones rendered per frame
  32711. */
  32712. getActiveBones(): number;
  32713. /**
  32714. * Gets the performance counter for active bones
  32715. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32716. */
  32717. readonly activeBonesPerfCounter: PerfCounter;
  32718. /**
  32719. * Gets the array of active meshes
  32720. * @returns an array of AbstractMesh
  32721. */
  32722. getActiveMeshes(): SmartArray<AbstractMesh>;
  32723. /**
  32724. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  32725. * @returns a number
  32726. */
  32727. getAnimationRatio(): number;
  32728. /**
  32729. * Gets an unique Id for the current render phase
  32730. * @returns a number
  32731. */
  32732. getRenderId(): number;
  32733. /**
  32734. * Gets an unique Id for the current frame
  32735. * @returns a number
  32736. */
  32737. getFrameId(): number;
  32738. /** Call this function if you want to manually increment the render Id*/
  32739. incrementRenderId(): void;
  32740. private _updatePointerPosition;
  32741. private _createUbo;
  32742. private _createAlternateUbo;
  32743. private _setRayOnPointerInfo;
  32744. /**
  32745. * Use this method to simulate a pointer move on a mesh
  32746. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32747. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32748. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32749. * @returns the current scene
  32750. */
  32751. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  32752. private _processPointerMove;
  32753. private _checkPrePointerObservable;
  32754. /**
  32755. * Use this method to simulate a pointer down on a mesh
  32756. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32757. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32758. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32759. * @returns the current scene
  32760. */
  32761. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  32762. private _processPointerDown;
  32763. /**
  32764. * Use this method to simulate a pointer up on a mesh
  32765. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32766. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32767. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32768. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  32769. * @returns the current scene
  32770. */
  32771. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  32772. private _processPointerUp;
  32773. /**
  32774. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  32775. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  32776. * @returns true if the pointer was captured
  32777. */
  32778. isPointerCaptured(pointerId?: number): boolean;
  32779. /** @hidden */
  32780. _isPointerSwiping(): boolean;
  32781. /**
  32782. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  32783. * @param attachUp defines if you want to attach events to pointerup
  32784. * @param attachDown defines if you want to attach events to pointerdown
  32785. * @param attachMove defines if you want to attach events to pointermove
  32786. */
  32787. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  32788. /** Detaches all event handlers*/
  32789. detachControl(): void;
  32790. /**
  32791. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  32792. * Delay loaded resources are not taking in account
  32793. * @return true if all required resources are ready
  32794. */
  32795. isReady(): boolean;
  32796. /** Resets all cached information relative to material (including effect and visibility) */
  32797. resetCachedMaterial(): void;
  32798. /**
  32799. * Registers a function to be called before every frame render
  32800. * @param func defines the function to register
  32801. */
  32802. registerBeforeRender(func: () => void): void;
  32803. /**
  32804. * Unregisters a function called before every frame render
  32805. * @param func defines the function to unregister
  32806. */
  32807. unregisterBeforeRender(func: () => void): void;
  32808. /**
  32809. * Registers a function to be called after every frame render
  32810. * @param func defines the function to register
  32811. */
  32812. registerAfterRender(func: () => void): void;
  32813. /**
  32814. * Unregisters a function called after every frame render
  32815. * @param func defines the function to unregister
  32816. */
  32817. unregisterAfterRender(func: () => void): void;
  32818. private _executeOnceBeforeRender;
  32819. /**
  32820. * The provided function will run before render once and will be disposed afterwards.
  32821. * A timeout delay can be provided so that the function will be executed in N ms.
  32822. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  32823. * @param func The function to be executed.
  32824. * @param timeout optional delay in ms
  32825. */
  32826. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  32827. /** @hidden */
  32828. _addPendingData(data: any): void;
  32829. /** @hidden */
  32830. _removePendingData(data: any): void;
  32831. /**
  32832. * Returns the number of items waiting to be loaded
  32833. * @returns the number of items waiting to be loaded
  32834. */
  32835. getWaitingItemsCount(): number;
  32836. /**
  32837. * Returns a boolean indicating if the scene is still loading data
  32838. */
  32839. readonly isLoading: boolean;
  32840. /**
  32841. * Registers a function to be executed when the scene is ready
  32842. * @param {Function} func - the function to be executed
  32843. */
  32844. executeWhenReady(func: () => void): void;
  32845. /**
  32846. * Returns a promise that resolves when the scene is ready
  32847. * @returns A promise that resolves when the scene is ready
  32848. */
  32849. whenReadyAsync(): Promise<void>;
  32850. /** @hidden */
  32851. _checkIsReady(): void;
  32852. /**
  32853. * Gets all animatable attached to the scene
  32854. */
  32855. readonly animatables: Animatable[];
  32856. /**
  32857. * Resets the last animation time frame.
  32858. * Useful to override when animations start running when loading a scene for the first time.
  32859. */
  32860. resetLastAnimationTimeFrame(): void;
  32861. /** @hidden */
  32862. _switchToAlternateCameraConfiguration(active: boolean): void;
  32863. /**
  32864. * Gets the current view matrix
  32865. * @returns a Matrix
  32866. */
  32867. getViewMatrix(): Matrix;
  32868. /**
  32869. * Gets the current projection matrix
  32870. * @returns a Matrix
  32871. */
  32872. getProjectionMatrix(): Matrix;
  32873. /**
  32874. * Gets the current transform matrix
  32875. * @returns a Matrix made of View * Projection
  32876. */
  32877. getTransformMatrix(): Matrix;
  32878. /**
  32879. * Sets the current transform matrix
  32880. * @param view defines the View matrix to use
  32881. * @param projection defines the Projection matrix to use
  32882. */
  32883. setTransformMatrix(view: Matrix, projection: Matrix): void;
  32884. /** @hidden */
  32885. _setAlternateTransformMatrix(view: Matrix, projection: Matrix): void;
  32886. /**
  32887. * Gets the uniform buffer used to store scene data
  32888. * @returns a UniformBuffer
  32889. */
  32890. getSceneUniformBuffer(): UniformBuffer;
  32891. /**
  32892. * Gets an unique (relatively to the current scene) Id
  32893. * @returns an unique number for the scene
  32894. */
  32895. getUniqueId(): number;
  32896. /**
  32897. * Add a mesh to the list of scene's meshes
  32898. * @param newMesh defines the mesh to add
  32899. * @param recursive if all child meshes should also be added to the scene
  32900. */
  32901. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  32902. /**
  32903. * Remove a mesh for the list of scene's meshes
  32904. * @param toRemove defines the mesh to remove
  32905. * @param recursive if all child meshes should also be removed from the scene
  32906. * @returns the index where the mesh was in the mesh list
  32907. */
  32908. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  32909. /**
  32910. * Add a transform node to the list of scene's transform nodes
  32911. * @param newTransformNode defines the transform node to add
  32912. */
  32913. addTransformNode(newTransformNode: TransformNode): void;
  32914. /**
  32915. * Remove a transform node for the list of scene's transform nodes
  32916. * @param toRemove defines the transform node to remove
  32917. * @returns the index where the transform node was in the transform node list
  32918. */
  32919. removeTransformNode(toRemove: TransformNode): number;
  32920. /**
  32921. * Remove a skeleton for the list of scene's skeletons
  32922. * @param toRemove defines the skeleton to remove
  32923. * @returns the index where the skeleton was in the skeleton list
  32924. */
  32925. removeSkeleton(toRemove: Skeleton): number;
  32926. /**
  32927. * Remove a morph target for the list of scene's morph targets
  32928. * @param toRemove defines the morph target to remove
  32929. * @returns the index where the morph target was in the morph target list
  32930. */
  32931. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  32932. /**
  32933. * Remove a light for the list of scene's lights
  32934. * @param toRemove defines the light to remove
  32935. * @returns the index where the light was in the light list
  32936. */
  32937. removeLight(toRemove: Light): number;
  32938. /**
  32939. * Remove a camera for the list of scene's cameras
  32940. * @param toRemove defines the camera to remove
  32941. * @returns the index where the camera was in the camera list
  32942. */
  32943. removeCamera(toRemove: Camera): number;
  32944. /**
  32945. * Remove a particle system for the list of scene's particle systems
  32946. * @param toRemove defines the particle system to remove
  32947. * @returns the index where the particle system was in the particle system list
  32948. */
  32949. removeParticleSystem(toRemove: IParticleSystem): number;
  32950. /**
  32951. * Remove a animation for the list of scene's animations
  32952. * @param toRemove defines the animation to remove
  32953. * @returns the index where the animation was in the animation list
  32954. */
  32955. removeAnimation(toRemove: Animation): number;
  32956. /**
  32957. * Removes the given animation group from this scene.
  32958. * @param toRemove The animation group to remove
  32959. * @returns The index of the removed animation group
  32960. */
  32961. removeAnimationGroup(toRemove: AnimationGroup): number;
  32962. /**
  32963. * Removes the given multi-material from this scene.
  32964. * @param toRemove The multi-material to remove
  32965. * @returns The index of the removed multi-material
  32966. */
  32967. removeMultiMaterial(toRemove: MultiMaterial): number;
  32968. /**
  32969. * Removes the given material from this scene.
  32970. * @param toRemove The material to remove
  32971. * @returns The index of the removed material
  32972. */
  32973. removeMaterial(toRemove: Material): number;
  32974. /**
  32975. * Removes the given action manager from this scene.
  32976. * @param toRemove The action manager to remove
  32977. * @returns The index of the removed action manager
  32978. */
  32979. removeActionManager(toRemove: AbstractActionManager): number;
  32980. /**
  32981. * Removes the given texture from this scene.
  32982. * @param toRemove The texture to remove
  32983. * @returns The index of the removed texture
  32984. */
  32985. removeTexture(toRemove: BaseTexture): number;
  32986. /**
  32987. * Adds the given light to this scene
  32988. * @param newLight The light to add
  32989. */
  32990. addLight(newLight: Light): void;
  32991. /**
  32992. * Sorts the list list based on light priorities
  32993. */
  32994. sortLightsByPriority(): void;
  32995. /**
  32996. * Adds the given camera to this scene
  32997. * @param newCamera The camera to add
  32998. */
  32999. addCamera(newCamera: Camera): void;
  33000. /**
  33001. * Adds the given skeleton to this scene
  33002. * @param newSkeleton The skeleton to add
  33003. */
  33004. addSkeleton(newSkeleton: Skeleton): void;
  33005. /**
  33006. * Adds the given particle system to this scene
  33007. * @param newParticleSystem The particle system to add
  33008. */
  33009. addParticleSystem(newParticleSystem: IParticleSystem): void;
  33010. /**
  33011. * Adds the given animation to this scene
  33012. * @param newAnimation The animation to add
  33013. */
  33014. addAnimation(newAnimation: Animation): void;
  33015. /**
  33016. * Adds the given animation group to this scene.
  33017. * @param newAnimationGroup The animation group to add
  33018. */
  33019. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  33020. /**
  33021. * Adds the given multi-material to this scene
  33022. * @param newMultiMaterial The multi-material to add
  33023. */
  33024. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  33025. /**
  33026. * Adds the given material to this scene
  33027. * @param newMaterial The material to add
  33028. */
  33029. addMaterial(newMaterial: Material): void;
  33030. /**
  33031. * Adds the given morph target to this scene
  33032. * @param newMorphTargetManager The morph target to add
  33033. */
  33034. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  33035. /**
  33036. * Adds the given geometry to this scene
  33037. * @param newGeometry The geometry to add
  33038. */
  33039. addGeometry(newGeometry: Geometry): void;
  33040. /**
  33041. * Adds the given action manager to this scene
  33042. * @param newActionManager The action manager to add
  33043. */
  33044. addActionManager(newActionManager: AbstractActionManager): void;
  33045. /**
  33046. * Adds the given texture to this scene.
  33047. * @param newTexture The texture to add
  33048. */
  33049. addTexture(newTexture: BaseTexture): void;
  33050. /**
  33051. * Switch active camera
  33052. * @param newCamera defines the new active camera
  33053. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  33054. */
  33055. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  33056. /**
  33057. * sets the active camera of the scene using its ID
  33058. * @param id defines the camera's ID
  33059. * @return the new active camera or null if none found.
  33060. */
  33061. setActiveCameraByID(id: string): Nullable<Camera>;
  33062. /**
  33063. * sets the active camera of the scene using its name
  33064. * @param name defines the camera's name
  33065. * @returns the new active camera or null if none found.
  33066. */
  33067. setActiveCameraByName(name: string): Nullable<Camera>;
  33068. /**
  33069. * get an animation group using its name
  33070. * @param name defines the material's name
  33071. * @return the animation group or null if none found.
  33072. */
  33073. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  33074. /**
  33075. * get a material using its id
  33076. * @param id defines the material's ID
  33077. * @return the material or null if none found.
  33078. */
  33079. getMaterialByID(id: string): Nullable<Material>;
  33080. /**
  33081. * Gets a material using its name
  33082. * @param name defines the material's name
  33083. * @return the material or null if none found.
  33084. */
  33085. getMaterialByName(name: string): Nullable<Material>;
  33086. /**
  33087. * Gets a camera using its id
  33088. * @param id defines the id to look for
  33089. * @returns the camera or null if not found
  33090. */
  33091. getCameraByID(id: string): Nullable<Camera>;
  33092. /**
  33093. * Gets a camera using its unique id
  33094. * @param uniqueId defines the unique id to look for
  33095. * @returns the camera or null if not found
  33096. */
  33097. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  33098. /**
  33099. * Gets a camera using its name
  33100. * @param name defines the camera's name
  33101. * @return the camera or null if none found.
  33102. */
  33103. getCameraByName(name: string): Nullable<Camera>;
  33104. /**
  33105. * Gets a bone using its id
  33106. * @param id defines the bone's id
  33107. * @return the bone or null if not found
  33108. */
  33109. getBoneByID(id: string): Nullable<Bone>;
  33110. /**
  33111. * Gets a bone using its id
  33112. * @param name defines the bone's name
  33113. * @return the bone or null if not found
  33114. */
  33115. getBoneByName(name: string): Nullable<Bone>;
  33116. /**
  33117. * Gets a light node using its name
  33118. * @param name defines the the light's name
  33119. * @return the light or null if none found.
  33120. */
  33121. getLightByName(name: string): Nullable<Light>;
  33122. /**
  33123. * Gets a light node using its id
  33124. * @param id defines the light's id
  33125. * @return the light or null if none found.
  33126. */
  33127. getLightByID(id: string): Nullable<Light>;
  33128. /**
  33129. * Gets a light node using its scene-generated unique ID
  33130. * @param uniqueId defines the light's unique id
  33131. * @return the light or null if none found.
  33132. */
  33133. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  33134. /**
  33135. * Gets a particle system by id
  33136. * @param id defines the particle system id
  33137. * @return the corresponding system or null if none found
  33138. */
  33139. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  33140. /**
  33141. * Gets a geometry using its ID
  33142. * @param id defines the geometry's id
  33143. * @return the geometry or null if none found.
  33144. */
  33145. getGeometryByID(id: string): Nullable<Geometry>;
  33146. private _getGeometryByUniqueID;
  33147. /**
  33148. * Add a new geometry to this scene
  33149. * @param geometry defines the geometry to be added to the scene.
  33150. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  33151. * @return a boolean defining if the geometry was added or not
  33152. */
  33153. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  33154. /**
  33155. * Removes an existing geometry
  33156. * @param geometry defines the geometry to be removed from the scene
  33157. * @return a boolean defining if the geometry was removed or not
  33158. */
  33159. removeGeometry(geometry: Geometry): boolean;
  33160. /**
  33161. * Gets the list of geometries attached to the scene
  33162. * @returns an array of Geometry
  33163. */
  33164. getGeometries(): Geometry[];
  33165. /**
  33166. * Gets the first added mesh found of a given ID
  33167. * @param id defines the id to search for
  33168. * @return the mesh found or null if not found at all
  33169. */
  33170. getMeshByID(id: string): Nullable<AbstractMesh>;
  33171. /**
  33172. * Gets a list of meshes using their id
  33173. * @param id defines the id to search for
  33174. * @returns a list of meshes
  33175. */
  33176. getMeshesByID(id: string): Array<AbstractMesh>;
  33177. /**
  33178. * Gets the first added transform node found of a given ID
  33179. * @param id defines the id to search for
  33180. * @return the found transform node or null if not found at all.
  33181. */
  33182. getTransformNodeByID(id: string): Nullable<TransformNode>;
  33183. /**
  33184. * Gets a list of transform nodes using their id
  33185. * @param id defines the id to search for
  33186. * @returns a list of transform nodes
  33187. */
  33188. getTransformNodesByID(id: string): Array<TransformNode>;
  33189. /**
  33190. * Gets a mesh with its auto-generated unique id
  33191. * @param uniqueId defines the unique id to search for
  33192. * @return the found mesh or null if not found at all.
  33193. */
  33194. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  33195. /**
  33196. * Gets a the last added mesh using a given id
  33197. * @param id defines the id to search for
  33198. * @return the found mesh or null if not found at all.
  33199. */
  33200. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  33201. /**
  33202. * Gets a the last added node (Mesh, Camera, Light) using a given id
  33203. * @param id defines the id to search for
  33204. * @return the found node or null if not found at all
  33205. */
  33206. getLastEntryByID(id: string): Nullable<Node>;
  33207. /**
  33208. * Gets a node (Mesh, Camera, Light) using a given id
  33209. * @param id defines the id to search for
  33210. * @return the found node or null if not found at all
  33211. */
  33212. getNodeByID(id: string): Nullable<Node>;
  33213. /**
  33214. * Gets a node (Mesh, Camera, Light) using a given name
  33215. * @param name defines the name to search for
  33216. * @return the found node or null if not found at all.
  33217. */
  33218. getNodeByName(name: string): Nullable<Node>;
  33219. /**
  33220. * Gets a mesh using a given name
  33221. * @param name defines the name to search for
  33222. * @return the found mesh or null if not found at all.
  33223. */
  33224. getMeshByName(name: string): Nullable<AbstractMesh>;
  33225. /**
  33226. * Gets a transform node using a given name
  33227. * @param name defines the name to search for
  33228. * @return the found transform node or null if not found at all.
  33229. */
  33230. getTransformNodeByName(name: string): Nullable<TransformNode>;
  33231. /**
  33232. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  33233. * @param id defines the id to search for
  33234. * @return the found skeleton or null if not found at all.
  33235. */
  33236. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  33237. /**
  33238. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  33239. * @param id defines the id to search for
  33240. * @return the found skeleton or null if not found at all.
  33241. */
  33242. getSkeletonById(id: string): Nullable<Skeleton>;
  33243. /**
  33244. * Gets a skeleton using a given name
  33245. * @param name defines the name to search for
  33246. * @return the found skeleton or null if not found at all.
  33247. */
  33248. getSkeletonByName(name: string): Nullable<Skeleton>;
  33249. /**
  33250. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  33251. * @param id defines the id to search for
  33252. * @return the found morph target manager or null if not found at all.
  33253. */
  33254. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  33255. /**
  33256. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  33257. * @param id defines the id to search for
  33258. * @return the found morph target or null if not found at all.
  33259. */
  33260. getMorphTargetById(id: string): Nullable<MorphTarget>;
  33261. /**
  33262. * Gets a boolean indicating if the given mesh is active
  33263. * @param mesh defines the mesh to look for
  33264. * @returns true if the mesh is in the active list
  33265. */
  33266. isActiveMesh(mesh: AbstractMesh): boolean;
  33267. /**
  33268. * Return a unique id as a string which can serve as an identifier for the scene
  33269. */
  33270. readonly uid: string;
  33271. /**
  33272. * Add an externaly attached data from its key.
  33273. * This method call will fail and return false, if such key already exists.
  33274. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  33275. * @param key the unique key that identifies the data
  33276. * @param data the data object to associate to the key for this Engine instance
  33277. * @return true if no such key were already present and the data was added successfully, false otherwise
  33278. */
  33279. addExternalData<T>(key: string, data: T): boolean;
  33280. /**
  33281. * Get an externaly attached data from its key
  33282. * @param key the unique key that identifies the data
  33283. * @return the associated data, if present (can be null), or undefined if not present
  33284. */
  33285. getExternalData<T>(key: string): Nullable<T>;
  33286. /**
  33287. * Get an externaly attached data from its key, create it using a factory if it's not already present
  33288. * @param key the unique key that identifies the data
  33289. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  33290. * @return the associated data, can be null if the factory returned null.
  33291. */
  33292. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  33293. /**
  33294. * Remove an externaly attached data from the Engine instance
  33295. * @param key the unique key that identifies the data
  33296. * @return true if the data was successfully removed, false if it doesn't exist
  33297. */
  33298. removeExternalData(key: string): boolean;
  33299. private _evaluateSubMesh;
  33300. /**
  33301. * Clear the processed materials smart array preventing retention point in material dispose.
  33302. */
  33303. freeProcessedMaterials(): void;
  33304. private _preventFreeActiveMeshesAndRenderingGroups;
  33305. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  33306. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  33307. * when disposing several meshes in a row or a hierarchy of meshes.
  33308. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  33309. */
  33310. blockfreeActiveMeshesAndRenderingGroups: boolean;
  33311. /**
  33312. * Clear the active meshes smart array preventing retention point in mesh dispose.
  33313. */
  33314. freeActiveMeshes(): void;
  33315. /**
  33316. * Clear the info related to rendering groups preventing retention points during dispose.
  33317. */
  33318. freeRenderingGroups(): void;
  33319. /** @hidden */
  33320. _isInIntermediateRendering(): boolean;
  33321. /**
  33322. * Lambda returning the list of potentially active meshes.
  33323. */
  33324. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  33325. /**
  33326. * Lambda returning the list of potentially active sub meshes.
  33327. */
  33328. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  33329. /**
  33330. * Lambda returning the list of potentially intersecting sub meshes.
  33331. */
  33332. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  33333. /**
  33334. * Lambda returning the list of potentially colliding sub meshes.
  33335. */
  33336. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  33337. private _activeMeshesFrozen;
  33338. /**
  33339. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  33340. * @returns the current scene
  33341. */
  33342. freezeActiveMeshes(): Scene;
  33343. /**
  33344. * Use this function to restart evaluating active meshes on every frame
  33345. * @returns the current scene
  33346. */
  33347. unfreezeActiveMeshes(): Scene;
  33348. private _evaluateActiveMeshes;
  33349. private _activeMesh;
  33350. /**
  33351. * Update the transform matrix to update from the current active camera
  33352. * @param force defines a boolean used to force the update even if cache is up to date
  33353. */
  33354. updateTransformMatrix(force?: boolean): void;
  33355. /**
  33356. * 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)
  33357. * @param alternateCamera defines the camera to use
  33358. */
  33359. updateAlternateTransformMatrix(alternateCamera: Camera): void;
  33360. /** @hidden */
  33361. _allowPostProcessClearColor: boolean;
  33362. private _renderForCamera;
  33363. private _processSubCameras;
  33364. private _checkIntersections;
  33365. /** @hidden */
  33366. _advancePhysicsEngineStep(step: number): void;
  33367. /**
  33368. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  33369. */
  33370. getDeterministicFrameTime: () => number;
  33371. /** @hidden */
  33372. _animate(): void;
  33373. /**
  33374. * Render the scene
  33375. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  33376. */
  33377. render(updateCameras?: boolean): void;
  33378. /**
  33379. * Freeze all materials
  33380. * A frozen material will not be updatable but should be faster to render
  33381. */
  33382. freezeMaterials(): void;
  33383. /**
  33384. * Unfreeze all materials
  33385. * A frozen material will not be updatable but should be faster to render
  33386. */
  33387. unfreezeMaterials(): void;
  33388. /**
  33389. * Releases all held ressources
  33390. */
  33391. dispose(): void;
  33392. /**
  33393. * Gets if the scene is already disposed
  33394. */
  33395. readonly isDisposed: boolean;
  33396. /**
  33397. * Call this function to reduce memory footprint of the scene.
  33398. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  33399. */
  33400. clearCachedVertexData(): void;
  33401. /**
  33402. * This function will remove the local cached buffer data from texture.
  33403. * It will save memory but will prevent the texture from being rebuilt
  33404. */
  33405. cleanCachedTextureBuffer(): void;
  33406. /**
  33407. * Get the world extend vectors with an optional filter
  33408. *
  33409. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  33410. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  33411. */
  33412. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  33413. min: Vector3;
  33414. max: Vector3;
  33415. };
  33416. /**
  33417. * Creates a ray that can be used to pick in the scene
  33418. * @param x defines the x coordinate of the origin (on-screen)
  33419. * @param y defines the y coordinate of the origin (on-screen)
  33420. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  33421. * @param camera defines the camera to use for the picking
  33422. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  33423. * @returns a Ray
  33424. */
  33425. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  33426. /**
  33427. * Creates a ray that can be used to pick in the scene
  33428. * @param x defines the x coordinate of the origin (on-screen)
  33429. * @param y defines the y coordinate of the origin (on-screen)
  33430. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  33431. * @param result defines the ray where to store the picking ray
  33432. * @param camera defines the camera to use for the picking
  33433. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  33434. * @returns the current scene
  33435. */
  33436. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  33437. /**
  33438. * Creates a ray that can be used to pick in the scene
  33439. * @param x defines the x coordinate of the origin (on-screen)
  33440. * @param y defines the y coordinate of the origin (on-screen)
  33441. * @param camera defines the camera to use for the picking
  33442. * @returns a Ray
  33443. */
  33444. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  33445. /**
  33446. * Creates a ray that can be used to pick in the scene
  33447. * @param x defines the x coordinate of the origin (on-screen)
  33448. * @param y defines the y coordinate of the origin (on-screen)
  33449. * @param result defines the ray where to store the picking ray
  33450. * @param camera defines the camera to use for the picking
  33451. * @returns the current scene
  33452. */
  33453. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  33454. /** Launch a ray to try to pick a mesh in the scene
  33455. * @param x position on screen
  33456. * @param y position on screen
  33457. * @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
  33458. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  33459. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  33460. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33461. * @returns a PickingInfo
  33462. */
  33463. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: (p0: Vector3, p1: Vector3, p2: Vector3) => boolean): Nullable<PickingInfo>;
  33464. /** Use the given ray to pick a mesh in the scene
  33465. * @param ray The ray to use to pick meshes
  33466. * @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
  33467. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  33468. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33469. * @returns a PickingInfo
  33470. */
  33471. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  33472. /**
  33473. * Launch a ray to try to pick a mesh in the scene
  33474. * @param x X position on screen
  33475. * @param y Y position on screen
  33476. * @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
  33477. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  33478. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33479. * @returns an array of PickingInfo
  33480. */
  33481. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  33482. /**
  33483. * Launch a ray to try to pick a mesh in the scene
  33484. * @param ray Ray to use
  33485. * @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
  33486. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33487. * @returns an array of PickingInfo
  33488. */
  33489. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  33490. /**
  33491. * Force the value of meshUnderPointer
  33492. * @param mesh defines the mesh to use
  33493. */
  33494. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  33495. /**
  33496. * Gets the mesh under the pointer
  33497. * @returns a Mesh or null if no mesh is under the pointer
  33498. */
  33499. getPointerOverMesh(): Nullable<AbstractMesh>;
  33500. /** @hidden */
  33501. _rebuildGeometries(): void;
  33502. /** @hidden */
  33503. _rebuildTextures(): void;
  33504. private _getByTags;
  33505. /**
  33506. * Get a list of meshes by tags
  33507. * @param tagsQuery defines the tags query to use
  33508. * @param forEach defines a predicate used to filter results
  33509. * @returns an array of Mesh
  33510. */
  33511. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  33512. /**
  33513. * Get a list of cameras by tags
  33514. * @param tagsQuery defines the tags query to use
  33515. * @param forEach defines a predicate used to filter results
  33516. * @returns an array of Camera
  33517. */
  33518. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  33519. /**
  33520. * Get a list of lights by tags
  33521. * @param tagsQuery defines the tags query to use
  33522. * @param forEach defines a predicate used to filter results
  33523. * @returns an array of Light
  33524. */
  33525. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  33526. /**
  33527. * Get a list of materials by tags
  33528. * @param tagsQuery defines the tags query to use
  33529. * @param forEach defines a predicate used to filter results
  33530. * @returns an array of Material
  33531. */
  33532. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  33533. /**
  33534. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  33535. * This allowed control for front to back rendering or reversly depending of the special needs.
  33536. *
  33537. * @param renderingGroupId The rendering group id corresponding to its index
  33538. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  33539. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  33540. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  33541. */
  33542. 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;
  33543. /**
  33544. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  33545. *
  33546. * @param renderingGroupId The rendering group id corresponding to its index
  33547. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  33548. * @param depth Automatically clears depth between groups if true and autoClear is true.
  33549. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  33550. */
  33551. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  33552. /**
  33553. * Gets the current auto clear configuration for one rendering group of the rendering
  33554. * manager.
  33555. * @param index the rendering group index to get the information for
  33556. * @returns The auto clear setup for the requested rendering group
  33557. */
  33558. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  33559. private _blockMaterialDirtyMechanism;
  33560. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  33561. blockMaterialDirtyMechanism: boolean;
  33562. /**
  33563. * Will flag all materials as dirty to trigger new shader compilation
  33564. * @param flag defines the flag used to specify which material part must be marked as dirty
  33565. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  33566. */
  33567. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  33568. /** @hidden */
  33569. _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;
  33570. /** @hidden */
  33571. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  33572. }
  33573. }
  33574. declare module "babylonjs/assetContainer" {
  33575. import { AbstractScene } from "babylonjs/abstractScene";
  33576. import { Scene } from "babylonjs/scene";
  33577. import { Mesh } from "babylonjs/Meshes/mesh";
  33578. /**
  33579. * Set of assets to keep when moving a scene into an asset container.
  33580. */
  33581. export class KeepAssets extends AbstractScene {
  33582. }
  33583. /**
  33584. * Container with a set of assets that can be added or removed from a scene.
  33585. */
  33586. export class AssetContainer extends AbstractScene {
  33587. /**
  33588. * The scene the AssetContainer belongs to.
  33589. */
  33590. scene: Scene;
  33591. /**
  33592. * Instantiates an AssetContainer.
  33593. * @param scene The scene the AssetContainer belongs to.
  33594. */
  33595. constructor(scene: Scene);
  33596. /**
  33597. * Adds all the assets from the container to the scene.
  33598. */
  33599. addAllToScene(): void;
  33600. /**
  33601. * Removes all the assets in the container from the scene
  33602. */
  33603. removeAllFromScene(): void;
  33604. /**
  33605. * Disposes all the assets in the container
  33606. */
  33607. dispose(): void;
  33608. private _moveAssets;
  33609. /**
  33610. * Removes all the assets contained in the scene and adds them to the container.
  33611. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  33612. */
  33613. moveAllFromScene(keepAssets?: KeepAssets): void;
  33614. /**
  33615. * 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.
  33616. * @returns the root mesh
  33617. */
  33618. createRootMesh(): Mesh;
  33619. }
  33620. }
  33621. declare module "babylonjs/abstractScene" {
  33622. import { Scene } from "babylonjs/scene";
  33623. import { Nullable } from "babylonjs/types";
  33624. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33625. import { TransformNode } from "babylonjs/Meshes/transformNode";
  33626. import { Geometry } from "babylonjs/Meshes/geometry";
  33627. import { Skeleton } from "babylonjs/Bones/skeleton";
  33628. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  33629. import { AssetContainer } from "babylonjs/assetContainer";
  33630. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  33631. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  33632. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  33633. import { Material } from "babylonjs/Materials/material";
  33634. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  33635. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  33636. import { Camera } from "babylonjs/Cameras/camera";
  33637. import { Light } from "babylonjs/Lights/light";
  33638. import { Node } from "babylonjs/node";
  33639. import { Animation } from "babylonjs/Animations/animation";
  33640. /**
  33641. * Defines how the parser contract is defined.
  33642. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  33643. */
  33644. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  33645. /**
  33646. * Defines how the individual parser contract is defined.
  33647. * These parser can parse an individual asset
  33648. */
  33649. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  33650. /**
  33651. * Base class of the scene acting as a container for the different elements composing a scene.
  33652. * This class is dynamically extended by the different components of the scene increasing
  33653. * flexibility and reducing coupling
  33654. */
  33655. export abstract class AbstractScene {
  33656. /**
  33657. * Stores the list of available parsers in the application.
  33658. */
  33659. private static _BabylonFileParsers;
  33660. /**
  33661. * Stores the list of available individual parsers in the application.
  33662. */
  33663. private static _IndividualBabylonFileParsers;
  33664. /**
  33665. * Adds a parser in the list of available ones
  33666. * @param name Defines the name of the parser
  33667. * @param parser Defines the parser to add
  33668. */
  33669. static AddParser(name: string, parser: BabylonFileParser): void;
  33670. /**
  33671. * Gets a general parser from the list of avaialble ones
  33672. * @param name Defines the name of the parser
  33673. * @returns the requested parser or null
  33674. */
  33675. static GetParser(name: string): Nullable<BabylonFileParser>;
  33676. /**
  33677. * Adds n individual parser in the list of available ones
  33678. * @param name Defines the name of the parser
  33679. * @param parser Defines the parser to add
  33680. */
  33681. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  33682. /**
  33683. * Gets an individual parser from the list of avaialble ones
  33684. * @param name Defines the name of the parser
  33685. * @returns the requested parser or null
  33686. */
  33687. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  33688. /**
  33689. * Parser json data and populate both a scene and its associated container object
  33690. * @param jsonData Defines the data to parse
  33691. * @param scene Defines the scene to parse the data for
  33692. * @param container Defines the container attached to the parsing sequence
  33693. * @param rootUrl Defines the root url of the data
  33694. */
  33695. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  33696. /**
  33697. * Gets the list of root nodes (ie. nodes with no parent)
  33698. */
  33699. rootNodes: Node[];
  33700. /** All of the cameras added to this scene
  33701. * @see http://doc.babylonjs.com/babylon101/cameras
  33702. */
  33703. cameras: Camera[];
  33704. /**
  33705. * All of the lights added to this scene
  33706. * @see http://doc.babylonjs.com/babylon101/lights
  33707. */
  33708. lights: Light[];
  33709. /**
  33710. * All of the (abstract) meshes added to this scene
  33711. */
  33712. meshes: AbstractMesh[];
  33713. /**
  33714. * The list of skeletons added to the scene
  33715. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  33716. */
  33717. skeletons: Skeleton[];
  33718. /**
  33719. * All of the particle systems added to this scene
  33720. * @see http://doc.babylonjs.com/babylon101/particles
  33721. */
  33722. particleSystems: IParticleSystem[];
  33723. /**
  33724. * Gets a list of Animations associated with the scene
  33725. */
  33726. animations: Animation[];
  33727. /**
  33728. * All of the animation groups added to this scene
  33729. * @see http://doc.babylonjs.com/how_to/group
  33730. */
  33731. animationGroups: AnimationGroup[];
  33732. /**
  33733. * All of the multi-materials added to this scene
  33734. * @see http://doc.babylonjs.com/how_to/multi_materials
  33735. */
  33736. multiMaterials: MultiMaterial[];
  33737. /**
  33738. * All of the materials added to this scene
  33739. * In the context of a Scene, it is not supposed to be modified manually.
  33740. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  33741. * Note also that the order of the Material wihin the array is not significant and might change.
  33742. * @see http://doc.babylonjs.com/babylon101/materials
  33743. */
  33744. materials: Material[];
  33745. /**
  33746. * The list of morph target managers added to the scene
  33747. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  33748. */
  33749. morphTargetManagers: MorphTargetManager[];
  33750. /**
  33751. * The list of geometries used in the scene.
  33752. */
  33753. geometries: Geometry[];
  33754. /**
  33755. * All of the tranform nodes added to this scene
  33756. * In the context of a Scene, it is not supposed to be modified manually.
  33757. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  33758. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  33759. * @see http://doc.babylonjs.com/how_to/transformnode
  33760. */
  33761. transformNodes: TransformNode[];
  33762. /**
  33763. * ActionManagers available on the scene.
  33764. */
  33765. actionManagers: AbstractActionManager[];
  33766. /**
  33767. * Textures to keep.
  33768. */
  33769. textures: BaseTexture[];
  33770. }
  33771. }
  33772. declare module "babylonjs/Audio/sound" {
  33773. import { Observable } from "babylonjs/Misc/observable";
  33774. import { Vector3 } from "babylonjs/Maths/math";
  33775. import { Nullable } from "babylonjs/types";
  33776. import { Scene } from "babylonjs/scene";
  33777. import { TransformNode } from "babylonjs/Meshes/transformNode";
  33778. /**
  33779. * Defines a sound that can be played in the application.
  33780. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  33781. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33782. */
  33783. export class Sound {
  33784. /**
  33785. * The name of the sound in the scene.
  33786. */
  33787. name: string;
  33788. /**
  33789. * Does the sound autoplay once loaded.
  33790. */
  33791. autoplay: boolean;
  33792. /**
  33793. * Does the sound loop after it finishes playing once.
  33794. */
  33795. loop: boolean;
  33796. /**
  33797. * Does the sound use a custom attenuation curve to simulate the falloff
  33798. * happening when the source gets further away from the camera.
  33799. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  33800. */
  33801. useCustomAttenuation: boolean;
  33802. /**
  33803. * The sound track id this sound belongs to.
  33804. */
  33805. soundTrackId: number;
  33806. /**
  33807. * Is this sound currently played.
  33808. */
  33809. isPlaying: boolean;
  33810. /**
  33811. * Is this sound currently paused.
  33812. */
  33813. isPaused: boolean;
  33814. /**
  33815. * Does this sound enables spatial sound.
  33816. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33817. */
  33818. spatialSound: boolean;
  33819. /**
  33820. * Define the reference distance the sound should be heard perfectly.
  33821. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33822. */
  33823. refDistance: number;
  33824. /**
  33825. * Define the roll off factor of spatial sounds.
  33826. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33827. */
  33828. rolloffFactor: number;
  33829. /**
  33830. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  33831. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33832. */
  33833. maxDistance: number;
  33834. /**
  33835. * Define the distance attenuation model the sound will follow.
  33836. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33837. */
  33838. distanceModel: string;
  33839. /**
  33840. * @hidden
  33841. * Back Compat
  33842. **/
  33843. onended: () => any;
  33844. /**
  33845. * Observable event when the current playing sound finishes.
  33846. */
  33847. onEndedObservable: Observable<Sound>;
  33848. private _panningModel;
  33849. private _playbackRate;
  33850. private _streaming;
  33851. private _startTime;
  33852. private _startOffset;
  33853. private _position;
  33854. /** @hidden */
  33855. _positionInEmitterSpace: boolean;
  33856. private _localDirection;
  33857. private _volume;
  33858. private _isReadyToPlay;
  33859. private _isDirectional;
  33860. private _readyToPlayCallback;
  33861. private _audioBuffer;
  33862. private _soundSource;
  33863. private _streamingSource;
  33864. private _soundPanner;
  33865. private _soundGain;
  33866. private _inputAudioNode;
  33867. private _outputAudioNode;
  33868. private _coneInnerAngle;
  33869. private _coneOuterAngle;
  33870. private _coneOuterGain;
  33871. private _scene;
  33872. private _connectedTransformNode;
  33873. private _customAttenuationFunction;
  33874. private _registerFunc;
  33875. private _isOutputConnected;
  33876. private _htmlAudioElement;
  33877. private _urlType;
  33878. /** @hidden */
  33879. static _SceneComponentInitialization: (scene: Scene) => void;
  33880. /**
  33881. * Create a sound and attach it to a scene
  33882. * @param name Name of your sound
  33883. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  33884. * @param scene defines the scene the sound belongs to
  33885. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  33886. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  33887. */
  33888. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  33889. /**
  33890. * Release the sound and its associated resources
  33891. */
  33892. dispose(): void;
  33893. /**
  33894. * Gets if the sounds is ready to be played or not.
  33895. * @returns true if ready, otherwise false
  33896. */
  33897. isReady(): boolean;
  33898. private _soundLoaded;
  33899. /**
  33900. * Sets the data of the sound from an audiobuffer
  33901. * @param audioBuffer The audioBuffer containing the data
  33902. */
  33903. setAudioBuffer(audioBuffer: AudioBuffer): void;
  33904. /**
  33905. * Updates the current sounds options such as maxdistance, loop...
  33906. * @param options A JSON object containing values named as the object properties
  33907. */
  33908. updateOptions(options: any): void;
  33909. private _createSpatialParameters;
  33910. private _updateSpatialParameters;
  33911. /**
  33912. * Switch the panning model to HRTF:
  33913. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  33914. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33915. */
  33916. switchPanningModelToHRTF(): void;
  33917. /**
  33918. * Switch the panning model to Equal Power:
  33919. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  33920. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33921. */
  33922. switchPanningModelToEqualPower(): void;
  33923. private _switchPanningModel;
  33924. /**
  33925. * Connect this sound to a sound track audio node like gain...
  33926. * @param soundTrackAudioNode the sound track audio node to connect to
  33927. */
  33928. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  33929. /**
  33930. * Transform this sound into a directional source
  33931. * @param coneInnerAngle Size of the inner cone in degree
  33932. * @param coneOuterAngle Size of the outer cone in degree
  33933. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  33934. */
  33935. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  33936. /**
  33937. * Gets or sets the inner angle for the directional cone.
  33938. */
  33939. /**
  33940. * Gets or sets the inner angle for the directional cone.
  33941. */
  33942. directionalConeInnerAngle: number;
  33943. /**
  33944. * Gets or sets the outer angle for the directional cone.
  33945. */
  33946. /**
  33947. * Gets or sets the outer angle for the directional cone.
  33948. */
  33949. directionalConeOuterAngle: number;
  33950. /**
  33951. * Sets the position of the emitter if spatial sound is enabled
  33952. * @param newPosition Defines the new posisiton
  33953. */
  33954. setPosition(newPosition: Vector3): void;
  33955. /**
  33956. * Sets the local direction of the emitter if spatial sound is enabled
  33957. * @param newLocalDirection Defines the new local direction
  33958. */
  33959. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  33960. private _updateDirection;
  33961. /** @hidden */
  33962. updateDistanceFromListener(): void;
  33963. /**
  33964. * Sets a new custom attenuation function for the sound.
  33965. * @param callback Defines the function used for the attenuation
  33966. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  33967. */
  33968. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  33969. /**
  33970. * Play the sound
  33971. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  33972. * @param offset (optional) Start the sound setting it at a specific time
  33973. */
  33974. play(time?: number, offset?: number): void;
  33975. private _onended;
  33976. /**
  33977. * Stop the sound
  33978. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  33979. */
  33980. stop(time?: number): void;
  33981. /**
  33982. * Put the sound in pause
  33983. */
  33984. pause(): void;
  33985. /**
  33986. * Sets a dedicated volume for this sounds
  33987. * @param newVolume Define the new volume of the sound
  33988. * @param time Define in how long the sound should be at this value
  33989. */
  33990. setVolume(newVolume: number, time?: number): void;
  33991. /**
  33992. * Set the sound play back rate
  33993. * @param newPlaybackRate Define the playback rate the sound should be played at
  33994. */
  33995. setPlaybackRate(newPlaybackRate: number): void;
  33996. /**
  33997. * Gets the volume of the sound.
  33998. * @returns the volume of the sound
  33999. */
  34000. getVolume(): number;
  34001. /**
  34002. * Attach the sound to a dedicated mesh
  34003. * @param transformNode The transform node to connect the sound with
  34004. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  34005. */
  34006. attachToMesh(transformNode: TransformNode): void;
  34007. /**
  34008. * Detach the sound from the previously attached mesh
  34009. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  34010. */
  34011. detachFromMesh(): void;
  34012. private _onRegisterAfterWorldMatrixUpdate;
  34013. /**
  34014. * Clone the current sound in the scene.
  34015. * @returns the new sound clone
  34016. */
  34017. clone(): Nullable<Sound>;
  34018. /**
  34019. * Gets the current underlying audio buffer containing the data
  34020. * @returns the audio buffer
  34021. */
  34022. getAudioBuffer(): Nullable<AudioBuffer>;
  34023. /**
  34024. * Serializes the Sound in a JSON representation
  34025. * @returns the JSON representation of the sound
  34026. */
  34027. serialize(): any;
  34028. /**
  34029. * Parse a JSON representation of a sound to innstantiate in a given scene
  34030. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  34031. * @param scene Define the scene the new parsed sound should be created in
  34032. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  34033. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  34034. * @returns the newly parsed sound
  34035. */
  34036. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  34037. }
  34038. }
  34039. declare module "babylonjs/Actions/directAudioActions" {
  34040. import { Action } from "babylonjs/Actions/action";
  34041. import { Condition } from "babylonjs/Actions/condition";
  34042. import { Sound } from "babylonjs/Audio/sound";
  34043. /**
  34044. * This defines an action helpful to play a defined sound on a triggered action.
  34045. */
  34046. export class PlaySoundAction extends Action {
  34047. private _sound;
  34048. /**
  34049. * Instantiate the action
  34050. * @param triggerOptions defines the trigger options
  34051. * @param sound defines the sound to play
  34052. * @param condition defines the trigger related conditions
  34053. */
  34054. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  34055. /** @hidden */
  34056. _prepare(): void;
  34057. /**
  34058. * Execute the action and play the sound.
  34059. */
  34060. execute(): void;
  34061. /**
  34062. * Serializes the actions and its related information.
  34063. * @param parent defines the object to serialize in
  34064. * @returns the serialized object
  34065. */
  34066. serialize(parent: any): any;
  34067. }
  34068. /**
  34069. * This defines an action helpful to stop a defined sound on a triggered action.
  34070. */
  34071. export class StopSoundAction extends Action {
  34072. private _sound;
  34073. /**
  34074. * Instantiate the action
  34075. * @param triggerOptions defines the trigger options
  34076. * @param sound defines the sound to stop
  34077. * @param condition defines the trigger related conditions
  34078. */
  34079. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  34080. /** @hidden */
  34081. _prepare(): void;
  34082. /**
  34083. * Execute the action and stop the sound.
  34084. */
  34085. execute(): void;
  34086. /**
  34087. * Serializes the actions and its related information.
  34088. * @param parent defines the object to serialize in
  34089. * @returns the serialized object
  34090. */
  34091. serialize(parent: any): any;
  34092. }
  34093. }
  34094. declare module "babylonjs/Actions/interpolateValueAction" {
  34095. import { Action } from "babylonjs/Actions/action";
  34096. import { Condition } from "babylonjs/Actions/condition";
  34097. import { Observable } from "babylonjs/Misc/observable";
  34098. /**
  34099. * This defines an action responsible to change the value of a property
  34100. * by interpolating between its current value and the newly set one once triggered.
  34101. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  34102. */
  34103. export class InterpolateValueAction extends Action {
  34104. /**
  34105. * Defines the path of the property where the value should be interpolated
  34106. */
  34107. propertyPath: string;
  34108. /**
  34109. * Defines the target value at the end of the interpolation.
  34110. */
  34111. value: any;
  34112. /**
  34113. * Defines the time it will take for the property to interpolate to the value.
  34114. */
  34115. duration: number;
  34116. /**
  34117. * Defines if the other scene animations should be stopped when the action has been triggered
  34118. */
  34119. stopOtherAnimations?: boolean;
  34120. /**
  34121. * Defines a callback raised once the interpolation animation has been done.
  34122. */
  34123. onInterpolationDone?: () => void;
  34124. /**
  34125. * Observable triggered once the interpolation animation has been done.
  34126. */
  34127. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  34128. private _target;
  34129. private _effectiveTarget;
  34130. private _property;
  34131. /**
  34132. * Instantiate the action
  34133. * @param triggerOptions defines the trigger options
  34134. * @param target defines the object containing the value to interpolate
  34135. * @param propertyPath defines the path to the property in the target object
  34136. * @param value defines the target value at the end of the interpolation
  34137. * @param duration deines the time it will take for the property to interpolate to the value.
  34138. * @param condition defines the trigger related conditions
  34139. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  34140. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  34141. */
  34142. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  34143. /** @hidden */
  34144. _prepare(): void;
  34145. /**
  34146. * Execute the action starts the value interpolation.
  34147. */
  34148. execute(): void;
  34149. /**
  34150. * Serializes the actions and its related information.
  34151. * @param parent defines the object to serialize in
  34152. * @returns the serialized object
  34153. */
  34154. serialize(parent: any): any;
  34155. }
  34156. }
  34157. declare module "babylonjs/Actions/index" {
  34158. export * from "babylonjs/Actions/action";
  34159. export * from "babylonjs/Actions/actionEvent";
  34160. export * from "babylonjs/Actions/actionManager";
  34161. export * from "babylonjs/Actions/condition";
  34162. export * from "babylonjs/Actions/directActions";
  34163. export * from "babylonjs/Actions/directAudioActions";
  34164. export * from "babylonjs/Actions/interpolateValueAction";
  34165. }
  34166. declare module "babylonjs/Animations/index" {
  34167. export * from "babylonjs/Animations/animatable";
  34168. export * from "babylonjs/Animations/animation";
  34169. export * from "babylonjs/Animations/animationGroup";
  34170. export * from "babylonjs/Animations/animationPropertiesOverride";
  34171. export * from "babylonjs/Animations/easing";
  34172. export * from "babylonjs/Animations/runtimeAnimation";
  34173. export * from "babylonjs/Animations/animationEvent";
  34174. export * from "babylonjs/Animations/animationGroup";
  34175. export * from "babylonjs/Animations/animationKey";
  34176. export * from "babylonjs/Animations/animationRange";
  34177. }
  34178. declare module "babylonjs/Audio/soundTrack" {
  34179. import { Sound } from "babylonjs/Audio/sound";
  34180. import { Analyser } from "babylonjs/Audio/analyser";
  34181. import { Scene } from "babylonjs/scene";
  34182. /**
  34183. * Options allowed during the creation of a sound track.
  34184. */
  34185. export interface ISoundTrackOptions {
  34186. /**
  34187. * The volume the sound track should take during creation
  34188. */
  34189. volume?: number;
  34190. /**
  34191. * Define if the sound track is the main sound track of the scene
  34192. */
  34193. mainTrack?: boolean;
  34194. }
  34195. /**
  34196. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  34197. * It will be also used in a future release to apply effects on a specific track.
  34198. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  34199. */
  34200. export class SoundTrack {
  34201. /**
  34202. * The unique identifier of the sound track in the scene.
  34203. */
  34204. id: number;
  34205. /**
  34206. * The list of sounds included in the sound track.
  34207. */
  34208. soundCollection: Array<Sound>;
  34209. private _outputAudioNode;
  34210. private _scene;
  34211. private _isMainTrack;
  34212. private _connectedAnalyser;
  34213. private _options;
  34214. private _isInitialized;
  34215. /**
  34216. * Creates a new sound track.
  34217. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  34218. * @param scene Define the scene the sound track belongs to
  34219. * @param options
  34220. */
  34221. constructor(scene: Scene, options?: ISoundTrackOptions);
  34222. private _initializeSoundTrackAudioGraph;
  34223. /**
  34224. * Release the sound track and its associated resources
  34225. */
  34226. dispose(): void;
  34227. /**
  34228. * Adds a sound to this sound track
  34229. * @param sound define the cound to add
  34230. * @ignoreNaming
  34231. */
  34232. AddSound(sound: Sound): void;
  34233. /**
  34234. * Removes a sound to this sound track
  34235. * @param sound define the cound to remove
  34236. * @ignoreNaming
  34237. */
  34238. RemoveSound(sound: Sound): void;
  34239. /**
  34240. * Set a global volume for the full sound track.
  34241. * @param newVolume Define the new volume of the sound track
  34242. */
  34243. setVolume(newVolume: number): void;
  34244. /**
  34245. * Switch the panning model to HRTF:
  34246. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  34247. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34248. */
  34249. switchPanningModelToHRTF(): void;
  34250. /**
  34251. * Switch the panning model to Equal Power:
  34252. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  34253. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34254. */
  34255. switchPanningModelToEqualPower(): void;
  34256. /**
  34257. * Connect the sound track to an audio analyser allowing some amazing
  34258. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  34259. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  34260. * @param analyser The analyser to connect to the engine
  34261. */
  34262. connectToAnalyser(analyser: Analyser): void;
  34263. }
  34264. }
  34265. declare module "babylonjs/Audio/audioSceneComponent" {
  34266. import { Sound } from "babylonjs/Audio/sound";
  34267. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  34268. import { Nullable } from "babylonjs/types";
  34269. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  34270. import { Scene } from "babylonjs/scene";
  34271. import { AbstractScene } from "babylonjs/abstractScene";
  34272. module "babylonjs/abstractScene" {
  34273. interface AbstractScene {
  34274. /**
  34275. * The list of sounds used in the scene.
  34276. */
  34277. sounds: Nullable<Array<Sound>>;
  34278. }
  34279. }
  34280. module "babylonjs/scene" {
  34281. interface Scene {
  34282. /**
  34283. * @hidden
  34284. * Backing field
  34285. */
  34286. _mainSoundTrack: SoundTrack;
  34287. /**
  34288. * The main sound track played by the scene.
  34289. * It cotains your primary collection of sounds.
  34290. */
  34291. mainSoundTrack: SoundTrack;
  34292. /**
  34293. * The list of sound tracks added to the scene
  34294. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34295. */
  34296. soundTracks: Nullable<Array<SoundTrack>>;
  34297. /**
  34298. * Gets a sound using a given name
  34299. * @param name defines the name to search for
  34300. * @return the found sound or null if not found at all.
  34301. */
  34302. getSoundByName(name: string): Nullable<Sound>;
  34303. /**
  34304. * Gets or sets if audio support is enabled
  34305. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34306. */
  34307. audioEnabled: boolean;
  34308. /**
  34309. * Gets or sets if audio will be output to headphones
  34310. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34311. */
  34312. headphone: boolean;
  34313. }
  34314. }
  34315. /**
  34316. * Defines the sound scene component responsible to manage any sounds
  34317. * in a given scene.
  34318. */
  34319. export class AudioSceneComponent implements ISceneSerializableComponent {
  34320. /**
  34321. * The component name helpfull to identify the component in the list of scene components.
  34322. */
  34323. readonly name: string;
  34324. /**
  34325. * The scene the component belongs to.
  34326. */
  34327. scene: Scene;
  34328. private _audioEnabled;
  34329. /**
  34330. * Gets whether audio is enabled or not.
  34331. * Please use related enable/disable method to switch state.
  34332. */
  34333. readonly audioEnabled: boolean;
  34334. private _headphone;
  34335. /**
  34336. * Gets whether audio is outputing to headphone or not.
  34337. * Please use the according Switch methods to change output.
  34338. */
  34339. readonly headphone: boolean;
  34340. /**
  34341. * Creates a new instance of the component for the given scene
  34342. * @param scene Defines the scene to register the component in
  34343. */
  34344. constructor(scene: Scene);
  34345. /**
  34346. * Registers the component in a given scene
  34347. */
  34348. register(): void;
  34349. /**
  34350. * Rebuilds the elements related to this component in case of
  34351. * context lost for instance.
  34352. */
  34353. rebuild(): void;
  34354. /**
  34355. * Serializes the component data to the specified json object
  34356. * @param serializationObject The object to serialize to
  34357. */
  34358. serialize(serializationObject: any): void;
  34359. /**
  34360. * Adds all the element from the container to the scene
  34361. * @param container the container holding the elements
  34362. */
  34363. addFromContainer(container: AbstractScene): void;
  34364. /**
  34365. * Removes all the elements in the container from the scene
  34366. * @param container contains the elements to remove
  34367. */
  34368. removeFromContainer(container: AbstractScene): void;
  34369. /**
  34370. * Disposes the component and the associated ressources.
  34371. */
  34372. dispose(): void;
  34373. /**
  34374. * Disables audio in the associated scene.
  34375. */
  34376. disableAudio(): void;
  34377. /**
  34378. * Enables audio in the associated scene.
  34379. */
  34380. enableAudio(): void;
  34381. /**
  34382. * Switch audio to headphone output.
  34383. */
  34384. switchAudioModeForHeadphones(): void;
  34385. /**
  34386. * Switch audio to normal speakers.
  34387. */
  34388. switchAudioModeForNormalSpeakers(): void;
  34389. private _afterRender;
  34390. }
  34391. }
  34392. declare module "babylonjs/Audio/weightedsound" {
  34393. import { Sound } from "babylonjs/Audio/sound";
  34394. /**
  34395. * Wraps one or more Sound objects and selects one with random weight for playback.
  34396. */
  34397. export class WeightedSound {
  34398. /** When true a Sound will be selected and played when the current playing Sound completes. */
  34399. loop: boolean;
  34400. private _coneInnerAngle;
  34401. private _coneOuterAngle;
  34402. private _volume;
  34403. /** A Sound is currently playing. */
  34404. isPlaying: boolean;
  34405. /** A Sound is currently paused. */
  34406. isPaused: boolean;
  34407. private _sounds;
  34408. private _weights;
  34409. private _currentIndex?;
  34410. /**
  34411. * Creates a new WeightedSound from the list of sounds given.
  34412. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  34413. * @param sounds Array of Sounds that will be selected from.
  34414. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  34415. */
  34416. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  34417. /**
  34418. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  34419. */
  34420. /**
  34421. * The size of cone in degress for a directional sound in which there will be no attenuation.
  34422. */
  34423. directionalConeInnerAngle: number;
  34424. /**
  34425. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  34426. * Listener angles between innerAngle and outerAngle will falloff linearly.
  34427. */
  34428. /**
  34429. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  34430. * Listener angles between innerAngle and outerAngle will falloff linearly.
  34431. */
  34432. directionalConeOuterAngle: number;
  34433. /**
  34434. * Playback volume.
  34435. */
  34436. /**
  34437. * Playback volume.
  34438. */
  34439. volume: number;
  34440. private _onended;
  34441. /**
  34442. * Suspend playback
  34443. */
  34444. pause(): void;
  34445. /**
  34446. * Stop playback
  34447. */
  34448. stop(): void;
  34449. /**
  34450. * Start playback.
  34451. * @param startOffset Position the clip head at a specific time in seconds.
  34452. */
  34453. play(startOffset?: number): void;
  34454. }
  34455. }
  34456. declare module "babylonjs/Audio/index" {
  34457. export * from "babylonjs/Audio/analyser";
  34458. export * from "babylonjs/Audio/audioEngine";
  34459. export * from "babylonjs/Audio/audioSceneComponent";
  34460. export * from "babylonjs/Audio/sound";
  34461. export * from "babylonjs/Audio/soundTrack";
  34462. export * from "babylonjs/Audio/weightedsound";
  34463. }
  34464. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  34465. import { Behavior } from "babylonjs/Behaviors/behavior";
  34466. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  34467. import { BackEase } from "babylonjs/Animations/easing";
  34468. /**
  34469. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  34470. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  34471. */
  34472. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  34473. /**
  34474. * Gets the name of the behavior.
  34475. */
  34476. readonly name: string;
  34477. /**
  34478. * The easing function used by animations
  34479. */
  34480. static EasingFunction: BackEase;
  34481. /**
  34482. * The easing mode used by animations
  34483. */
  34484. static EasingMode: number;
  34485. /**
  34486. * The duration of the animation, in milliseconds
  34487. */
  34488. transitionDuration: number;
  34489. /**
  34490. * Length of the distance animated by the transition when lower radius is reached
  34491. */
  34492. lowerRadiusTransitionRange: number;
  34493. /**
  34494. * Length of the distance animated by the transition when upper radius is reached
  34495. */
  34496. upperRadiusTransitionRange: number;
  34497. private _autoTransitionRange;
  34498. /**
  34499. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  34500. */
  34501. /**
  34502. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  34503. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  34504. */
  34505. autoTransitionRange: boolean;
  34506. private _attachedCamera;
  34507. private _onAfterCheckInputsObserver;
  34508. private _onMeshTargetChangedObserver;
  34509. /**
  34510. * Initializes the behavior.
  34511. */
  34512. init(): void;
  34513. /**
  34514. * Attaches the behavior to its arc rotate camera.
  34515. * @param camera Defines the camera to attach the behavior to
  34516. */
  34517. attach(camera: ArcRotateCamera): void;
  34518. /**
  34519. * Detaches the behavior from its current arc rotate camera.
  34520. */
  34521. detach(): void;
  34522. private _radiusIsAnimating;
  34523. private _radiusBounceTransition;
  34524. private _animatables;
  34525. private _cachedWheelPrecision;
  34526. /**
  34527. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  34528. * @param radiusLimit The limit to check against.
  34529. * @return Bool to indicate if at limit.
  34530. */
  34531. private _isRadiusAtLimit;
  34532. /**
  34533. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  34534. * @param radiusDelta The delta by which to animate to. Can be negative.
  34535. */
  34536. private _applyBoundRadiusAnimation;
  34537. /**
  34538. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  34539. */
  34540. protected _clearAnimationLocks(): void;
  34541. /**
  34542. * Stops and removes all animations that have been applied to the camera
  34543. */
  34544. stopAllAnimations(): void;
  34545. }
  34546. }
  34547. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  34548. import { Behavior } from "babylonjs/Behaviors/behavior";
  34549. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  34550. import { ExponentialEase } from "babylonjs/Animations/easing";
  34551. import { Nullable } from "babylonjs/types";
  34552. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  34553. import { Vector3 } from "babylonjs/Maths/math";
  34554. /**
  34555. * 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.
  34556. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  34557. */
  34558. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  34559. /**
  34560. * Gets the name of the behavior.
  34561. */
  34562. readonly name: string;
  34563. private _mode;
  34564. private _radiusScale;
  34565. private _positionScale;
  34566. private _defaultElevation;
  34567. private _elevationReturnTime;
  34568. private _elevationReturnWaitTime;
  34569. private _zoomStopsAnimation;
  34570. private _framingTime;
  34571. /**
  34572. * The easing function used by animations
  34573. */
  34574. static EasingFunction: ExponentialEase;
  34575. /**
  34576. * The easing mode used by animations
  34577. */
  34578. static EasingMode: number;
  34579. /**
  34580. * Sets the current mode used by the behavior
  34581. */
  34582. /**
  34583. * Gets current mode used by the behavior.
  34584. */
  34585. mode: number;
  34586. /**
  34587. * Sets the scale applied to the radius (1 by default)
  34588. */
  34589. /**
  34590. * Gets the scale applied to the radius
  34591. */
  34592. radiusScale: number;
  34593. /**
  34594. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  34595. */
  34596. /**
  34597. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  34598. */
  34599. positionScale: number;
  34600. /**
  34601. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  34602. * behaviour is triggered, in radians.
  34603. */
  34604. /**
  34605. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  34606. * behaviour is triggered, in radians.
  34607. */
  34608. defaultElevation: number;
  34609. /**
  34610. * Sets the time (in milliseconds) taken to return to the default beta position.
  34611. * Negative value indicates camera should not return to default.
  34612. */
  34613. /**
  34614. * Gets the time (in milliseconds) taken to return to the default beta position.
  34615. * Negative value indicates camera should not return to default.
  34616. */
  34617. elevationReturnTime: number;
  34618. /**
  34619. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  34620. */
  34621. /**
  34622. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  34623. */
  34624. elevationReturnWaitTime: number;
  34625. /**
  34626. * Sets the flag that indicates if user zooming should stop animation.
  34627. */
  34628. /**
  34629. * Gets the flag that indicates if user zooming should stop animation.
  34630. */
  34631. zoomStopsAnimation: boolean;
  34632. /**
  34633. * Sets the transition time when framing the mesh, in milliseconds
  34634. */
  34635. /**
  34636. * Gets the transition time when framing the mesh, in milliseconds
  34637. */
  34638. framingTime: number;
  34639. /**
  34640. * Define if the behavior should automatically change the configured
  34641. * camera limits and sensibilities.
  34642. */
  34643. autoCorrectCameraLimitsAndSensibility: boolean;
  34644. private _onPrePointerObservableObserver;
  34645. private _onAfterCheckInputsObserver;
  34646. private _onMeshTargetChangedObserver;
  34647. private _attachedCamera;
  34648. private _isPointerDown;
  34649. private _lastInteractionTime;
  34650. /**
  34651. * Initializes the behavior.
  34652. */
  34653. init(): void;
  34654. /**
  34655. * Attaches the behavior to its arc rotate camera.
  34656. * @param camera Defines the camera to attach the behavior to
  34657. */
  34658. attach(camera: ArcRotateCamera): void;
  34659. /**
  34660. * Detaches the behavior from its current arc rotate camera.
  34661. */
  34662. detach(): void;
  34663. private _animatables;
  34664. private _betaIsAnimating;
  34665. private _betaTransition;
  34666. private _radiusTransition;
  34667. private _vectorTransition;
  34668. /**
  34669. * Targets the given mesh and updates zoom level accordingly.
  34670. * @param mesh The mesh to target.
  34671. * @param radius Optional. If a cached radius position already exists, overrides default.
  34672. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  34673. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34674. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34675. */
  34676. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34677. /**
  34678. * Targets the given mesh with its children and updates zoom level accordingly.
  34679. * @param mesh The mesh to target.
  34680. * @param radius Optional. If a cached radius position already exists, overrides default.
  34681. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  34682. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34683. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34684. */
  34685. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34686. /**
  34687. * Targets the given meshes with their children and updates zoom level accordingly.
  34688. * @param meshes The mesh to target.
  34689. * @param radius Optional. If a cached radius position already exists, overrides default.
  34690. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  34691. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34692. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34693. */
  34694. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34695. /**
  34696. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  34697. * @param minimumWorld Determines the smaller position of the bounding box extend
  34698. * @param maximumWorld Determines the bigger position of the bounding box extend
  34699. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34700. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34701. */
  34702. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34703. /**
  34704. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  34705. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  34706. * frustum width.
  34707. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  34708. * to fully enclose the mesh in the viewing frustum.
  34709. */
  34710. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  34711. /**
  34712. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  34713. * is automatically returned to its default position (expected to be above ground plane).
  34714. */
  34715. private _maintainCameraAboveGround;
  34716. /**
  34717. * Returns the frustum slope based on the canvas ratio and camera FOV
  34718. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  34719. */
  34720. private _getFrustumSlope;
  34721. /**
  34722. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  34723. */
  34724. private _clearAnimationLocks;
  34725. /**
  34726. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  34727. */
  34728. private _applyUserInteraction;
  34729. /**
  34730. * Stops and removes all animations that have been applied to the camera
  34731. */
  34732. stopAllAnimations(): void;
  34733. /**
  34734. * Gets a value indicating if the user is moving the camera
  34735. */
  34736. readonly isUserIsMoving: boolean;
  34737. /**
  34738. * The camera can move all the way towards the mesh.
  34739. */
  34740. static IgnoreBoundsSizeMode: number;
  34741. /**
  34742. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  34743. */
  34744. static FitFrustumSidesMode: number;
  34745. }
  34746. }
  34747. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  34748. import { Nullable } from "babylonjs/types";
  34749. import { Camera } from "babylonjs/Cameras/camera";
  34750. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  34751. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  34752. /**
  34753. * Base class for Camera Pointer Inputs.
  34754. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  34755. * for example usage.
  34756. */
  34757. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  34758. /**
  34759. * Defines the camera the input is attached to.
  34760. */
  34761. abstract camera: Camera;
  34762. /**
  34763. * Whether keyboard modifier keys are pressed at time of last mouse event.
  34764. */
  34765. protected _altKey: boolean;
  34766. protected _ctrlKey: boolean;
  34767. protected _metaKey: boolean;
  34768. protected _shiftKey: boolean;
  34769. /**
  34770. * Which mouse buttons were pressed at time of last mouse event.
  34771. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  34772. */
  34773. protected _buttonsPressed: number;
  34774. /**
  34775. * Defines the buttons associated with the input to handle camera move.
  34776. */
  34777. buttons: number[];
  34778. /**
  34779. * Attach the input controls to a specific dom element to get the input from.
  34780. * @param element Defines the element the controls should be listened from
  34781. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  34782. */
  34783. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  34784. /**
  34785. * Detach the current controls from the specified dom element.
  34786. * @param element Defines the element to stop listening the inputs from
  34787. */
  34788. detachControl(element: Nullable<HTMLElement>): void;
  34789. /**
  34790. * Gets the class name of the current input.
  34791. * @returns the class name
  34792. */
  34793. getClassName(): string;
  34794. /**
  34795. * Get the friendly name associated with the input class.
  34796. * @returns the input friendly name
  34797. */
  34798. getSimpleName(): string;
  34799. /**
  34800. * Called on pointer POINTERDOUBLETAP event.
  34801. * Override this method to provide functionality on POINTERDOUBLETAP event.
  34802. */
  34803. protected onDoubleTap(type: string): void;
  34804. /**
  34805. * Called on pointer POINTERMOVE event if only a single touch is active.
  34806. * Override this method to provide functionality.
  34807. */
  34808. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  34809. /**
  34810. * Called on pointer POINTERMOVE event if multiple touches are active.
  34811. * Override this method to provide functionality.
  34812. */
  34813. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  34814. /**
  34815. * Called on JS contextmenu event.
  34816. * Override this method to provide functionality.
  34817. */
  34818. protected onContextMenu(evt: PointerEvent): void;
  34819. /**
  34820. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  34821. * press.
  34822. * Override this method to provide functionality.
  34823. */
  34824. protected onButtonDown(evt: PointerEvent, buttonCount: number): void;
  34825. /**
  34826. * Called each time a new POINTERUP event occurs. Ie, for each button
  34827. * release.
  34828. * Override this method to provide functionality.
  34829. */
  34830. protected onButtonUp(evt: PointerEvent): void;
  34831. /**
  34832. * Called when window becomes inactive.
  34833. * Override this method to provide functionality.
  34834. */
  34835. protected onLostFocus(): void;
  34836. private _pointerInput;
  34837. private _observer;
  34838. private _onLostFocus;
  34839. }
  34840. }
  34841. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  34842. import { Nullable } from "babylonjs/types";
  34843. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  34844. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  34845. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  34846. /**
  34847. * Manage the pointers inputs to control an arc rotate camera.
  34848. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34849. */
  34850. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  34851. /**
  34852. * Defines the camera the input is attached to.
  34853. */
  34854. camera: ArcRotateCamera;
  34855. /**
  34856. * Gets the class name of the current input.
  34857. * @returns the class name
  34858. */
  34859. getClassName(): string;
  34860. /**
  34861. * Defines the buttons associated with the input to handle camera move.
  34862. */
  34863. buttons: number[];
  34864. /**
  34865. * Defines the pointer angular sensibility along the X axis or how fast is
  34866. * the camera rotating.
  34867. */
  34868. angularSensibilityX: number;
  34869. /**
  34870. * Defines the pointer angular sensibility along the Y axis or how fast is
  34871. * the camera rotating.
  34872. */
  34873. angularSensibilityY: number;
  34874. /**
  34875. * Defines the pointer pinch precision or how fast is the camera zooming.
  34876. */
  34877. pinchPrecision: number;
  34878. /**
  34879. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  34880. * from 0.
  34881. * It defines the percentage of current camera.radius to use as delta when
  34882. * pinch zoom is used.
  34883. */
  34884. pinchDeltaPercentage: number;
  34885. /**
  34886. * Defines the pointer panning sensibility or how fast is the camera moving.
  34887. */
  34888. panningSensibility: number;
  34889. /**
  34890. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  34891. */
  34892. multiTouchPanning: boolean;
  34893. /**
  34894. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  34895. * zoom (pinch) through multitouch.
  34896. */
  34897. multiTouchPanAndZoom: boolean;
  34898. /**
  34899. * Revers pinch action direction.
  34900. */
  34901. pinchInwards: boolean;
  34902. private _isPanClick;
  34903. private _twoFingerActivityCount;
  34904. private _isPinching;
  34905. /**
  34906. * Called on pointer POINTERMOVE event if only a single touch is active.
  34907. */
  34908. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  34909. /**
  34910. * Called on pointer POINTERDOUBLETAP event.
  34911. */
  34912. protected onDoubleTap(type: string): void;
  34913. /**
  34914. * Called on pointer POINTERMOVE event if multiple touches are active.
  34915. */
  34916. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  34917. /**
  34918. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  34919. * press.
  34920. */
  34921. protected onButtonDown(evt: PointerEvent, buttonCount: number): void;
  34922. /**
  34923. * Called each time a new POINTERUP event occurs. Ie, for each button
  34924. * release.
  34925. */
  34926. protected onButtonUp(evt: PointerEvent): void;
  34927. /**
  34928. * Called when window becomes inactive.
  34929. */
  34930. protected onLostFocus(): void;
  34931. }
  34932. }
  34933. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  34934. import { Nullable } from "babylonjs/types";
  34935. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  34936. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  34937. /**
  34938. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  34939. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34940. */
  34941. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  34942. /**
  34943. * Defines the camera the input is attached to.
  34944. */
  34945. camera: ArcRotateCamera;
  34946. /**
  34947. * Defines the list of key codes associated with the up action (increase alpha)
  34948. */
  34949. keysUp: number[];
  34950. /**
  34951. * Defines the list of key codes associated with the down action (decrease alpha)
  34952. */
  34953. keysDown: number[];
  34954. /**
  34955. * Defines the list of key codes associated with the left action (increase beta)
  34956. */
  34957. keysLeft: number[];
  34958. /**
  34959. * Defines the list of key codes associated with the right action (decrease beta)
  34960. */
  34961. keysRight: number[];
  34962. /**
  34963. * Defines the list of key codes associated with the reset action.
  34964. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  34965. */
  34966. keysReset: number[];
  34967. /**
  34968. * Defines the panning sensibility of the inputs.
  34969. * (How fast is the camera paning)
  34970. */
  34971. panningSensibility: number;
  34972. /**
  34973. * Defines the zooming sensibility of the inputs.
  34974. * (How fast is the camera zooming)
  34975. */
  34976. zoomingSensibility: number;
  34977. /**
  34978. * Defines wether maintaining the alt key down switch the movement mode from
  34979. * orientation to zoom.
  34980. */
  34981. useAltToZoom: boolean;
  34982. /**
  34983. * Rotation speed of the camera
  34984. */
  34985. angularSpeed: number;
  34986. private _keys;
  34987. private _ctrlPressed;
  34988. private _altPressed;
  34989. private _onCanvasBlurObserver;
  34990. private _onKeyboardObserver;
  34991. private _engine;
  34992. private _scene;
  34993. /**
  34994. * Attach the input controls to a specific dom element to get the input from.
  34995. * @param element Defines the element the controls should be listened from
  34996. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  34997. */
  34998. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  34999. /**
  35000. * Detach the current controls from the specified dom element.
  35001. * @param element Defines the element to stop listening the inputs from
  35002. */
  35003. detachControl(element: Nullable<HTMLElement>): void;
  35004. /**
  35005. * Update the current camera state depending on the inputs that have been used this frame.
  35006. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  35007. */
  35008. checkInputs(): void;
  35009. /**
  35010. * Gets the class name of the current intput.
  35011. * @returns the class name
  35012. */
  35013. getClassName(): string;
  35014. /**
  35015. * Get the friendly name associated with the input class.
  35016. * @returns the input friendly name
  35017. */
  35018. getSimpleName(): string;
  35019. }
  35020. }
  35021. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  35022. import { Nullable } from "babylonjs/types";
  35023. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35024. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  35025. /**
  35026. * Manage the mouse wheel inputs to control an arc rotate camera.
  35027. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35028. */
  35029. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  35030. /**
  35031. * Defines the camera the input is attached to.
  35032. */
  35033. camera: ArcRotateCamera;
  35034. /**
  35035. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  35036. */
  35037. wheelPrecision: number;
  35038. /**
  35039. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  35040. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  35041. */
  35042. wheelDeltaPercentage: number;
  35043. private _wheel;
  35044. private _observer;
  35045. /**
  35046. * Attach the input controls to a specific dom element to get the input from.
  35047. * @param element Defines the element the controls should be listened from
  35048. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35049. */
  35050. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35051. /**
  35052. * Detach the current controls from the specified dom element.
  35053. * @param element Defines the element to stop listening the inputs from
  35054. */
  35055. detachControl(element: Nullable<HTMLElement>): void;
  35056. /**
  35057. * Gets the class name of the current intput.
  35058. * @returns the class name
  35059. */
  35060. getClassName(): string;
  35061. /**
  35062. * Get the friendly name associated with the input class.
  35063. * @returns the input friendly name
  35064. */
  35065. getSimpleName(): string;
  35066. }
  35067. }
  35068. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  35069. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35070. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  35071. /**
  35072. * Default Inputs manager for the ArcRotateCamera.
  35073. * It groups all the default supported inputs for ease of use.
  35074. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35075. */
  35076. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  35077. /**
  35078. * Instantiates a new ArcRotateCameraInputsManager.
  35079. * @param camera Defines the camera the inputs belong to
  35080. */
  35081. constructor(camera: ArcRotateCamera);
  35082. /**
  35083. * Add mouse wheel input support to the input manager.
  35084. * @returns the current input manager
  35085. */
  35086. addMouseWheel(): ArcRotateCameraInputsManager;
  35087. /**
  35088. * Add pointers input support to the input manager.
  35089. * @returns the current input manager
  35090. */
  35091. addPointers(): ArcRotateCameraInputsManager;
  35092. /**
  35093. * Add keyboard input support to the input manager.
  35094. * @returns the current input manager
  35095. */
  35096. addKeyboard(): ArcRotateCameraInputsManager;
  35097. }
  35098. }
  35099. declare module "babylonjs/Cameras/arcRotateCamera" {
  35100. import { Observable } from "babylonjs/Misc/observable";
  35101. import { Nullable } from "babylonjs/types";
  35102. import { Scene } from "babylonjs/scene";
  35103. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math";
  35104. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35105. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  35106. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  35107. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  35108. import { Camera } from "babylonjs/Cameras/camera";
  35109. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  35110. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  35111. import { Collider } from "babylonjs/Collisions/collider";
  35112. /**
  35113. * This represents an orbital type of camera.
  35114. *
  35115. * 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.
  35116. * 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.
  35117. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  35118. */
  35119. export class ArcRotateCamera extends TargetCamera {
  35120. /**
  35121. * Defines the rotation angle of the camera along the longitudinal axis.
  35122. */
  35123. alpha: number;
  35124. /**
  35125. * Defines the rotation angle of the camera along the latitudinal axis.
  35126. */
  35127. beta: number;
  35128. /**
  35129. * Defines the radius of the camera from it s target point.
  35130. */
  35131. radius: number;
  35132. protected _target: Vector3;
  35133. protected _targetHost: Nullable<AbstractMesh>;
  35134. /**
  35135. * Defines the target point of the camera.
  35136. * The camera looks towards it form the radius distance.
  35137. */
  35138. target: Vector3;
  35139. /**
  35140. * Define the current local position of the camera in the scene
  35141. */
  35142. position: Vector3;
  35143. /**
  35144. * Current inertia value on the longitudinal axis.
  35145. * The bigger this number the longer it will take for the camera to stop.
  35146. */
  35147. inertialAlphaOffset: number;
  35148. /**
  35149. * Current inertia value on the latitudinal axis.
  35150. * The bigger this number the longer it will take for the camera to stop.
  35151. */
  35152. inertialBetaOffset: number;
  35153. /**
  35154. * Current inertia value on the radius axis.
  35155. * The bigger this number the longer it will take for the camera to stop.
  35156. */
  35157. inertialRadiusOffset: number;
  35158. /**
  35159. * Minimum allowed angle on the longitudinal axis.
  35160. * This can help limiting how the Camera is able to move in the scene.
  35161. */
  35162. lowerAlphaLimit: Nullable<number>;
  35163. /**
  35164. * Maximum allowed angle on the longitudinal axis.
  35165. * This can help limiting how the Camera is able to move in the scene.
  35166. */
  35167. upperAlphaLimit: Nullable<number>;
  35168. /**
  35169. * Minimum allowed angle on the latitudinal axis.
  35170. * This can help limiting how the Camera is able to move in the scene.
  35171. */
  35172. lowerBetaLimit: number;
  35173. /**
  35174. * Maximum allowed angle on the latitudinal axis.
  35175. * This can help limiting how the Camera is able to move in the scene.
  35176. */
  35177. upperBetaLimit: number;
  35178. /**
  35179. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  35180. * This can help limiting how the Camera is able to move in the scene.
  35181. */
  35182. lowerRadiusLimit: Nullable<number>;
  35183. /**
  35184. * Maximum allowed distance of the camera to the target (The camera can not get further).
  35185. * This can help limiting how the Camera is able to move in the scene.
  35186. */
  35187. upperRadiusLimit: Nullable<number>;
  35188. /**
  35189. * Defines the current inertia value used during panning of the camera along the X axis.
  35190. */
  35191. inertialPanningX: number;
  35192. /**
  35193. * Defines the current inertia value used during panning of the camera along the Y axis.
  35194. */
  35195. inertialPanningY: number;
  35196. /**
  35197. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  35198. * Basically if your fingers moves away from more than this distance you will be considered
  35199. * in pinch mode.
  35200. */
  35201. pinchToPanMaxDistance: number;
  35202. /**
  35203. * Defines the maximum distance the camera can pan.
  35204. * This could help keeping the cammera always in your scene.
  35205. */
  35206. panningDistanceLimit: Nullable<number>;
  35207. /**
  35208. * Defines the target of the camera before paning.
  35209. */
  35210. panningOriginTarget: Vector3;
  35211. /**
  35212. * Defines the value of the inertia used during panning.
  35213. * 0 would mean stop inertia and one would mean no decelleration at all.
  35214. */
  35215. panningInertia: number;
  35216. /**
  35217. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  35218. */
  35219. angularSensibilityX: number;
  35220. /**
  35221. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  35222. */
  35223. angularSensibilityY: number;
  35224. /**
  35225. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  35226. */
  35227. pinchPrecision: number;
  35228. /**
  35229. * Gets or Set the pointer pinch 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. pinchDeltaPercentage: number;
  35234. /**
  35235. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  35236. */
  35237. panningSensibility: number;
  35238. /**
  35239. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  35240. */
  35241. keysUp: number[];
  35242. /**
  35243. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  35244. */
  35245. keysDown: number[];
  35246. /**
  35247. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  35248. */
  35249. keysLeft: number[];
  35250. /**
  35251. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  35252. */
  35253. keysRight: number[];
  35254. /**
  35255. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  35256. */
  35257. wheelPrecision: number;
  35258. /**
  35259. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  35260. * It will be used instead of pinchDeltaPrecision if different from 0.
  35261. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  35262. */
  35263. wheelDeltaPercentage: number;
  35264. /**
  35265. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  35266. */
  35267. zoomOnFactor: number;
  35268. /**
  35269. * Defines a screen offset for the camera position.
  35270. */
  35271. targetScreenOffset: Vector2;
  35272. /**
  35273. * Allows the camera to be completely reversed.
  35274. * If false the camera can not arrive upside down.
  35275. */
  35276. allowUpsideDown: boolean;
  35277. /**
  35278. * Define if double tap/click is used to restore the previously saved state of the camera.
  35279. */
  35280. useInputToRestoreState: boolean;
  35281. /** @hidden */
  35282. _viewMatrix: Matrix;
  35283. /** @hidden */
  35284. _useCtrlForPanning: boolean;
  35285. /** @hidden */
  35286. _panningMouseButton: number;
  35287. /**
  35288. * Defines the input associated to the camera.
  35289. */
  35290. inputs: ArcRotateCameraInputsManager;
  35291. /** @hidden */
  35292. _reset: () => void;
  35293. /**
  35294. * Defines the allowed panning axis.
  35295. */
  35296. panningAxis: Vector3;
  35297. protected _localDirection: Vector3;
  35298. protected _transformedDirection: Vector3;
  35299. private _bouncingBehavior;
  35300. /**
  35301. * Gets the bouncing behavior of the camera if it has been enabled.
  35302. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35303. */
  35304. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  35305. /**
  35306. * Defines if the bouncing behavior of the camera is enabled on the camera.
  35307. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35308. */
  35309. useBouncingBehavior: boolean;
  35310. private _framingBehavior;
  35311. /**
  35312. * Gets the framing behavior of the camera if it has been enabled.
  35313. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35314. */
  35315. readonly framingBehavior: Nullable<FramingBehavior>;
  35316. /**
  35317. * Defines if the framing behavior of the camera is enabled on the camera.
  35318. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35319. */
  35320. useFramingBehavior: boolean;
  35321. private _autoRotationBehavior;
  35322. /**
  35323. * Gets the auto rotation behavior of the camera if it has been enabled.
  35324. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35325. */
  35326. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  35327. /**
  35328. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  35329. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35330. */
  35331. useAutoRotationBehavior: boolean;
  35332. /**
  35333. * Observable triggered when the mesh target has been changed on the camera.
  35334. */
  35335. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  35336. /**
  35337. * Event raised when the camera is colliding with a mesh.
  35338. */
  35339. onCollide: (collidedMesh: AbstractMesh) => void;
  35340. /**
  35341. * Defines whether the camera should check collision with the objects oh the scene.
  35342. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  35343. */
  35344. checkCollisions: boolean;
  35345. /**
  35346. * Defines the collision radius of the camera.
  35347. * This simulates a sphere around the camera.
  35348. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  35349. */
  35350. collisionRadius: Vector3;
  35351. protected _collider: Collider;
  35352. protected _previousPosition: Vector3;
  35353. protected _collisionVelocity: Vector3;
  35354. protected _newPosition: Vector3;
  35355. protected _previousAlpha: number;
  35356. protected _previousBeta: number;
  35357. protected _previousRadius: number;
  35358. protected _collisionTriggered: boolean;
  35359. protected _targetBoundingCenter: Nullable<Vector3>;
  35360. private _computationVector;
  35361. private _tempAxisVector;
  35362. private _tempAxisRotationMatrix;
  35363. /**
  35364. * Instantiates a new ArcRotateCamera in a given scene
  35365. * @param name Defines the name of the camera
  35366. * @param alpha Defines the camera rotation along the logitudinal axis
  35367. * @param beta Defines the camera rotation along the latitudinal axis
  35368. * @param radius Defines the camera distance from its target
  35369. * @param target Defines the camera target
  35370. * @param scene Defines the scene the camera belongs to
  35371. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  35372. */
  35373. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  35374. /** @hidden */
  35375. _initCache(): void;
  35376. /** @hidden */
  35377. _updateCache(ignoreParentClass?: boolean): void;
  35378. protected _getTargetPosition(): Vector3;
  35379. private _storedAlpha;
  35380. private _storedBeta;
  35381. private _storedRadius;
  35382. private _storedTarget;
  35383. /**
  35384. * Stores the current state of the camera (alpha, beta, radius and target)
  35385. * @returns the camera itself
  35386. */
  35387. storeState(): Camera;
  35388. /**
  35389. * @hidden
  35390. * Restored camera state. You must call storeState() first
  35391. */
  35392. _restoreStateValues(): boolean;
  35393. /** @hidden */
  35394. _isSynchronizedViewMatrix(): boolean;
  35395. /**
  35396. * Attached controls to the current camera.
  35397. * @param element Defines the element the controls should be listened from
  35398. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35399. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  35400. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  35401. */
  35402. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  35403. /**
  35404. * Detach the current controls from the camera.
  35405. * The camera will stop reacting to inputs.
  35406. * @param element Defines the element to stop listening the inputs from
  35407. */
  35408. detachControl(element: HTMLElement): void;
  35409. /** @hidden */
  35410. _checkInputs(): void;
  35411. protected _checkLimits(): void;
  35412. /**
  35413. * Rebuilds angles (alpha, beta) and radius from the give position and target
  35414. * @param updateView defines a boolean forcing the camera to update its position with a view matrix computation first (default is true)
  35415. */
  35416. rebuildAnglesAndRadius(updateView?: boolean): void;
  35417. /**
  35418. * Use a position to define the current camera related information like aplha, beta and radius
  35419. * @param position Defines the position to set the camera at
  35420. */
  35421. setPosition(position: Vector3): void;
  35422. /**
  35423. * Defines the target the camera should look at.
  35424. * This will automatically adapt alpha beta and radius to fit within the new target.
  35425. * @param target Defines the new target as a Vector or a mesh
  35426. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  35427. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  35428. */
  35429. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  35430. /** @hidden */
  35431. _getViewMatrix(): Matrix;
  35432. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  35433. /**
  35434. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  35435. * @param meshes Defines the mesh to zoom on
  35436. * @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)
  35437. */
  35438. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  35439. /**
  35440. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  35441. * The target will be changed but the radius
  35442. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  35443. * @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)
  35444. */
  35445. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  35446. min: Vector3;
  35447. max: Vector3;
  35448. distance: number;
  35449. }, doNotUpdateMaxZ?: boolean): void;
  35450. /**
  35451. * @override
  35452. * Override Camera.createRigCamera
  35453. */
  35454. createRigCamera(name: string, cameraIndex: number): Camera;
  35455. /**
  35456. * @hidden
  35457. * @override
  35458. * Override Camera._updateRigCameras
  35459. */
  35460. _updateRigCameras(): void;
  35461. /**
  35462. * Destroy the camera and release the current resources hold by it.
  35463. */
  35464. dispose(): void;
  35465. /**
  35466. * Gets the current object class name.
  35467. * @return the class name
  35468. */
  35469. getClassName(): string;
  35470. }
  35471. }
  35472. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  35473. import { Behavior } from "babylonjs/Behaviors/behavior";
  35474. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35475. /**
  35476. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  35477. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35478. */
  35479. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  35480. /**
  35481. * Gets the name of the behavior.
  35482. */
  35483. readonly name: string;
  35484. private _zoomStopsAnimation;
  35485. private _idleRotationSpeed;
  35486. private _idleRotationWaitTime;
  35487. private _idleRotationSpinupTime;
  35488. /**
  35489. * Sets the flag that indicates if user zooming should stop animation.
  35490. */
  35491. /**
  35492. * Gets the flag that indicates if user zooming should stop animation.
  35493. */
  35494. zoomStopsAnimation: boolean;
  35495. /**
  35496. * Sets the default speed at which the camera rotates around the model.
  35497. */
  35498. /**
  35499. * Gets the default speed at which the camera rotates around the model.
  35500. */
  35501. idleRotationSpeed: number;
  35502. /**
  35503. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  35504. */
  35505. /**
  35506. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  35507. */
  35508. idleRotationWaitTime: number;
  35509. /**
  35510. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  35511. */
  35512. /**
  35513. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  35514. */
  35515. idleRotationSpinupTime: number;
  35516. /**
  35517. * Gets a value indicating if the camera is currently rotating because of this behavior
  35518. */
  35519. readonly rotationInProgress: boolean;
  35520. private _onPrePointerObservableObserver;
  35521. private _onAfterCheckInputsObserver;
  35522. private _attachedCamera;
  35523. private _isPointerDown;
  35524. private _lastFrameTime;
  35525. private _lastInteractionTime;
  35526. private _cameraRotationSpeed;
  35527. /**
  35528. * Initializes the behavior.
  35529. */
  35530. init(): void;
  35531. /**
  35532. * Attaches the behavior to its arc rotate camera.
  35533. * @param camera Defines the camera to attach the behavior to
  35534. */
  35535. attach(camera: ArcRotateCamera): void;
  35536. /**
  35537. * Detaches the behavior from its current arc rotate camera.
  35538. */
  35539. detach(): void;
  35540. /**
  35541. * Returns true if user is scrolling.
  35542. * @return true if user is scrolling.
  35543. */
  35544. private _userIsZooming;
  35545. private _lastFrameRadius;
  35546. private _shouldAnimationStopForInteraction;
  35547. /**
  35548. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  35549. */
  35550. private _applyUserInteraction;
  35551. private _userIsMoving;
  35552. }
  35553. }
  35554. declare module "babylonjs/Behaviors/Cameras/index" {
  35555. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  35556. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  35557. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  35558. }
  35559. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  35560. import { Mesh } from "babylonjs/Meshes/mesh";
  35561. import { TransformNode } from "babylonjs/Meshes/transformNode";
  35562. import { Behavior } from "babylonjs/Behaviors/behavior";
  35563. /**
  35564. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  35565. */
  35566. export class AttachToBoxBehavior implements Behavior<Mesh> {
  35567. private ui;
  35568. /**
  35569. * The name of the behavior
  35570. */
  35571. name: string;
  35572. /**
  35573. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  35574. */
  35575. distanceAwayFromFace: number;
  35576. /**
  35577. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  35578. */
  35579. distanceAwayFromBottomOfFace: number;
  35580. private _faceVectors;
  35581. private _target;
  35582. private _scene;
  35583. private _onRenderObserver;
  35584. private _tmpMatrix;
  35585. private _tmpVector;
  35586. /**
  35587. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  35588. * @param ui The transform node that should be attched to the mesh
  35589. */
  35590. constructor(ui: TransformNode);
  35591. /**
  35592. * Initializes the behavior
  35593. */
  35594. init(): void;
  35595. private _closestFace;
  35596. private _zeroVector;
  35597. private _lookAtTmpMatrix;
  35598. private _lookAtToRef;
  35599. /**
  35600. * Attaches the AttachToBoxBehavior to the passed in mesh
  35601. * @param target The mesh that the specified node will be attached to
  35602. */
  35603. attach(target: Mesh): void;
  35604. /**
  35605. * Detaches the behavior from the mesh
  35606. */
  35607. detach(): void;
  35608. }
  35609. }
  35610. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  35611. import { Behavior } from "babylonjs/Behaviors/behavior";
  35612. import { Mesh } from "babylonjs/Meshes/mesh";
  35613. /**
  35614. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  35615. */
  35616. export class FadeInOutBehavior implements Behavior<Mesh> {
  35617. /**
  35618. * Time in milliseconds to delay before fading in (Default: 0)
  35619. */
  35620. delay: number;
  35621. /**
  35622. * Time in milliseconds for the mesh to fade in (Default: 300)
  35623. */
  35624. fadeInTime: number;
  35625. private _millisecondsPerFrame;
  35626. private _hovered;
  35627. private _hoverValue;
  35628. private _ownerNode;
  35629. /**
  35630. * Instatiates the FadeInOutBehavior
  35631. */
  35632. constructor();
  35633. /**
  35634. * The name of the behavior
  35635. */
  35636. readonly name: string;
  35637. /**
  35638. * Initializes the behavior
  35639. */
  35640. init(): void;
  35641. /**
  35642. * Attaches the fade behavior on the passed in mesh
  35643. * @param ownerNode The mesh that will be faded in/out once attached
  35644. */
  35645. attach(ownerNode: Mesh): void;
  35646. /**
  35647. * Detaches the behavior from the mesh
  35648. */
  35649. detach(): void;
  35650. /**
  35651. * Triggers the mesh to begin fading in or out
  35652. * @param value if the object should fade in or out (true to fade in)
  35653. */
  35654. fadeIn(value: boolean): void;
  35655. private _update;
  35656. private _setAllVisibility;
  35657. }
  35658. }
  35659. declare module "babylonjs/Misc/pivotTools" {
  35660. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35661. /**
  35662. * Class containing a set of static utilities functions for managing Pivots
  35663. * @hidden
  35664. */
  35665. export class PivotTools {
  35666. private static _PivotCached;
  35667. private static _OldPivotPoint;
  35668. private static _PivotTranslation;
  35669. private static _PivotTmpVector;
  35670. /** @hidden */
  35671. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  35672. /** @hidden */
  35673. static _RestorePivotPoint(mesh: AbstractMesh): void;
  35674. }
  35675. }
  35676. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  35677. import { Scene } from "babylonjs/scene";
  35678. import { Vector4, Plane } from "babylonjs/Maths/math";
  35679. import { Mesh } from "babylonjs/Meshes/mesh";
  35680. /**
  35681. * Class containing static functions to help procedurally build meshes
  35682. */
  35683. export class PlaneBuilder {
  35684. /**
  35685. * Creates a plane mesh
  35686. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  35687. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  35688. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  35689. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  35690. * * If you create a double-sided mesh, you can choose what parts of 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
  35691. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  35692. * @param name defines the name of the mesh
  35693. * @param options defines the options used to create the mesh
  35694. * @param scene defines the hosting scene
  35695. * @returns the plane mesh
  35696. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  35697. */
  35698. static CreatePlane(name: string, options: {
  35699. size?: number;
  35700. width?: number;
  35701. height?: number;
  35702. sideOrientation?: number;
  35703. frontUVs?: Vector4;
  35704. backUVs?: Vector4;
  35705. updatable?: boolean;
  35706. sourcePlane?: Plane;
  35707. }, scene: Scene): Mesh;
  35708. }
  35709. }
  35710. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  35711. import { Behavior } from "babylonjs/Behaviors/behavior";
  35712. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35713. import { Observable } from "babylonjs/Misc/observable";
  35714. import { Vector3 } from "babylonjs/Maths/math";
  35715. import { Ray } from "babylonjs/Culling/ray";
  35716. import "babylonjs/Meshes/Builders/planeBuilder";
  35717. /**
  35718. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  35719. */
  35720. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  35721. private static _AnyMouseID;
  35722. private _attachedNode;
  35723. private _dragPlane;
  35724. private _scene;
  35725. private _pointerObserver;
  35726. private _beforeRenderObserver;
  35727. private static _planeScene;
  35728. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  35729. /**
  35730. * 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)
  35731. */
  35732. maxDragAngle: number;
  35733. /**
  35734. * @hidden
  35735. */
  35736. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  35737. /**
  35738. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  35739. */
  35740. currentDraggingPointerID: number;
  35741. /**
  35742. * The last position where the pointer hit the drag plane in world space
  35743. */
  35744. lastDragPosition: Vector3;
  35745. /**
  35746. * If the behavior is currently in a dragging state
  35747. */
  35748. dragging: boolean;
  35749. /**
  35750. * 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)
  35751. */
  35752. dragDeltaRatio: number;
  35753. /**
  35754. * If the drag plane orientation should be updated during the dragging (Default: true)
  35755. */
  35756. updateDragPlane: boolean;
  35757. private _debugMode;
  35758. private _moving;
  35759. /**
  35760. * Fires each time the attached mesh is dragged with the pointer
  35761. * * delta between last drag position and current drag position in world space
  35762. * * dragDistance along the drag axis
  35763. * * dragPlaneNormal normal of the current drag plane used during the drag
  35764. * * dragPlanePoint in world space where the drag intersects the drag plane
  35765. */
  35766. onDragObservable: Observable<{
  35767. delta: Vector3;
  35768. dragPlanePoint: Vector3;
  35769. dragPlaneNormal: Vector3;
  35770. dragDistance: number;
  35771. pointerId: number;
  35772. }>;
  35773. /**
  35774. * Fires each time a drag begins (eg. mouse down on mesh)
  35775. */
  35776. onDragStartObservable: Observable<{
  35777. dragPlanePoint: Vector3;
  35778. pointerId: number;
  35779. }>;
  35780. /**
  35781. * Fires each time a drag ends (eg. mouse release after drag)
  35782. */
  35783. onDragEndObservable: Observable<{
  35784. dragPlanePoint: Vector3;
  35785. pointerId: number;
  35786. }>;
  35787. /**
  35788. * If the attached mesh should be moved when dragged
  35789. */
  35790. moveAttached: boolean;
  35791. /**
  35792. * If the drag behavior will react to drag events (Default: true)
  35793. */
  35794. enabled: boolean;
  35795. /**
  35796. * If camera controls should be detached during the drag
  35797. */
  35798. detachCameraControls: boolean;
  35799. /**
  35800. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  35801. */
  35802. useObjectOrienationForDragging: boolean;
  35803. private _options;
  35804. /**
  35805. * Creates a pointer drag behavior that can be attached to a mesh
  35806. * @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)
  35807. */
  35808. constructor(options?: {
  35809. dragAxis?: Vector3;
  35810. dragPlaneNormal?: Vector3;
  35811. });
  35812. /**
  35813. * Predicate to determine if it is valid to move the object to a new position when it is moved
  35814. */
  35815. validateDrag: (targetPosition: Vector3) => boolean;
  35816. /**
  35817. * The name of the behavior
  35818. */
  35819. readonly name: string;
  35820. /**
  35821. * Initializes the behavior
  35822. */
  35823. init(): void;
  35824. private _tmpVector;
  35825. private _alternatePickedPoint;
  35826. private _worldDragAxis;
  35827. private _targetPosition;
  35828. private _attachedElement;
  35829. /**
  35830. * Attaches the drag behavior the passed in mesh
  35831. * @param ownerNode The mesh that will be dragged around once attached
  35832. */
  35833. attach(ownerNode: AbstractMesh): void;
  35834. /**
  35835. * Force relase the drag action by code.
  35836. */
  35837. releaseDrag(): void;
  35838. private _startDragRay;
  35839. private _lastPointerRay;
  35840. /**
  35841. * Simulates the start of a pointer drag event on the behavior
  35842. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  35843. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  35844. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  35845. */
  35846. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  35847. private _startDrag;
  35848. private _dragDelta;
  35849. private _moveDrag;
  35850. private _pickWithRayOnDragPlane;
  35851. private _pointA;
  35852. private _pointB;
  35853. private _pointC;
  35854. private _lineA;
  35855. private _lineB;
  35856. private _localAxis;
  35857. private _lookAt;
  35858. private _updateDragPlanePosition;
  35859. /**
  35860. * Detaches the behavior from the mesh
  35861. */
  35862. detach(): void;
  35863. }
  35864. }
  35865. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  35866. import { Mesh } from "babylonjs/Meshes/mesh";
  35867. import { Behavior } from "babylonjs/Behaviors/behavior";
  35868. /**
  35869. * A behavior that when attached to a mesh will allow the mesh to be scaled
  35870. */
  35871. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  35872. private _dragBehaviorA;
  35873. private _dragBehaviorB;
  35874. private _startDistance;
  35875. private _initialScale;
  35876. private _targetScale;
  35877. private _ownerNode;
  35878. private _sceneRenderObserver;
  35879. /**
  35880. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  35881. */
  35882. constructor();
  35883. /**
  35884. * The name of the behavior
  35885. */
  35886. readonly name: string;
  35887. /**
  35888. * Initializes the behavior
  35889. */
  35890. init(): void;
  35891. private _getCurrentDistance;
  35892. /**
  35893. * Attaches the scale behavior the passed in mesh
  35894. * @param ownerNode The mesh that will be scaled around once attached
  35895. */
  35896. attach(ownerNode: Mesh): void;
  35897. /**
  35898. * Detaches the behavior from the mesh
  35899. */
  35900. detach(): void;
  35901. }
  35902. }
  35903. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  35904. import { Behavior } from "babylonjs/Behaviors/behavior";
  35905. import { Mesh } from "babylonjs/Meshes/mesh";
  35906. import { Observable } from "babylonjs/Misc/observable";
  35907. /**
  35908. * 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
  35909. */
  35910. export class SixDofDragBehavior implements Behavior<Mesh> {
  35911. private static _virtualScene;
  35912. private _ownerNode;
  35913. private _sceneRenderObserver;
  35914. private _scene;
  35915. private _targetPosition;
  35916. private _virtualOriginMesh;
  35917. private _virtualDragMesh;
  35918. private _pointerObserver;
  35919. private _moving;
  35920. private _startingOrientation;
  35921. /**
  35922. * 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)
  35923. */
  35924. private zDragFactor;
  35925. /**
  35926. * If the object should rotate to face the drag origin
  35927. */
  35928. rotateDraggedObject: boolean;
  35929. /**
  35930. * If the behavior is currently in a dragging state
  35931. */
  35932. dragging: boolean;
  35933. /**
  35934. * 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)
  35935. */
  35936. dragDeltaRatio: number;
  35937. /**
  35938. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  35939. */
  35940. currentDraggingPointerID: number;
  35941. /**
  35942. * If camera controls should be detached during the drag
  35943. */
  35944. detachCameraControls: boolean;
  35945. /**
  35946. * Fires each time a drag starts
  35947. */
  35948. onDragStartObservable: Observable<{}>;
  35949. /**
  35950. * Fires each time a drag ends (eg. mouse release after drag)
  35951. */
  35952. onDragEndObservable: Observable<{}>;
  35953. /**
  35954. * 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
  35955. */
  35956. constructor();
  35957. /**
  35958. * The name of the behavior
  35959. */
  35960. readonly name: string;
  35961. /**
  35962. * Initializes the behavior
  35963. */
  35964. init(): void;
  35965. /**
  35966. * Attaches the scale behavior the passed in mesh
  35967. * @param ownerNode The mesh that will be scaled around once attached
  35968. */
  35969. attach(ownerNode: Mesh): void;
  35970. /**
  35971. * Detaches the behavior from the mesh
  35972. */
  35973. detach(): void;
  35974. }
  35975. }
  35976. declare module "babylonjs/Behaviors/Meshes/index" {
  35977. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  35978. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  35979. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  35980. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  35981. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  35982. }
  35983. declare module "babylonjs/Behaviors/index" {
  35984. export * from "babylonjs/Behaviors/behavior";
  35985. export * from "babylonjs/Behaviors/Cameras/index";
  35986. export * from "babylonjs/Behaviors/Meshes/index";
  35987. }
  35988. declare module "babylonjs/Bones/boneIKController" {
  35989. import { Bone } from "babylonjs/Bones/bone";
  35990. import { Vector3 } from "babylonjs/Maths/math";
  35991. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35992. import { Nullable } from "babylonjs/types";
  35993. /**
  35994. * Class used to apply inverse kinematics to bones
  35995. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  35996. */
  35997. export class BoneIKController {
  35998. private static _tmpVecs;
  35999. private static _tmpQuat;
  36000. private static _tmpMats;
  36001. /**
  36002. * Gets or sets the target mesh
  36003. */
  36004. targetMesh: AbstractMesh;
  36005. /** Gets or sets the mesh used as pole */
  36006. poleTargetMesh: AbstractMesh;
  36007. /**
  36008. * Gets or sets the bone used as pole
  36009. */
  36010. poleTargetBone: Nullable<Bone>;
  36011. /**
  36012. * Gets or sets the target position
  36013. */
  36014. targetPosition: Vector3;
  36015. /**
  36016. * Gets or sets the pole target position
  36017. */
  36018. poleTargetPosition: Vector3;
  36019. /**
  36020. * Gets or sets the pole target local offset
  36021. */
  36022. poleTargetLocalOffset: Vector3;
  36023. /**
  36024. * Gets or sets the pole angle
  36025. */
  36026. poleAngle: number;
  36027. /**
  36028. * Gets or sets the mesh associated with the controller
  36029. */
  36030. mesh: AbstractMesh;
  36031. /**
  36032. * 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)
  36033. */
  36034. slerpAmount: number;
  36035. private _bone1Quat;
  36036. private _bone1Mat;
  36037. private _bone2Ang;
  36038. private _bone1;
  36039. private _bone2;
  36040. private _bone1Length;
  36041. private _bone2Length;
  36042. private _maxAngle;
  36043. private _maxReach;
  36044. private _rightHandedSystem;
  36045. private _bendAxis;
  36046. private _slerping;
  36047. private _adjustRoll;
  36048. /**
  36049. * Gets or sets maximum allowed angle
  36050. */
  36051. maxAngle: number;
  36052. /**
  36053. * Creates a new BoneIKController
  36054. * @param mesh defines the mesh to control
  36055. * @param bone defines the bone to control
  36056. * @param options defines options to set up the controller
  36057. */
  36058. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  36059. targetMesh?: AbstractMesh;
  36060. poleTargetMesh?: AbstractMesh;
  36061. poleTargetBone?: Bone;
  36062. poleTargetLocalOffset?: Vector3;
  36063. poleAngle?: number;
  36064. bendAxis?: Vector3;
  36065. maxAngle?: number;
  36066. slerpAmount?: number;
  36067. });
  36068. private _setMaxAngle;
  36069. /**
  36070. * Force the controller to update the bones
  36071. */
  36072. update(): void;
  36073. }
  36074. }
  36075. declare module "babylonjs/Bones/boneLookController" {
  36076. import { Vector3, Space } from "babylonjs/Maths/math";
  36077. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36078. import { Bone } from "babylonjs/Bones/bone";
  36079. /**
  36080. * Class used to make a bone look toward a point in space
  36081. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  36082. */
  36083. export class BoneLookController {
  36084. private static _tmpVecs;
  36085. private static _tmpQuat;
  36086. private static _tmpMats;
  36087. /**
  36088. * The target Vector3 that the bone will look at
  36089. */
  36090. target: Vector3;
  36091. /**
  36092. * The mesh that the bone is attached to
  36093. */
  36094. mesh: AbstractMesh;
  36095. /**
  36096. * The bone that will be looking to the target
  36097. */
  36098. bone: Bone;
  36099. /**
  36100. * The up axis of the coordinate system that is used when the bone is rotated
  36101. */
  36102. upAxis: Vector3;
  36103. /**
  36104. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  36105. */
  36106. upAxisSpace: Space;
  36107. /**
  36108. * Used to make an adjustment to the yaw of the bone
  36109. */
  36110. adjustYaw: number;
  36111. /**
  36112. * Used to make an adjustment to the pitch of the bone
  36113. */
  36114. adjustPitch: number;
  36115. /**
  36116. * Used to make an adjustment to the roll of the bone
  36117. */
  36118. adjustRoll: number;
  36119. /**
  36120. * 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)
  36121. */
  36122. slerpAmount: number;
  36123. private _minYaw;
  36124. private _maxYaw;
  36125. private _minPitch;
  36126. private _maxPitch;
  36127. private _minYawSin;
  36128. private _minYawCos;
  36129. private _maxYawSin;
  36130. private _maxYawCos;
  36131. private _midYawConstraint;
  36132. private _minPitchTan;
  36133. private _maxPitchTan;
  36134. private _boneQuat;
  36135. private _slerping;
  36136. private _transformYawPitch;
  36137. private _transformYawPitchInv;
  36138. private _firstFrameSkipped;
  36139. private _yawRange;
  36140. private _fowardAxis;
  36141. /**
  36142. * Gets or sets the minimum yaw angle that the bone can look to
  36143. */
  36144. minYaw: number;
  36145. /**
  36146. * Gets or sets the maximum yaw angle that the bone can look to
  36147. */
  36148. maxYaw: number;
  36149. /**
  36150. * Gets or sets the minimum pitch angle that the bone can look to
  36151. */
  36152. minPitch: number;
  36153. /**
  36154. * Gets or sets the maximum pitch angle that the bone can look to
  36155. */
  36156. maxPitch: number;
  36157. /**
  36158. * Create a BoneLookController
  36159. * @param mesh the mesh that the bone belongs to
  36160. * @param bone the bone that will be looking to the target
  36161. * @param target the target Vector3 to look at
  36162. * @param options optional settings:
  36163. * * maxYaw: the maximum angle the bone will yaw to
  36164. * * minYaw: the minimum angle the bone will yaw to
  36165. * * maxPitch: the maximum angle the bone will pitch to
  36166. * * minPitch: the minimum angle the bone will yaw to
  36167. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  36168. * * upAxis: the up axis of the coordinate system
  36169. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  36170. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  36171. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  36172. * * adjustYaw: used to make an adjustment to the yaw of the bone
  36173. * * adjustPitch: used to make an adjustment to the pitch of the bone
  36174. * * adjustRoll: used to make an adjustment to the roll of the bone
  36175. **/
  36176. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  36177. maxYaw?: number;
  36178. minYaw?: number;
  36179. maxPitch?: number;
  36180. minPitch?: number;
  36181. slerpAmount?: number;
  36182. upAxis?: Vector3;
  36183. upAxisSpace?: Space;
  36184. yawAxis?: Vector3;
  36185. pitchAxis?: Vector3;
  36186. adjustYaw?: number;
  36187. adjustPitch?: number;
  36188. adjustRoll?: number;
  36189. });
  36190. /**
  36191. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  36192. */
  36193. update(): void;
  36194. private _getAngleDiff;
  36195. private _getAngleBetween;
  36196. private _isAngleBetween;
  36197. }
  36198. }
  36199. declare module "babylonjs/Bones/index" {
  36200. export * from "babylonjs/Bones/bone";
  36201. export * from "babylonjs/Bones/boneIKController";
  36202. export * from "babylonjs/Bones/boneLookController";
  36203. export * from "babylonjs/Bones/skeleton";
  36204. }
  36205. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  36206. import { Nullable } from "babylonjs/types";
  36207. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36208. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36209. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  36210. /**
  36211. * Manage the gamepad inputs to control an arc rotate camera.
  36212. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36213. */
  36214. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  36215. /**
  36216. * Defines the camera the input is attached to.
  36217. */
  36218. camera: ArcRotateCamera;
  36219. /**
  36220. * Defines the gamepad the input is gathering event from.
  36221. */
  36222. gamepad: Nullable<Gamepad>;
  36223. /**
  36224. * Defines the gamepad rotation sensiblity.
  36225. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  36226. */
  36227. gamepadRotationSensibility: number;
  36228. /**
  36229. * Defines the gamepad move sensiblity.
  36230. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  36231. */
  36232. gamepadMoveSensibility: number;
  36233. private _onGamepadConnectedObserver;
  36234. private _onGamepadDisconnectedObserver;
  36235. /**
  36236. * Attach the input controls to a specific dom element to get the input from.
  36237. * @param element Defines the element the controls should be listened from
  36238. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36239. */
  36240. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36241. /**
  36242. * Detach the current controls from the specified dom element.
  36243. * @param element Defines the element to stop listening the inputs from
  36244. */
  36245. detachControl(element: Nullable<HTMLElement>): void;
  36246. /**
  36247. * Update the current camera state depending on the inputs that have been used this frame.
  36248. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36249. */
  36250. checkInputs(): void;
  36251. /**
  36252. * Gets the class name of the current intput.
  36253. * @returns the class name
  36254. */
  36255. getClassName(): string;
  36256. /**
  36257. * Get the friendly name associated with the input class.
  36258. * @returns the input friendly name
  36259. */
  36260. getSimpleName(): string;
  36261. }
  36262. }
  36263. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  36264. import { Nullable } from "babylonjs/types";
  36265. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36266. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36267. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  36268. interface ArcRotateCameraInputsManager {
  36269. /**
  36270. * Add orientation input support to the input manager.
  36271. * @returns the current input manager
  36272. */
  36273. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  36274. }
  36275. }
  36276. /**
  36277. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  36278. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36279. */
  36280. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  36281. /**
  36282. * Defines the camera the input is attached to.
  36283. */
  36284. camera: ArcRotateCamera;
  36285. /**
  36286. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  36287. */
  36288. alphaCorrection: number;
  36289. /**
  36290. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  36291. */
  36292. gammaCorrection: number;
  36293. private _alpha;
  36294. private _gamma;
  36295. private _dirty;
  36296. private _deviceOrientationHandler;
  36297. /**
  36298. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  36299. */
  36300. constructor();
  36301. /**
  36302. * Attach the input controls to a specific dom element to get the input from.
  36303. * @param element Defines the element the controls should be listened from
  36304. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36305. */
  36306. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36307. /** @hidden */
  36308. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  36309. /**
  36310. * Update the current camera state depending on the inputs that have been used this frame.
  36311. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36312. */
  36313. checkInputs(): void;
  36314. /**
  36315. * Detach the current controls from the specified dom element.
  36316. * @param element Defines the element to stop listening the inputs from
  36317. */
  36318. detachControl(element: Nullable<HTMLElement>): void;
  36319. /**
  36320. * Gets the class name of the current intput.
  36321. * @returns the class name
  36322. */
  36323. getClassName(): string;
  36324. /**
  36325. * Get the friendly name associated with the input class.
  36326. * @returns the input friendly name
  36327. */
  36328. getSimpleName(): string;
  36329. }
  36330. }
  36331. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  36332. import { Nullable } from "babylonjs/types";
  36333. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36334. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  36335. /**
  36336. * Listen to mouse events to control the camera.
  36337. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36338. */
  36339. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  36340. /**
  36341. * Defines the camera the input is attached to.
  36342. */
  36343. camera: FlyCamera;
  36344. /**
  36345. * Defines if touch is enabled. (Default is true.)
  36346. */
  36347. touchEnabled: boolean;
  36348. /**
  36349. * Defines the buttons associated with the input to handle camera rotation.
  36350. */
  36351. buttons: number[];
  36352. /**
  36353. * Assign buttons for Yaw control.
  36354. */
  36355. buttonsYaw: number[];
  36356. /**
  36357. * Assign buttons for Pitch control.
  36358. */
  36359. buttonsPitch: number[];
  36360. /**
  36361. * Assign buttons for Roll control.
  36362. */
  36363. buttonsRoll: number[];
  36364. /**
  36365. * Detect if any button is being pressed while mouse is moved.
  36366. * -1 = Mouse locked.
  36367. * 0 = Left button.
  36368. * 1 = Middle Button.
  36369. * 2 = Right Button.
  36370. */
  36371. activeButton: number;
  36372. /**
  36373. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  36374. * Higher values reduce its sensitivity.
  36375. */
  36376. angularSensibility: number;
  36377. private _mousemoveCallback;
  36378. private _observer;
  36379. private _rollObserver;
  36380. private previousPosition;
  36381. private noPreventDefault;
  36382. private element;
  36383. /**
  36384. * Listen to mouse events to control the camera.
  36385. * @param touchEnabled Define if touch is enabled. (Default is true.)
  36386. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36387. */
  36388. constructor(touchEnabled?: boolean);
  36389. /**
  36390. * Attach the mouse control to the HTML DOM element.
  36391. * @param element Defines the element that listens to the input events.
  36392. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  36393. */
  36394. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36395. /**
  36396. * Detach the current controls from the specified dom element.
  36397. * @param element Defines the element to stop listening the inputs from
  36398. */
  36399. detachControl(element: Nullable<HTMLElement>): void;
  36400. /**
  36401. * Gets the class name of the current input.
  36402. * @returns the class name.
  36403. */
  36404. getClassName(): string;
  36405. /**
  36406. * Get the friendly name associated with the input class.
  36407. * @returns the input's friendly name.
  36408. */
  36409. getSimpleName(): string;
  36410. private _pointerInput;
  36411. private _onMouseMove;
  36412. /**
  36413. * Rotate camera by mouse offset.
  36414. */
  36415. private rotateCamera;
  36416. }
  36417. }
  36418. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  36419. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  36420. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  36421. /**
  36422. * Default Inputs manager for the FlyCamera.
  36423. * It groups all the default supported inputs for ease of use.
  36424. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36425. */
  36426. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  36427. /**
  36428. * Instantiates a new FlyCameraInputsManager.
  36429. * @param camera Defines the camera the inputs belong to.
  36430. */
  36431. constructor(camera: FlyCamera);
  36432. /**
  36433. * Add keyboard input support to the input manager.
  36434. * @returns the new FlyCameraKeyboardMoveInput().
  36435. */
  36436. addKeyboard(): FlyCameraInputsManager;
  36437. /**
  36438. * Add mouse input support to the input manager.
  36439. * @param touchEnabled Enable touch screen support.
  36440. * @returns the new FlyCameraMouseInput().
  36441. */
  36442. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  36443. }
  36444. }
  36445. declare module "babylonjs/Cameras/flyCamera" {
  36446. import { Scene } from "babylonjs/scene";
  36447. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  36448. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36449. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  36450. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  36451. /**
  36452. * This is a flying camera, designed for 3D movement and rotation in all directions,
  36453. * such as in a 3D Space Shooter or a Flight Simulator.
  36454. */
  36455. export class FlyCamera extends TargetCamera {
  36456. /**
  36457. * Define the collision ellipsoid of the camera.
  36458. * This is helpful for simulating a camera body, like a player's body.
  36459. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  36460. */
  36461. ellipsoid: Vector3;
  36462. /**
  36463. * Define an offset for the position of the ellipsoid around the camera.
  36464. * This can be helpful if the camera is attached away from the player's body center,
  36465. * such as at its head.
  36466. */
  36467. ellipsoidOffset: Vector3;
  36468. /**
  36469. * Enable or disable collisions of the camera with the rest of the scene objects.
  36470. */
  36471. checkCollisions: boolean;
  36472. /**
  36473. * Enable or disable gravity on the camera.
  36474. */
  36475. applyGravity: boolean;
  36476. /**
  36477. * Define the current direction the camera is moving to.
  36478. */
  36479. cameraDirection: Vector3;
  36480. /**
  36481. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  36482. * This overrides and empties cameraRotation.
  36483. */
  36484. rotationQuaternion: Quaternion;
  36485. /**
  36486. * Track Roll to maintain the wanted Rolling when looking around.
  36487. */
  36488. _trackRoll: number;
  36489. /**
  36490. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  36491. */
  36492. rollCorrect: number;
  36493. /**
  36494. * Mimic a banked turn, Rolling the camera when Yawing.
  36495. * It's recommended to use rollCorrect = 10 for faster banking correction.
  36496. */
  36497. bankedTurn: boolean;
  36498. /**
  36499. * Limit in radians for how much Roll banking will add. (Default: 90°)
  36500. */
  36501. bankedTurnLimit: number;
  36502. /**
  36503. * Value of 0 disables the banked Roll.
  36504. * Value of 1 is equal to the Yaw angle in radians.
  36505. */
  36506. bankedTurnMultiplier: number;
  36507. /**
  36508. * The inputs manager loads all the input sources, such as keyboard and mouse.
  36509. */
  36510. inputs: FlyCameraInputsManager;
  36511. /**
  36512. * Gets the input sensibility for mouse input.
  36513. * Higher values reduce sensitivity.
  36514. */
  36515. /**
  36516. * Sets the input sensibility for a mouse input.
  36517. * Higher values reduce sensitivity.
  36518. */
  36519. angularSensibility: number;
  36520. /**
  36521. * Get the keys for camera movement forward.
  36522. */
  36523. /**
  36524. * Set the keys for camera movement forward.
  36525. */
  36526. keysForward: number[];
  36527. /**
  36528. * Get the keys for camera movement backward.
  36529. */
  36530. keysBackward: number[];
  36531. /**
  36532. * Get the keys for camera movement up.
  36533. */
  36534. /**
  36535. * Set the keys for camera movement up.
  36536. */
  36537. keysUp: number[];
  36538. /**
  36539. * Get the keys for camera movement down.
  36540. */
  36541. /**
  36542. * Set the keys for camera movement down.
  36543. */
  36544. keysDown: number[];
  36545. /**
  36546. * Get the keys for camera movement left.
  36547. */
  36548. /**
  36549. * Set the keys for camera movement left.
  36550. */
  36551. keysLeft: number[];
  36552. /**
  36553. * Set the keys for camera movement right.
  36554. */
  36555. /**
  36556. * Set the keys for camera movement right.
  36557. */
  36558. keysRight: number[];
  36559. /**
  36560. * Event raised when the camera collides with a mesh in the scene.
  36561. */
  36562. onCollide: (collidedMesh: AbstractMesh) => void;
  36563. private _collider;
  36564. private _needMoveForGravity;
  36565. private _oldPosition;
  36566. private _diffPosition;
  36567. private _newPosition;
  36568. /** @hidden */
  36569. _localDirection: Vector3;
  36570. /** @hidden */
  36571. _transformedDirection: Vector3;
  36572. /**
  36573. * Instantiates a FlyCamera.
  36574. * This is a flying camera, designed for 3D movement and rotation in all directions,
  36575. * such as in a 3D Space Shooter or a Flight Simulator.
  36576. * @param name Define the name of the camera in the scene.
  36577. * @param position Define the starting position of the camera in the scene.
  36578. * @param scene Define the scene the camera belongs to.
  36579. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  36580. */
  36581. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  36582. /**
  36583. * Attach a control to the HTML DOM element.
  36584. * @param element Defines the element that listens to the input events.
  36585. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  36586. */
  36587. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36588. /**
  36589. * Detach a control from the HTML DOM element.
  36590. * The camera will stop reacting to that input.
  36591. * @param element Defines the element that listens to the input events.
  36592. */
  36593. detachControl(element: HTMLElement): void;
  36594. private _collisionMask;
  36595. /**
  36596. * Get the mask that the camera ignores in collision events.
  36597. */
  36598. /**
  36599. * Set the mask that the camera ignores in collision events.
  36600. */
  36601. collisionMask: number;
  36602. /** @hidden */
  36603. _collideWithWorld(displacement: Vector3): void;
  36604. /** @hidden */
  36605. private _onCollisionPositionChange;
  36606. /** @hidden */
  36607. _checkInputs(): void;
  36608. /** @hidden */
  36609. _decideIfNeedsToMove(): boolean;
  36610. /** @hidden */
  36611. _updatePosition(): void;
  36612. /**
  36613. * Restore the Roll to its target value at the rate specified.
  36614. * @param rate - Higher means slower restoring.
  36615. * @hidden
  36616. */
  36617. restoreRoll(rate: number): void;
  36618. /**
  36619. * Destroy the camera and release the current resources held by it.
  36620. */
  36621. dispose(): void;
  36622. /**
  36623. * Get the current object class name.
  36624. * @returns the class name.
  36625. */
  36626. getClassName(): string;
  36627. }
  36628. }
  36629. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  36630. import { Nullable } from "babylonjs/types";
  36631. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36632. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  36633. /**
  36634. * Listen to keyboard events to control the camera.
  36635. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36636. */
  36637. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  36638. /**
  36639. * Defines the camera the input is attached to.
  36640. */
  36641. camera: FlyCamera;
  36642. /**
  36643. * The list of keyboard keys used to control the forward move of the camera.
  36644. */
  36645. keysForward: number[];
  36646. /**
  36647. * The list of keyboard keys used to control the backward move of the camera.
  36648. */
  36649. keysBackward: number[];
  36650. /**
  36651. * The list of keyboard keys used to control the forward move of the camera.
  36652. */
  36653. keysUp: number[];
  36654. /**
  36655. * The list of keyboard keys used to control the backward move of the camera.
  36656. */
  36657. keysDown: number[];
  36658. /**
  36659. * The list of keyboard keys used to control the right strafe move of the camera.
  36660. */
  36661. keysRight: number[];
  36662. /**
  36663. * The list of keyboard keys used to control the left strafe move of the camera.
  36664. */
  36665. keysLeft: number[];
  36666. private _keys;
  36667. private _onCanvasBlurObserver;
  36668. private _onKeyboardObserver;
  36669. private _engine;
  36670. private _scene;
  36671. /**
  36672. * Attach the input controls to a specific dom element to get the input from.
  36673. * @param element Defines the element the controls should be listened from
  36674. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36675. */
  36676. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36677. /**
  36678. * Detach the current controls from the specified dom element.
  36679. * @param element Defines the element to stop listening the inputs from
  36680. */
  36681. detachControl(element: Nullable<HTMLElement>): void;
  36682. /**
  36683. * Gets the class name of the current intput.
  36684. * @returns the class name
  36685. */
  36686. getClassName(): string;
  36687. /** @hidden */
  36688. _onLostFocus(e: FocusEvent): void;
  36689. /**
  36690. * Get the friendly name associated with the input class.
  36691. * @returns the input friendly name
  36692. */
  36693. getSimpleName(): string;
  36694. /**
  36695. * Update the current camera state depending on the inputs that have been used this frame.
  36696. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36697. */
  36698. checkInputs(): void;
  36699. }
  36700. }
  36701. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  36702. import { Nullable } from "babylonjs/types";
  36703. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  36704. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36705. /**
  36706. * Manage the mouse wheel inputs to control a follow camera.
  36707. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36708. */
  36709. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  36710. /**
  36711. * Defines the camera the input is attached to.
  36712. */
  36713. camera: FollowCamera;
  36714. /**
  36715. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  36716. */
  36717. axisControlRadius: boolean;
  36718. /**
  36719. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  36720. */
  36721. axisControlHeight: boolean;
  36722. /**
  36723. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  36724. */
  36725. axisControlRotation: boolean;
  36726. /**
  36727. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  36728. * relation to mouseWheel events.
  36729. */
  36730. wheelPrecision: number;
  36731. /**
  36732. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  36733. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  36734. */
  36735. wheelDeltaPercentage: number;
  36736. private _wheel;
  36737. private _observer;
  36738. /**
  36739. * Attach the input controls to a specific dom element to get the input from.
  36740. * @param element Defines the element the controls should be listened from
  36741. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36742. */
  36743. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36744. /**
  36745. * Detach the current controls from the specified dom element.
  36746. * @param element Defines the element to stop listening the inputs from
  36747. */
  36748. detachControl(element: Nullable<HTMLElement>): void;
  36749. /**
  36750. * Gets the class name of the current intput.
  36751. * @returns the class name
  36752. */
  36753. getClassName(): string;
  36754. /**
  36755. * Get the friendly name associated with the input class.
  36756. * @returns the input friendly name
  36757. */
  36758. getSimpleName(): string;
  36759. }
  36760. }
  36761. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  36762. import { Nullable } from "babylonjs/types";
  36763. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  36764. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  36765. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  36766. /**
  36767. * Manage the pointers inputs to control an follow camera.
  36768. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36769. */
  36770. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  36771. /**
  36772. * Defines the camera the input is attached to.
  36773. */
  36774. camera: FollowCamera;
  36775. /**
  36776. * Gets the class name of the current input.
  36777. * @returns the class name
  36778. */
  36779. getClassName(): string;
  36780. /**
  36781. * Defines the pointer angular sensibility along the X axis or how fast is
  36782. * the camera rotating.
  36783. * A negative number will reverse the axis direction.
  36784. */
  36785. angularSensibilityX: number;
  36786. /**
  36787. * Defines the pointer angular sensibility along the Y axis or how fast is
  36788. * the camera rotating.
  36789. * A negative number will reverse the axis direction.
  36790. */
  36791. angularSensibilityY: number;
  36792. /**
  36793. * Defines the pointer pinch precision or how fast is the camera zooming.
  36794. * A negative number will reverse the axis direction.
  36795. */
  36796. pinchPrecision: number;
  36797. /**
  36798. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  36799. * from 0.
  36800. * It defines the percentage of current camera.radius to use as delta when
  36801. * pinch zoom is used.
  36802. */
  36803. pinchDeltaPercentage: number;
  36804. /**
  36805. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  36806. */
  36807. axisXControlRadius: boolean;
  36808. /**
  36809. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  36810. */
  36811. axisXControlHeight: boolean;
  36812. /**
  36813. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  36814. */
  36815. axisXControlRotation: boolean;
  36816. /**
  36817. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  36818. */
  36819. axisYControlRadius: boolean;
  36820. /**
  36821. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  36822. */
  36823. axisYControlHeight: boolean;
  36824. /**
  36825. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  36826. */
  36827. axisYControlRotation: boolean;
  36828. /**
  36829. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  36830. */
  36831. axisPinchControlRadius: boolean;
  36832. /**
  36833. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  36834. */
  36835. axisPinchControlHeight: boolean;
  36836. /**
  36837. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  36838. */
  36839. axisPinchControlRotation: boolean;
  36840. /**
  36841. * Log error messages if basic misconfiguration has occurred.
  36842. */
  36843. warningEnable: boolean;
  36844. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  36845. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  36846. private _warningCounter;
  36847. private _warning;
  36848. }
  36849. }
  36850. declare module "babylonjs/Cameras/followCameraInputsManager" {
  36851. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  36852. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  36853. /**
  36854. * Default Inputs manager for the FollowCamera.
  36855. * It groups all the default supported inputs for ease of use.
  36856. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36857. */
  36858. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  36859. /**
  36860. * Instantiates a new FollowCameraInputsManager.
  36861. * @param camera Defines the camera the inputs belong to
  36862. */
  36863. constructor(camera: FollowCamera);
  36864. /**
  36865. * Add keyboard input support to the input manager.
  36866. * @returns the current input manager
  36867. */
  36868. addKeyboard(): FollowCameraInputsManager;
  36869. /**
  36870. * Add mouse wheel input support to the input manager.
  36871. * @returns the current input manager
  36872. */
  36873. addMouseWheel(): FollowCameraInputsManager;
  36874. /**
  36875. * Add pointers input support to the input manager.
  36876. * @returns the current input manager
  36877. */
  36878. addPointers(): FollowCameraInputsManager;
  36879. /**
  36880. * Add orientation input support to the input manager.
  36881. * @returns the current input manager
  36882. */
  36883. addVRDeviceOrientation(): FollowCameraInputsManager;
  36884. }
  36885. }
  36886. declare module "babylonjs/Cameras/followCamera" {
  36887. import { Nullable } from "babylonjs/types";
  36888. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  36889. import { Scene } from "babylonjs/scene";
  36890. import { Vector3 } from "babylonjs/Maths/math";
  36891. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36892. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  36893. /**
  36894. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  36895. * an arc rotate version arcFollowCamera are available.
  36896. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  36897. */
  36898. export class FollowCamera extends TargetCamera {
  36899. /**
  36900. * Distance the follow camera should follow an object at
  36901. */
  36902. radius: number;
  36903. /**
  36904. * Minimum allowed distance of the camera to the axis of rotation
  36905. * (The camera can not get closer).
  36906. * This can help limiting how the Camera is able to move in the scene.
  36907. */
  36908. lowerRadiusLimit: Nullable<number>;
  36909. /**
  36910. * Maximum allowed distance of the camera to the axis of rotation
  36911. * (The camera can not get further).
  36912. * This can help limiting how the Camera is able to move in the scene.
  36913. */
  36914. upperRadiusLimit: Nullable<number>;
  36915. /**
  36916. * Define a rotation offset between the camera and the object it follows
  36917. */
  36918. rotationOffset: number;
  36919. /**
  36920. * Minimum allowed angle to camera position relative to target object.
  36921. * This can help limiting how the Camera is able to move in the scene.
  36922. */
  36923. lowerRotationOffsetLimit: Nullable<number>;
  36924. /**
  36925. * Maximum allowed angle to camera position relative to target object.
  36926. * This can help limiting how the Camera is able to move in the scene.
  36927. */
  36928. upperRotationOffsetLimit: Nullable<number>;
  36929. /**
  36930. * Define a height offset between the camera and the object it follows.
  36931. * It can help following an object from the top (like a car chaing a plane)
  36932. */
  36933. heightOffset: number;
  36934. /**
  36935. * Minimum allowed height of camera position relative to target object.
  36936. * This can help limiting how the Camera is able to move in the scene.
  36937. */
  36938. lowerHeightOffsetLimit: Nullable<number>;
  36939. /**
  36940. * Maximum allowed height of camera position relative to target object.
  36941. * This can help limiting how the Camera is able to move in the scene.
  36942. */
  36943. upperHeightOffsetLimit: Nullable<number>;
  36944. /**
  36945. * Define how fast the camera can accelerate to follow it s target.
  36946. */
  36947. cameraAcceleration: number;
  36948. /**
  36949. * Define the speed limit of the camera following an object.
  36950. */
  36951. maxCameraSpeed: number;
  36952. /**
  36953. * Define the target of the camera.
  36954. */
  36955. lockedTarget: Nullable<AbstractMesh>;
  36956. /**
  36957. * Defines the input associated with the camera.
  36958. */
  36959. inputs: FollowCameraInputsManager;
  36960. /**
  36961. * Instantiates the follow camera.
  36962. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  36963. * @param name Define the name of the camera in the scene
  36964. * @param position Define the position of the camera
  36965. * @param scene Define the scene the camera belong to
  36966. * @param lockedTarget Define the target of the camera
  36967. */
  36968. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  36969. private _follow;
  36970. /**
  36971. * Attached controls to the current camera.
  36972. * @param element Defines the element the controls should be listened from
  36973. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36974. */
  36975. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36976. /**
  36977. * Detach the current controls from the camera.
  36978. * The camera will stop reacting to inputs.
  36979. * @param element Defines the element to stop listening the inputs from
  36980. */
  36981. detachControl(element: HTMLElement): void;
  36982. /** @hidden */
  36983. _checkInputs(): void;
  36984. private _checkLimits;
  36985. /**
  36986. * Gets the camera class name.
  36987. * @returns the class name
  36988. */
  36989. getClassName(): string;
  36990. }
  36991. /**
  36992. * Arc Rotate version of the follow camera.
  36993. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  36994. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  36995. */
  36996. export class ArcFollowCamera extends TargetCamera {
  36997. /** The longitudinal angle of the camera */
  36998. alpha: number;
  36999. /** The latitudinal angle of the camera */
  37000. beta: number;
  37001. /** The radius of the camera from its target */
  37002. radius: number;
  37003. /** Define the camera target (the messh it should follow) */
  37004. target: Nullable<AbstractMesh>;
  37005. private _cartesianCoordinates;
  37006. /**
  37007. * Instantiates a new ArcFollowCamera
  37008. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37009. * @param name Define the name of the camera
  37010. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  37011. * @param beta Define the rotation angle of the camera around the elevation axis
  37012. * @param radius Define the radius of the camera from its target point
  37013. * @param target Define the target of the camera
  37014. * @param scene Define the scene the camera belongs to
  37015. */
  37016. constructor(name: string,
  37017. /** The longitudinal angle of the camera */
  37018. alpha: number,
  37019. /** The latitudinal angle of the camera */
  37020. beta: number,
  37021. /** The radius of the camera from its target */
  37022. radius: number,
  37023. /** Define the camera target (the messh it should follow) */
  37024. target: Nullable<AbstractMesh>, scene: Scene);
  37025. private _follow;
  37026. /** @hidden */
  37027. _checkInputs(): void;
  37028. /**
  37029. * Returns the class name of the object.
  37030. * It is mostly used internally for serialization purposes.
  37031. */
  37032. getClassName(): string;
  37033. }
  37034. }
  37035. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  37036. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37037. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  37038. import { Nullable } from "babylonjs/types";
  37039. /**
  37040. * Manage the keyboard inputs to control the movement of a follow camera.
  37041. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37042. */
  37043. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  37044. /**
  37045. * Defines the camera the input is attached to.
  37046. */
  37047. camera: FollowCamera;
  37048. /**
  37049. * Defines the list of key codes associated with the up action (increase heightOffset)
  37050. */
  37051. keysHeightOffsetIncr: number[];
  37052. /**
  37053. * Defines the list of key codes associated with the down action (decrease heightOffset)
  37054. */
  37055. keysHeightOffsetDecr: number[];
  37056. /**
  37057. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  37058. */
  37059. keysHeightOffsetModifierAlt: boolean;
  37060. /**
  37061. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  37062. */
  37063. keysHeightOffsetModifierCtrl: boolean;
  37064. /**
  37065. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  37066. */
  37067. keysHeightOffsetModifierShift: boolean;
  37068. /**
  37069. * Defines the list of key codes associated with the left action (increase rotationOffset)
  37070. */
  37071. keysRotationOffsetIncr: number[];
  37072. /**
  37073. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  37074. */
  37075. keysRotationOffsetDecr: number[];
  37076. /**
  37077. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  37078. */
  37079. keysRotationOffsetModifierAlt: boolean;
  37080. /**
  37081. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  37082. */
  37083. keysRotationOffsetModifierCtrl: boolean;
  37084. /**
  37085. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  37086. */
  37087. keysRotationOffsetModifierShift: boolean;
  37088. /**
  37089. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  37090. */
  37091. keysRadiusIncr: number[];
  37092. /**
  37093. * Defines the list of key codes associated with the zoom-out action (increase radius)
  37094. */
  37095. keysRadiusDecr: number[];
  37096. /**
  37097. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  37098. */
  37099. keysRadiusModifierAlt: boolean;
  37100. /**
  37101. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  37102. */
  37103. keysRadiusModifierCtrl: boolean;
  37104. /**
  37105. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  37106. */
  37107. keysRadiusModifierShift: boolean;
  37108. /**
  37109. * Defines the rate of change of heightOffset.
  37110. */
  37111. heightSensibility: number;
  37112. /**
  37113. * Defines the rate of change of rotationOffset.
  37114. */
  37115. rotationSensibility: number;
  37116. /**
  37117. * Defines the rate of change of radius.
  37118. */
  37119. radiusSensibility: number;
  37120. private _keys;
  37121. private _ctrlPressed;
  37122. private _altPressed;
  37123. private _shiftPressed;
  37124. private _onCanvasBlurObserver;
  37125. private _onKeyboardObserver;
  37126. private _engine;
  37127. private _scene;
  37128. /**
  37129. * Attach the input controls to a specific dom element to get the input from.
  37130. * @param element Defines the element the controls should be listened from
  37131. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37132. */
  37133. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37134. /**
  37135. * Detach the current controls from the specified dom element.
  37136. * @param element Defines the element to stop listening the inputs from
  37137. */
  37138. detachControl(element: Nullable<HTMLElement>): void;
  37139. /**
  37140. * Update the current camera state depending on the inputs that have been used this frame.
  37141. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37142. */
  37143. checkInputs(): void;
  37144. /**
  37145. * Gets the class name of the current input.
  37146. * @returns the class name
  37147. */
  37148. getClassName(): string;
  37149. /**
  37150. * Get the friendly name associated with the input class.
  37151. * @returns the input friendly name
  37152. */
  37153. getSimpleName(): string;
  37154. /**
  37155. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37156. * allow modification of the heightOffset value.
  37157. */
  37158. private _modifierHeightOffset;
  37159. /**
  37160. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37161. * allow modification of the rotationOffset value.
  37162. */
  37163. private _modifierRotationOffset;
  37164. /**
  37165. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37166. * allow modification of the radius value.
  37167. */
  37168. private _modifierRadius;
  37169. }
  37170. }
  37171. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  37172. import { Nullable } from "babylonjs/types";
  37173. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37174. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37175. module "babylonjs/Cameras/freeCameraInputsManager" {
  37176. interface FreeCameraInputsManager {
  37177. /**
  37178. * Add orientation input support to the input manager.
  37179. * @returns the current input manager
  37180. */
  37181. addDeviceOrientation(): FreeCameraInputsManager;
  37182. }
  37183. }
  37184. /**
  37185. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  37186. * Screen rotation is taken into account.
  37187. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37188. */
  37189. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  37190. private _camera;
  37191. private _screenOrientationAngle;
  37192. private _constantTranform;
  37193. private _screenQuaternion;
  37194. private _alpha;
  37195. private _beta;
  37196. private _gamma;
  37197. /**
  37198. * Instantiates a new input
  37199. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37200. */
  37201. constructor();
  37202. /**
  37203. * Define the camera controlled by the input.
  37204. */
  37205. camera: FreeCamera;
  37206. /**
  37207. * Attach the input controls to a specific dom element to get the input from.
  37208. * @param element Defines the element the controls should be listened from
  37209. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37210. */
  37211. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37212. private _orientationChanged;
  37213. private _deviceOrientation;
  37214. /**
  37215. * Detach the current controls from the specified dom element.
  37216. * @param element Defines the element to stop listening the inputs from
  37217. */
  37218. detachControl(element: Nullable<HTMLElement>): void;
  37219. /**
  37220. * Update the current camera state depending on the inputs that have been used this frame.
  37221. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37222. */
  37223. checkInputs(): void;
  37224. /**
  37225. * Gets the class name of the current intput.
  37226. * @returns the class name
  37227. */
  37228. getClassName(): string;
  37229. /**
  37230. * Get the friendly name associated with the input class.
  37231. * @returns the input friendly name
  37232. */
  37233. getSimpleName(): string;
  37234. }
  37235. }
  37236. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  37237. import { Nullable } from "babylonjs/types";
  37238. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37239. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37240. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  37241. /**
  37242. * Manage the gamepad inputs to control a free camera.
  37243. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37244. */
  37245. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  37246. /**
  37247. * Define the camera the input is attached to.
  37248. */
  37249. camera: FreeCamera;
  37250. /**
  37251. * Define the Gamepad controlling the input
  37252. */
  37253. gamepad: Nullable<Gamepad>;
  37254. /**
  37255. * Defines the gamepad rotation sensiblity.
  37256. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37257. */
  37258. gamepadAngularSensibility: number;
  37259. /**
  37260. * Defines the gamepad move sensiblity.
  37261. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37262. */
  37263. gamepadMoveSensibility: number;
  37264. private _onGamepadConnectedObserver;
  37265. private _onGamepadDisconnectedObserver;
  37266. private _cameraTransform;
  37267. private _deltaTransform;
  37268. private _vector3;
  37269. private _vector2;
  37270. /**
  37271. * Attach the input controls to a specific dom element to get the input from.
  37272. * @param element Defines the element the controls should be listened from
  37273. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37274. */
  37275. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37276. /**
  37277. * Detach the current controls from the specified dom element.
  37278. * @param element Defines the element to stop listening the inputs from
  37279. */
  37280. detachControl(element: Nullable<HTMLElement>): void;
  37281. /**
  37282. * Update the current camera state depending on the inputs that have been used this frame.
  37283. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37284. */
  37285. checkInputs(): void;
  37286. /**
  37287. * Gets the class name of the current intput.
  37288. * @returns the class name
  37289. */
  37290. getClassName(): string;
  37291. /**
  37292. * Get the friendly name associated with the input class.
  37293. * @returns the input friendly name
  37294. */
  37295. getSimpleName(): string;
  37296. }
  37297. }
  37298. declare module "babylonjs/Misc/virtualJoystick" {
  37299. import { Nullable } from "babylonjs/types";
  37300. import { Vector3 } from "babylonjs/Maths/math";
  37301. /**
  37302. * Defines the potential axis of a Joystick
  37303. */
  37304. export enum JoystickAxis {
  37305. /** X axis */
  37306. X = 0,
  37307. /** Y axis */
  37308. Y = 1,
  37309. /** Z axis */
  37310. Z = 2
  37311. }
  37312. /**
  37313. * Class used to define virtual joystick (used in touch mode)
  37314. */
  37315. export class VirtualJoystick {
  37316. /**
  37317. * Gets or sets a boolean indicating that left and right values must be inverted
  37318. */
  37319. reverseLeftRight: boolean;
  37320. /**
  37321. * Gets or sets a boolean indicating that up and down values must be inverted
  37322. */
  37323. reverseUpDown: boolean;
  37324. /**
  37325. * Gets the offset value for the position (ie. the change of the position value)
  37326. */
  37327. deltaPosition: Vector3;
  37328. /**
  37329. * Gets a boolean indicating if the virtual joystick was pressed
  37330. */
  37331. pressed: boolean;
  37332. /**
  37333. * Canvas the virtual joystick will render onto, default z-index of this is 5
  37334. */
  37335. static Canvas: Nullable<HTMLCanvasElement>;
  37336. private static _globalJoystickIndex;
  37337. private static vjCanvasContext;
  37338. private static vjCanvasWidth;
  37339. private static vjCanvasHeight;
  37340. private static halfWidth;
  37341. private _action;
  37342. private _axisTargetedByLeftAndRight;
  37343. private _axisTargetedByUpAndDown;
  37344. private _joystickSensibility;
  37345. private _inversedSensibility;
  37346. private _joystickPointerID;
  37347. private _joystickColor;
  37348. private _joystickPointerPos;
  37349. private _joystickPreviousPointerPos;
  37350. private _joystickPointerStartPos;
  37351. private _deltaJoystickVector;
  37352. private _leftJoystick;
  37353. private _touches;
  37354. private _onPointerDownHandlerRef;
  37355. private _onPointerMoveHandlerRef;
  37356. private _onPointerUpHandlerRef;
  37357. private _onResize;
  37358. /**
  37359. * Creates a new virtual joystick
  37360. * @param leftJoystick defines that the joystick is for left hand (false by default)
  37361. */
  37362. constructor(leftJoystick?: boolean);
  37363. /**
  37364. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  37365. * @param newJoystickSensibility defines the new sensibility
  37366. */
  37367. setJoystickSensibility(newJoystickSensibility: number): void;
  37368. private _onPointerDown;
  37369. private _onPointerMove;
  37370. private _onPointerUp;
  37371. /**
  37372. * Change the color of the virtual joystick
  37373. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  37374. */
  37375. setJoystickColor(newColor: string): void;
  37376. /**
  37377. * Defines a callback to call when the joystick is touched
  37378. * @param action defines the callback
  37379. */
  37380. setActionOnTouch(action: () => any): void;
  37381. /**
  37382. * Defines which axis you'd like to control for left & right
  37383. * @param axis defines the axis to use
  37384. */
  37385. setAxisForLeftRight(axis: JoystickAxis): void;
  37386. /**
  37387. * Defines which axis you'd like to control for up & down
  37388. * @param axis defines the axis to use
  37389. */
  37390. setAxisForUpDown(axis: JoystickAxis): void;
  37391. private _drawVirtualJoystick;
  37392. /**
  37393. * Release internal HTML canvas
  37394. */
  37395. releaseCanvas(): void;
  37396. }
  37397. }
  37398. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  37399. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  37400. import { Nullable } from "babylonjs/types";
  37401. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37402. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37403. module "babylonjs/Cameras/freeCameraInputsManager" {
  37404. interface FreeCameraInputsManager {
  37405. /**
  37406. * Add virtual joystick input support to the input manager.
  37407. * @returns the current input manager
  37408. */
  37409. addVirtualJoystick(): FreeCameraInputsManager;
  37410. }
  37411. }
  37412. /**
  37413. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  37414. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37415. */
  37416. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  37417. /**
  37418. * Defines the camera the input is attached to.
  37419. */
  37420. camera: FreeCamera;
  37421. private _leftjoystick;
  37422. private _rightjoystick;
  37423. /**
  37424. * Gets the left stick of the virtual joystick.
  37425. * @returns The virtual Joystick
  37426. */
  37427. getLeftJoystick(): VirtualJoystick;
  37428. /**
  37429. * Gets the right stick of the virtual joystick.
  37430. * @returns The virtual Joystick
  37431. */
  37432. getRightJoystick(): VirtualJoystick;
  37433. /**
  37434. * Update the current camera state depending on the inputs that have been used this frame.
  37435. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37436. */
  37437. checkInputs(): void;
  37438. /**
  37439. * Attach the input controls to a specific dom element to get the input from.
  37440. * @param element Defines the element the controls should be listened from
  37441. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37442. */
  37443. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37444. /**
  37445. * Detach the current controls from the specified dom element.
  37446. * @param element Defines the element to stop listening the inputs from
  37447. */
  37448. detachControl(element: Nullable<HTMLElement>): void;
  37449. /**
  37450. * Gets the class name of the current intput.
  37451. * @returns the class name
  37452. */
  37453. getClassName(): string;
  37454. /**
  37455. * Get the friendly name associated with the input class.
  37456. * @returns the input friendly name
  37457. */
  37458. getSimpleName(): string;
  37459. }
  37460. }
  37461. declare module "babylonjs/Cameras/Inputs/index" {
  37462. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  37463. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  37464. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  37465. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  37466. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  37467. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  37468. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  37469. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  37470. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  37471. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  37472. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  37473. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  37474. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  37475. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  37476. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  37477. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  37478. }
  37479. declare module "babylonjs/Cameras/touchCamera" {
  37480. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37481. import { Scene } from "babylonjs/scene";
  37482. import { Vector3 } from "babylonjs/Maths/math";
  37483. /**
  37484. * This represents a FPS type of camera controlled by touch.
  37485. * This is like a universal camera minus the Gamepad controls.
  37486. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37487. */
  37488. export class TouchCamera extends FreeCamera {
  37489. /**
  37490. * Defines the touch sensibility for rotation.
  37491. * The higher the faster.
  37492. */
  37493. touchAngularSensibility: number;
  37494. /**
  37495. * Defines the touch sensibility for move.
  37496. * The higher the faster.
  37497. */
  37498. touchMoveSensibility: number;
  37499. /**
  37500. * Instantiates a new touch camera.
  37501. * This represents a FPS type of camera controlled by touch.
  37502. * This is like a universal camera minus the Gamepad controls.
  37503. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37504. * @param name Define the name of the camera in the scene
  37505. * @param position Define the start position of the camera in the scene
  37506. * @param scene Define the scene the camera belongs to
  37507. */
  37508. constructor(name: string, position: Vector3, scene: Scene);
  37509. /**
  37510. * Gets the current object class name.
  37511. * @return the class name
  37512. */
  37513. getClassName(): string;
  37514. /** @hidden */
  37515. _setupInputs(): void;
  37516. }
  37517. }
  37518. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  37519. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37520. import { Scene } from "babylonjs/scene";
  37521. import { Vector3, Axis } from "babylonjs/Maths/math";
  37522. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  37523. /**
  37524. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  37525. * being tilted forward or back and left or right.
  37526. */
  37527. export class DeviceOrientationCamera extends FreeCamera {
  37528. private _initialQuaternion;
  37529. private _quaternionCache;
  37530. /**
  37531. * Creates a new device orientation camera
  37532. * @param name The name of the camera
  37533. * @param position The start position camera
  37534. * @param scene The scene the camera belongs to
  37535. */
  37536. constructor(name: string, position: Vector3, scene: Scene);
  37537. /**
  37538. * Gets the current instance class name ("DeviceOrientationCamera").
  37539. * This helps avoiding instanceof at run time.
  37540. * @returns the class name
  37541. */
  37542. getClassName(): string;
  37543. /**
  37544. * @hidden
  37545. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  37546. */
  37547. _checkInputs(): void;
  37548. /**
  37549. * Reset the camera to its default orientation on the specified axis only.
  37550. * @param axis The axis to reset
  37551. */
  37552. resetToCurrentRotation(axis?: Axis): void;
  37553. }
  37554. }
  37555. declare module "babylonjs/Cameras/universalCamera" {
  37556. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  37557. import { Scene } from "babylonjs/scene";
  37558. import { Vector3 } from "babylonjs/Maths/math";
  37559. /**
  37560. * 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,
  37561. * which still works and will still be found in many Playgrounds.
  37562. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37563. */
  37564. export class UniversalCamera extends TouchCamera {
  37565. /**
  37566. * Defines the gamepad rotation sensiblity.
  37567. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37568. */
  37569. gamepadAngularSensibility: number;
  37570. /**
  37571. * Defines the gamepad move sensiblity.
  37572. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37573. */
  37574. gamepadMoveSensibility: number;
  37575. /**
  37576. * 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,
  37577. * which still works and will still be found in many Playgrounds.
  37578. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37579. * @param name Define the name of the camera in the scene
  37580. * @param position Define the start position of the camera in the scene
  37581. * @param scene Define the scene the camera belongs to
  37582. */
  37583. constructor(name: string, position: Vector3, scene: Scene);
  37584. /**
  37585. * Gets the current object class name.
  37586. * @return the class name
  37587. */
  37588. getClassName(): string;
  37589. }
  37590. }
  37591. declare module "babylonjs/Cameras/gamepadCamera" {
  37592. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  37593. import { Scene } from "babylonjs/scene";
  37594. import { Vector3 } from "babylonjs/Maths/math";
  37595. /**
  37596. * This represents a FPS type of camera. This is only here for back compat purpose.
  37597. * Please use the UniversalCamera instead as both are identical.
  37598. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37599. */
  37600. export class GamepadCamera extends UniversalCamera {
  37601. /**
  37602. * Instantiates a new Gamepad Camera
  37603. * This represents a FPS type of camera. This is only here for back compat purpose.
  37604. * Please use the UniversalCamera instead as both are identical.
  37605. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37606. * @param name Define the name of the camera in the scene
  37607. * @param position Define the start position of the camera in the scene
  37608. * @param scene Define the scene the camera belongs to
  37609. */
  37610. constructor(name: string, position: Vector3, scene: Scene);
  37611. /**
  37612. * Gets the current object class name.
  37613. * @return the class name
  37614. */
  37615. getClassName(): string;
  37616. }
  37617. }
  37618. declare module "babylonjs/Shaders/pass.fragment" {
  37619. /** @hidden */
  37620. export var passPixelShader: {
  37621. name: string;
  37622. shader: string;
  37623. };
  37624. }
  37625. declare module "babylonjs/Shaders/passCube.fragment" {
  37626. /** @hidden */
  37627. export var passCubePixelShader: {
  37628. name: string;
  37629. shader: string;
  37630. };
  37631. }
  37632. declare module "babylonjs/PostProcesses/passPostProcess" {
  37633. import { Nullable } from "babylonjs/types";
  37634. import { Camera } from "babylonjs/Cameras/camera";
  37635. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  37636. import { Engine } from "babylonjs/Engines/engine";
  37637. import "babylonjs/Shaders/pass.fragment";
  37638. import "babylonjs/Shaders/passCube.fragment";
  37639. /**
  37640. * PassPostProcess which produces an output the same as it's input
  37641. */
  37642. export class PassPostProcess extends PostProcess {
  37643. /**
  37644. * Creates the PassPostProcess
  37645. * @param name The name of the effect.
  37646. * @param options The required width/height ratio to downsize to before computing the render pass.
  37647. * @param camera The camera to apply the render pass to.
  37648. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  37649. * @param engine The engine which the post process will be applied. (default: current engine)
  37650. * @param reusable If the post process can be reused on the same frame. (default: false)
  37651. * @param textureType The type of texture to be used when performing the post processing.
  37652. * @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)
  37653. */
  37654. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  37655. }
  37656. /**
  37657. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  37658. */
  37659. export class PassCubePostProcess extends PostProcess {
  37660. private _face;
  37661. /**
  37662. * Gets or sets the cube face to display.
  37663. * * 0 is +X
  37664. * * 1 is -X
  37665. * * 2 is +Y
  37666. * * 3 is -Y
  37667. * * 4 is +Z
  37668. * * 5 is -Z
  37669. */
  37670. face: number;
  37671. /**
  37672. * Creates the PassCubePostProcess
  37673. * @param name The name of the effect.
  37674. * @param options The required width/height ratio to downsize to before computing the render pass.
  37675. * @param camera The camera to apply the render pass to.
  37676. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  37677. * @param engine The engine which the post process will be applied. (default: current engine)
  37678. * @param reusable If the post process can be reused on the same frame. (default: false)
  37679. * @param textureType The type of texture to be used when performing the post processing.
  37680. * @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)
  37681. */
  37682. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  37683. }
  37684. }
  37685. declare module "babylonjs/Shaders/anaglyph.fragment" {
  37686. /** @hidden */
  37687. export var anaglyphPixelShader: {
  37688. name: string;
  37689. shader: string;
  37690. };
  37691. }
  37692. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  37693. import { Engine } from "babylonjs/Engines/engine";
  37694. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  37695. import { Camera } from "babylonjs/Cameras/camera";
  37696. import "babylonjs/Shaders/anaglyph.fragment";
  37697. /**
  37698. * Postprocess used to generate anaglyphic rendering
  37699. */
  37700. export class AnaglyphPostProcess extends PostProcess {
  37701. private _passedProcess;
  37702. /**
  37703. * Creates a new AnaglyphPostProcess
  37704. * @param name defines postprocess name
  37705. * @param options defines creation options or target ratio scale
  37706. * @param rigCameras defines cameras using this postprocess
  37707. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  37708. * @param engine defines hosting engine
  37709. * @param reusable defines if the postprocess will be reused multiple times per frame
  37710. */
  37711. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  37712. }
  37713. }
  37714. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  37715. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  37716. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37717. import { Scene } from "babylonjs/scene";
  37718. import { Vector3 } from "babylonjs/Maths/math";
  37719. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  37720. /**
  37721. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  37722. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  37723. */
  37724. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  37725. /**
  37726. * Creates a new AnaglyphArcRotateCamera
  37727. * @param name defines camera name
  37728. * @param alpha defines alpha angle (in radians)
  37729. * @param beta defines beta angle (in radians)
  37730. * @param radius defines radius
  37731. * @param target defines camera target
  37732. * @param interaxialDistance defines distance between each color axis
  37733. * @param scene defines the hosting scene
  37734. */
  37735. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  37736. /**
  37737. * Gets camera class name
  37738. * @returns AnaglyphArcRotateCamera
  37739. */
  37740. getClassName(): string;
  37741. }
  37742. }
  37743. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  37744. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37745. import { Scene } from "babylonjs/scene";
  37746. import { Vector3 } from "babylonjs/Maths/math";
  37747. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  37748. /**
  37749. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  37750. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  37751. */
  37752. export class AnaglyphFreeCamera extends FreeCamera {
  37753. /**
  37754. * Creates a new AnaglyphFreeCamera
  37755. * @param name defines camera name
  37756. * @param position defines initial position
  37757. * @param interaxialDistance defines distance between each color axis
  37758. * @param scene defines the hosting scene
  37759. */
  37760. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  37761. /**
  37762. * Gets camera class name
  37763. * @returns AnaglyphFreeCamera
  37764. */
  37765. getClassName(): string;
  37766. }
  37767. }
  37768. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  37769. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  37770. import { Scene } from "babylonjs/scene";
  37771. import { Vector3 } from "babylonjs/Maths/math";
  37772. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  37773. /**
  37774. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  37775. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  37776. */
  37777. export class AnaglyphGamepadCamera extends GamepadCamera {
  37778. /**
  37779. * Creates a new AnaglyphGamepadCamera
  37780. * @param name defines camera name
  37781. * @param position defines initial position
  37782. * @param interaxialDistance defines distance between each color axis
  37783. * @param scene defines the hosting scene
  37784. */
  37785. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  37786. /**
  37787. * Gets camera class name
  37788. * @returns AnaglyphGamepadCamera
  37789. */
  37790. getClassName(): string;
  37791. }
  37792. }
  37793. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  37794. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  37795. import { Scene } from "babylonjs/scene";
  37796. import { Vector3 } from "babylonjs/Maths/math";
  37797. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  37798. /**
  37799. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  37800. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  37801. */
  37802. export class AnaglyphUniversalCamera extends UniversalCamera {
  37803. /**
  37804. * Creates a new AnaglyphUniversalCamera
  37805. * @param name defines camera name
  37806. * @param position defines initial position
  37807. * @param interaxialDistance defines distance between each color axis
  37808. * @param scene defines the hosting scene
  37809. */
  37810. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  37811. /**
  37812. * Gets camera class name
  37813. * @returns AnaglyphUniversalCamera
  37814. */
  37815. getClassName(): string;
  37816. }
  37817. }
  37818. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  37819. /** @hidden */
  37820. export var stereoscopicInterlacePixelShader: {
  37821. name: string;
  37822. shader: string;
  37823. };
  37824. }
  37825. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  37826. import { Camera } from "babylonjs/Cameras/camera";
  37827. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  37828. import { Engine } from "babylonjs/Engines/engine";
  37829. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  37830. /**
  37831. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  37832. */
  37833. export class StereoscopicInterlacePostProcess extends PostProcess {
  37834. private _stepSize;
  37835. private _passedProcess;
  37836. /**
  37837. * Initializes a StereoscopicInterlacePostProcess
  37838. * @param name The name of the effect.
  37839. * @param rigCameras The rig cameras to be appled to the post process
  37840. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  37841. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  37842. * @param engine The engine which the post process will be applied. (default: current engine)
  37843. * @param reusable If the post process can be reused on the same frame. (default: false)
  37844. */
  37845. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  37846. }
  37847. }
  37848. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  37849. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  37850. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37851. import { Scene } from "babylonjs/scene";
  37852. import { Vector3 } from "babylonjs/Maths/math";
  37853. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  37854. /**
  37855. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  37856. * @see http://doc.babylonjs.com/features/cameras
  37857. */
  37858. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  37859. /**
  37860. * Creates a new StereoscopicArcRotateCamera
  37861. * @param name defines camera name
  37862. * @param alpha defines alpha angle (in radians)
  37863. * @param beta defines beta angle (in radians)
  37864. * @param radius defines radius
  37865. * @param target defines camera target
  37866. * @param interaxialDistance defines distance between each color axis
  37867. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  37868. * @param scene defines the hosting scene
  37869. */
  37870. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  37871. /**
  37872. * Gets camera class name
  37873. * @returns StereoscopicArcRotateCamera
  37874. */
  37875. getClassName(): string;
  37876. }
  37877. }
  37878. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  37879. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37880. import { Scene } from "babylonjs/scene";
  37881. import { Vector3 } from "babylonjs/Maths/math";
  37882. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  37883. /**
  37884. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  37885. * @see http://doc.babylonjs.com/features/cameras
  37886. */
  37887. export class StereoscopicFreeCamera extends FreeCamera {
  37888. /**
  37889. * Creates a new StereoscopicFreeCamera
  37890. * @param name defines camera name
  37891. * @param position defines initial position
  37892. * @param interaxialDistance defines distance between each color axis
  37893. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  37894. * @param scene defines the hosting scene
  37895. */
  37896. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  37897. /**
  37898. * Gets camera class name
  37899. * @returns StereoscopicFreeCamera
  37900. */
  37901. getClassName(): string;
  37902. }
  37903. }
  37904. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  37905. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  37906. import { Scene } from "babylonjs/scene";
  37907. import { Vector3 } from "babylonjs/Maths/math";
  37908. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  37909. /**
  37910. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  37911. * @see http://doc.babylonjs.com/features/cameras
  37912. */
  37913. export class StereoscopicGamepadCamera extends GamepadCamera {
  37914. /**
  37915. * Creates a new StereoscopicGamepadCamera
  37916. * @param name defines camera name
  37917. * @param position defines initial position
  37918. * @param interaxialDistance defines distance between each color axis
  37919. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  37920. * @param scene defines the hosting scene
  37921. */
  37922. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  37923. /**
  37924. * Gets camera class name
  37925. * @returns StereoscopicGamepadCamera
  37926. */
  37927. getClassName(): string;
  37928. }
  37929. }
  37930. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  37931. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  37932. import { Scene } from "babylonjs/scene";
  37933. import { Vector3 } from "babylonjs/Maths/math";
  37934. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  37935. /**
  37936. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  37937. * @see http://doc.babylonjs.com/features/cameras
  37938. */
  37939. export class StereoscopicUniversalCamera extends UniversalCamera {
  37940. /**
  37941. * Creates a new StereoscopicUniversalCamera
  37942. * @param name defines camera name
  37943. * @param position defines initial position
  37944. * @param interaxialDistance defines distance between each color axis
  37945. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  37946. * @param scene defines the hosting scene
  37947. */
  37948. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  37949. /**
  37950. * Gets camera class name
  37951. * @returns StereoscopicUniversalCamera
  37952. */
  37953. getClassName(): string;
  37954. }
  37955. }
  37956. declare module "babylonjs/Cameras/Stereoscopic/index" {
  37957. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  37958. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  37959. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  37960. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  37961. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  37962. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  37963. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  37964. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  37965. }
  37966. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  37967. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37968. import { Scene } from "babylonjs/scene";
  37969. import { Vector3 } from "babylonjs/Maths/math";
  37970. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  37971. /**
  37972. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  37973. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  37974. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  37975. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  37976. */
  37977. export class VirtualJoysticksCamera extends FreeCamera {
  37978. /**
  37979. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  37980. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  37981. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  37982. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  37983. * @param name Define the name of the camera in the scene
  37984. * @param position Define the start position of the camera in the scene
  37985. * @param scene Define the scene the camera belongs to
  37986. */
  37987. constructor(name: string, position: Vector3, scene: Scene);
  37988. /**
  37989. * Gets the current object class name.
  37990. * @return the class name
  37991. */
  37992. getClassName(): string;
  37993. }
  37994. }
  37995. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  37996. import { Matrix } from "babylonjs/Maths/math";
  37997. /**
  37998. * This represents all the required metrics to create a VR camera.
  37999. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  38000. */
  38001. export class VRCameraMetrics {
  38002. /**
  38003. * Define the horizontal resolution off the screen.
  38004. */
  38005. hResolution: number;
  38006. /**
  38007. * Define the vertical resolution off the screen.
  38008. */
  38009. vResolution: number;
  38010. /**
  38011. * Define the horizontal screen size.
  38012. */
  38013. hScreenSize: number;
  38014. /**
  38015. * Define the vertical screen size.
  38016. */
  38017. vScreenSize: number;
  38018. /**
  38019. * Define the vertical screen center position.
  38020. */
  38021. vScreenCenter: number;
  38022. /**
  38023. * Define the distance of the eyes to the screen.
  38024. */
  38025. eyeToScreenDistance: number;
  38026. /**
  38027. * Define the distance between both lenses
  38028. */
  38029. lensSeparationDistance: number;
  38030. /**
  38031. * Define the distance between both viewer's eyes.
  38032. */
  38033. interpupillaryDistance: number;
  38034. /**
  38035. * Define the distortion factor of the VR postprocess.
  38036. * Please, touch with care.
  38037. */
  38038. distortionK: number[];
  38039. /**
  38040. * Define the chromatic aberration correction factors for the VR post process.
  38041. */
  38042. chromaAbCorrection: number[];
  38043. /**
  38044. * Define the scale factor of the post process.
  38045. * The smaller the better but the slower.
  38046. */
  38047. postProcessScaleFactor: number;
  38048. /**
  38049. * Define an offset for the lens center.
  38050. */
  38051. lensCenterOffset: number;
  38052. /**
  38053. * Define if the current vr camera should compensate the distortion of the lense or not.
  38054. */
  38055. compensateDistortion: boolean;
  38056. /**
  38057. * Gets the rendering aspect ratio based on the provided resolutions.
  38058. */
  38059. readonly aspectRatio: number;
  38060. /**
  38061. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  38062. */
  38063. readonly aspectRatioFov: number;
  38064. /**
  38065. * @hidden
  38066. */
  38067. readonly leftHMatrix: Matrix;
  38068. /**
  38069. * @hidden
  38070. */
  38071. readonly rightHMatrix: Matrix;
  38072. /**
  38073. * @hidden
  38074. */
  38075. readonly leftPreViewMatrix: Matrix;
  38076. /**
  38077. * @hidden
  38078. */
  38079. readonly rightPreViewMatrix: Matrix;
  38080. /**
  38081. * Get the default VRMetrics based on the most generic setup.
  38082. * @returns the default vr metrics
  38083. */
  38084. static GetDefault(): VRCameraMetrics;
  38085. }
  38086. }
  38087. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  38088. /** @hidden */
  38089. export var vrDistortionCorrectionPixelShader: {
  38090. name: string;
  38091. shader: string;
  38092. };
  38093. }
  38094. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  38095. import { Camera } from "babylonjs/Cameras/camera";
  38096. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  38097. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  38098. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  38099. /**
  38100. * VRDistortionCorrectionPostProcess used for mobile VR
  38101. */
  38102. export class VRDistortionCorrectionPostProcess extends PostProcess {
  38103. private _isRightEye;
  38104. private _distortionFactors;
  38105. private _postProcessScaleFactor;
  38106. private _lensCenterOffset;
  38107. private _scaleIn;
  38108. private _scaleFactor;
  38109. private _lensCenter;
  38110. /**
  38111. * Initializes the VRDistortionCorrectionPostProcess
  38112. * @param name The name of the effect.
  38113. * @param camera The camera to apply the render pass to.
  38114. * @param isRightEye If this is for the right eye distortion
  38115. * @param vrMetrics All the required metrics for the VR camera
  38116. */
  38117. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  38118. }
  38119. }
  38120. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  38121. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  38122. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38123. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  38124. import { Scene } from "babylonjs/scene";
  38125. import { Vector3 } from "babylonjs/Maths/math";
  38126. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  38127. import "babylonjs/Cameras/RigModes/vrRigMode";
  38128. /**
  38129. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  38130. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38131. */
  38132. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  38133. /**
  38134. * Creates a new VRDeviceOrientationArcRotateCamera
  38135. * @param name defines camera name
  38136. * @param alpha defines the camera rotation along the logitudinal axis
  38137. * @param beta defines the camera rotation along the latitudinal axis
  38138. * @param radius defines the camera distance from its target
  38139. * @param target defines the camera target
  38140. * @param scene defines the scene the camera belongs to
  38141. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38142. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38143. */
  38144. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38145. /**
  38146. * Gets camera class name
  38147. * @returns VRDeviceOrientationArcRotateCamera
  38148. */
  38149. getClassName(): string;
  38150. }
  38151. }
  38152. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  38153. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  38154. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  38155. import { Scene } from "babylonjs/scene";
  38156. import { Vector3 } from "babylonjs/Maths/math";
  38157. import "babylonjs/Cameras/RigModes/vrRigMode";
  38158. /**
  38159. * Camera used to simulate VR rendering (based on FreeCamera)
  38160. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38161. */
  38162. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  38163. /**
  38164. * Creates a new VRDeviceOrientationFreeCamera
  38165. * @param name defines camera name
  38166. * @param position defines the start position of the camera
  38167. * @param scene defines the scene the camera belongs to
  38168. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38169. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38170. */
  38171. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38172. /**
  38173. * Gets camera class name
  38174. * @returns VRDeviceOrientationFreeCamera
  38175. */
  38176. getClassName(): string;
  38177. }
  38178. }
  38179. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  38180. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  38181. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  38182. import { Scene } from "babylonjs/scene";
  38183. import { Vector3 } from "babylonjs/Maths/math";
  38184. /**
  38185. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  38186. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38187. */
  38188. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  38189. /**
  38190. * Creates a new VRDeviceOrientationGamepadCamera
  38191. * @param name defines camera name
  38192. * @param position defines the start position of the camera
  38193. * @param scene defines the scene the camera belongs to
  38194. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38195. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38196. */
  38197. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38198. /**
  38199. * Gets camera class name
  38200. * @returns VRDeviceOrientationGamepadCamera
  38201. */
  38202. getClassName(): string;
  38203. }
  38204. }
  38205. declare module "babylonjs/Gamepads/xboxGamepad" {
  38206. import { Observable } from "babylonjs/Misc/observable";
  38207. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  38208. /**
  38209. * Defines supported buttons for XBox360 compatible gamepads
  38210. */
  38211. export enum Xbox360Button {
  38212. /** A */
  38213. A = 0,
  38214. /** B */
  38215. B = 1,
  38216. /** X */
  38217. X = 2,
  38218. /** Y */
  38219. Y = 3,
  38220. /** Start */
  38221. Start = 4,
  38222. /** Back */
  38223. Back = 5,
  38224. /** Left button */
  38225. LB = 6,
  38226. /** Right button */
  38227. RB = 7,
  38228. /** Left stick */
  38229. LeftStick = 8,
  38230. /** Right stick */
  38231. RightStick = 9
  38232. }
  38233. /** Defines values for XBox360 DPad */
  38234. export enum Xbox360Dpad {
  38235. /** Up */
  38236. Up = 0,
  38237. /** Down */
  38238. Down = 1,
  38239. /** Left */
  38240. Left = 2,
  38241. /** Right */
  38242. Right = 3
  38243. }
  38244. /**
  38245. * Defines a XBox360 gamepad
  38246. */
  38247. export class Xbox360Pad extends Gamepad {
  38248. private _leftTrigger;
  38249. private _rightTrigger;
  38250. private _onlefttriggerchanged;
  38251. private _onrighttriggerchanged;
  38252. private _onbuttondown;
  38253. private _onbuttonup;
  38254. private _ondpaddown;
  38255. private _ondpadup;
  38256. /** Observable raised when a button is pressed */
  38257. onButtonDownObservable: Observable<Xbox360Button>;
  38258. /** Observable raised when a button is released */
  38259. onButtonUpObservable: Observable<Xbox360Button>;
  38260. /** Observable raised when a pad is pressed */
  38261. onPadDownObservable: Observable<Xbox360Dpad>;
  38262. /** Observable raised when a pad is released */
  38263. onPadUpObservable: Observable<Xbox360Dpad>;
  38264. private _buttonA;
  38265. private _buttonB;
  38266. private _buttonX;
  38267. private _buttonY;
  38268. private _buttonBack;
  38269. private _buttonStart;
  38270. private _buttonLB;
  38271. private _buttonRB;
  38272. private _buttonLeftStick;
  38273. private _buttonRightStick;
  38274. private _dPadUp;
  38275. private _dPadDown;
  38276. private _dPadLeft;
  38277. private _dPadRight;
  38278. private _isXboxOnePad;
  38279. /**
  38280. * Creates a new XBox360 gamepad object
  38281. * @param id defines the id of this gamepad
  38282. * @param index defines its index
  38283. * @param gamepad defines the internal HTML gamepad object
  38284. * @param xboxOne defines if it is a XBox One gamepad
  38285. */
  38286. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  38287. /**
  38288. * Defines the callback to call when left trigger is pressed
  38289. * @param callback defines the callback to use
  38290. */
  38291. onlefttriggerchanged(callback: (value: number) => void): void;
  38292. /**
  38293. * Defines the callback to call when right trigger is pressed
  38294. * @param callback defines the callback to use
  38295. */
  38296. onrighttriggerchanged(callback: (value: number) => void): void;
  38297. /**
  38298. * Gets the left trigger value
  38299. */
  38300. /**
  38301. * Sets the left trigger value
  38302. */
  38303. leftTrigger: number;
  38304. /**
  38305. * Gets the right trigger value
  38306. */
  38307. /**
  38308. * Sets the right trigger value
  38309. */
  38310. rightTrigger: number;
  38311. /**
  38312. * Defines the callback to call when a button is pressed
  38313. * @param callback defines the callback to use
  38314. */
  38315. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  38316. /**
  38317. * Defines the callback to call when a button is released
  38318. * @param callback defines the callback to use
  38319. */
  38320. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  38321. /**
  38322. * Defines the callback to call when a pad is pressed
  38323. * @param callback defines the callback to use
  38324. */
  38325. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  38326. /**
  38327. * Defines the callback to call when a pad is released
  38328. * @param callback defines the callback to use
  38329. */
  38330. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  38331. private _setButtonValue;
  38332. private _setDPadValue;
  38333. /**
  38334. * Gets the value of the `A` button
  38335. */
  38336. /**
  38337. * Sets the value of the `A` button
  38338. */
  38339. buttonA: number;
  38340. /**
  38341. * Gets the value of the `B` button
  38342. */
  38343. /**
  38344. * Sets the value of the `B` button
  38345. */
  38346. buttonB: number;
  38347. /**
  38348. * Gets the value of the `X` button
  38349. */
  38350. /**
  38351. * Sets the value of the `X` button
  38352. */
  38353. buttonX: number;
  38354. /**
  38355. * Gets the value of the `Y` button
  38356. */
  38357. /**
  38358. * Sets the value of the `Y` button
  38359. */
  38360. buttonY: number;
  38361. /**
  38362. * Gets the value of the `Start` button
  38363. */
  38364. /**
  38365. * Sets the value of the `Start` button
  38366. */
  38367. buttonStart: number;
  38368. /**
  38369. * Gets the value of the `Back` button
  38370. */
  38371. /**
  38372. * Sets the value of the `Back` button
  38373. */
  38374. buttonBack: number;
  38375. /**
  38376. * Gets the value of the `Left` button
  38377. */
  38378. /**
  38379. * Sets the value of the `Left` button
  38380. */
  38381. buttonLB: number;
  38382. /**
  38383. * Gets the value of the `Right` button
  38384. */
  38385. /**
  38386. * Sets the value of the `Right` button
  38387. */
  38388. buttonRB: number;
  38389. /**
  38390. * Gets the value of the Left joystick
  38391. */
  38392. /**
  38393. * Sets the value of the Left joystick
  38394. */
  38395. buttonLeftStick: number;
  38396. /**
  38397. * Gets the value of the Right joystick
  38398. */
  38399. /**
  38400. * Sets the value of the Right joystick
  38401. */
  38402. buttonRightStick: number;
  38403. /**
  38404. * Gets the value of D-pad up
  38405. */
  38406. /**
  38407. * Sets the value of D-pad up
  38408. */
  38409. dPadUp: number;
  38410. /**
  38411. * Gets the value of D-pad down
  38412. */
  38413. /**
  38414. * Sets the value of D-pad down
  38415. */
  38416. dPadDown: number;
  38417. /**
  38418. * Gets the value of D-pad left
  38419. */
  38420. /**
  38421. * Sets the value of D-pad left
  38422. */
  38423. dPadLeft: number;
  38424. /**
  38425. * Gets the value of D-pad right
  38426. */
  38427. /**
  38428. * Sets the value of D-pad right
  38429. */
  38430. dPadRight: number;
  38431. /**
  38432. * Force the gamepad to synchronize with device values
  38433. */
  38434. update(): void;
  38435. /**
  38436. * Disposes the gamepad
  38437. */
  38438. dispose(): void;
  38439. }
  38440. }
  38441. declare module "babylonjs/Materials/pushMaterial" {
  38442. import { Nullable } from "babylonjs/types";
  38443. import { Scene } from "babylonjs/scene";
  38444. import { Matrix } from "babylonjs/Maths/math";
  38445. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38446. import { Mesh } from "babylonjs/Meshes/mesh";
  38447. import { Material } from "babylonjs/Materials/material";
  38448. import { Effect } from "babylonjs/Materials/effect";
  38449. /**
  38450. * Base class of materials working in push mode in babylon JS
  38451. * @hidden
  38452. */
  38453. export class PushMaterial extends Material {
  38454. protected _activeEffect: Effect;
  38455. protected _normalMatrix: Matrix;
  38456. /**
  38457. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  38458. * This means that the material can keep using a previous shader while a new one is being compiled.
  38459. * This is mostly used when shader parallel compilation is supported (true by default)
  38460. */
  38461. allowShaderHotSwapping: boolean;
  38462. constructor(name: string, scene: Scene);
  38463. getEffect(): Effect;
  38464. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  38465. /**
  38466. * Binds the given world matrix to the active effect
  38467. *
  38468. * @param world the matrix to bind
  38469. */
  38470. bindOnlyWorldMatrix(world: Matrix): void;
  38471. /**
  38472. * Binds the given normal matrix to the active effect
  38473. *
  38474. * @param normalMatrix the matrix to bind
  38475. */
  38476. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  38477. bind(world: Matrix, mesh?: Mesh): void;
  38478. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  38479. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  38480. }
  38481. }
  38482. declare module "babylonjs/Materials/materialFlags" {
  38483. /**
  38484. * This groups all the flags used to control the materials channel.
  38485. */
  38486. export class MaterialFlags {
  38487. private static _DiffuseTextureEnabled;
  38488. /**
  38489. * Are diffuse textures enabled in the application.
  38490. */
  38491. static DiffuseTextureEnabled: boolean;
  38492. private static _AmbientTextureEnabled;
  38493. /**
  38494. * Are ambient textures enabled in the application.
  38495. */
  38496. static AmbientTextureEnabled: boolean;
  38497. private static _OpacityTextureEnabled;
  38498. /**
  38499. * Are opacity textures enabled in the application.
  38500. */
  38501. static OpacityTextureEnabled: boolean;
  38502. private static _ReflectionTextureEnabled;
  38503. /**
  38504. * Are reflection textures enabled in the application.
  38505. */
  38506. static ReflectionTextureEnabled: boolean;
  38507. private static _EmissiveTextureEnabled;
  38508. /**
  38509. * Are emissive textures enabled in the application.
  38510. */
  38511. static EmissiveTextureEnabled: boolean;
  38512. private static _SpecularTextureEnabled;
  38513. /**
  38514. * Are specular textures enabled in the application.
  38515. */
  38516. static SpecularTextureEnabled: boolean;
  38517. private static _BumpTextureEnabled;
  38518. /**
  38519. * Are bump textures enabled in the application.
  38520. */
  38521. static BumpTextureEnabled: boolean;
  38522. private static _LightmapTextureEnabled;
  38523. /**
  38524. * Are lightmap textures enabled in the application.
  38525. */
  38526. static LightmapTextureEnabled: boolean;
  38527. private static _RefractionTextureEnabled;
  38528. /**
  38529. * Are refraction textures enabled in the application.
  38530. */
  38531. static RefractionTextureEnabled: boolean;
  38532. private static _ColorGradingTextureEnabled;
  38533. /**
  38534. * Are color grading textures enabled in the application.
  38535. */
  38536. static ColorGradingTextureEnabled: boolean;
  38537. private static _FresnelEnabled;
  38538. /**
  38539. * Are fresnels enabled in the application.
  38540. */
  38541. static FresnelEnabled: boolean;
  38542. private static _ClearCoatTextureEnabled;
  38543. /**
  38544. * Are clear coat textures enabled in the application.
  38545. */
  38546. static ClearCoatTextureEnabled: boolean;
  38547. private static _ClearCoatBumpTextureEnabled;
  38548. /**
  38549. * Are clear coat bump textures enabled in the application.
  38550. */
  38551. static ClearCoatBumpTextureEnabled: boolean;
  38552. private static _ClearCoatTintTextureEnabled;
  38553. /**
  38554. * Are clear coat tint textures enabled in the application.
  38555. */
  38556. static ClearCoatTintTextureEnabled: boolean;
  38557. }
  38558. }
  38559. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  38560. /** @hidden */
  38561. export var defaultFragmentDeclaration: {
  38562. name: string;
  38563. shader: string;
  38564. };
  38565. }
  38566. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  38567. /** @hidden */
  38568. export var defaultUboDeclaration: {
  38569. name: string;
  38570. shader: string;
  38571. };
  38572. }
  38573. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  38574. /** @hidden */
  38575. export var lightFragmentDeclaration: {
  38576. name: string;
  38577. shader: string;
  38578. };
  38579. }
  38580. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  38581. /** @hidden */
  38582. export var lightUboDeclaration: {
  38583. name: string;
  38584. shader: string;
  38585. };
  38586. }
  38587. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  38588. /** @hidden */
  38589. export var lightsFragmentFunctions: {
  38590. name: string;
  38591. shader: string;
  38592. };
  38593. }
  38594. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  38595. /** @hidden */
  38596. export var shadowsFragmentFunctions: {
  38597. name: string;
  38598. shader: string;
  38599. };
  38600. }
  38601. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  38602. /** @hidden */
  38603. export var fresnelFunction: {
  38604. name: string;
  38605. shader: string;
  38606. };
  38607. }
  38608. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  38609. /** @hidden */
  38610. export var reflectionFunction: {
  38611. name: string;
  38612. shader: string;
  38613. };
  38614. }
  38615. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  38616. /** @hidden */
  38617. export var bumpFragmentFunctions: {
  38618. name: string;
  38619. shader: string;
  38620. };
  38621. }
  38622. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  38623. /** @hidden */
  38624. export var logDepthDeclaration: {
  38625. name: string;
  38626. shader: string;
  38627. };
  38628. }
  38629. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  38630. /** @hidden */
  38631. export var bumpFragment: {
  38632. name: string;
  38633. shader: string;
  38634. };
  38635. }
  38636. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  38637. /** @hidden */
  38638. export var depthPrePass: {
  38639. name: string;
  38640. shader: string;
  38641. };
  38642. }
  38643. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  38644. /** @hidden */
  38645. export var lightFragment: {
  38646. name: string;
  38647. shader: string;
  38648. };
  38649. }
  38650. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  38651. /** @hidden */
  38652. export var logDepthFragment: {
  38653. name: string;
  38654. shader: string;
  38655. };
  38656. }
  38657. declare module "babylonjs/Shaders/default.fragment" {
  38658. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  38659. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  38660. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  38661. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  38662. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  38663. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  38664. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  38665. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  38666. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  38667. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  38668. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  38669. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  38670. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  38671. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  38672. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  38673. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  38674. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  38675. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  38676. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  38677. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  38678. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  38679. /** @hidden */
  38680. export var defaultPixelShader: {
  38681. name: string;
  38682. shader: string;
  38683. };
  38684. }
  38685. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  38686. /** @hidden */
  38687. export var defaultVertexDeclaration: {
  38688. name: string;
  38689. shader: string;
  38690. };
  38691. }
  38692. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  38693. /** @hidden */
  38694. export var bumpVertexDeclaration: {
  38695. name: string;
  38696. shader: string;
  38697. };
  38698. }
  38699. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  38700. /** @hidden */
  38701. export var bumpVertex: {
  38702. name: string;
  38703. shader: string;
  38704. };
  38705. }
  38706. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  38707. /** @hidden */
  38708. export var fogVertex: {
  38709. name: string;
  38710. shader: string;
  38711. };
  38712. }
  38713. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  38714. /** @hidden */
  38715. export var shadowsVertex: {
  38716. name: string;
  38717. shader: string;
  38718. };
  38719. }
  38720. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  38721. /** @hidden */
  38722. export var pointCloudVertex: {
  38723. name: string;
  38724. shader: string;
  38725. };
  38726. }
  38727. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  38728. /** @hidden */
  38729. export var logDepthVertex: {
  38730. name: string;
  38731. shader: string;
  38732. };
  38733. }
  38734. declare module "babylonjs/Shaders/default.vertex" {
  38735. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  38736. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  38737. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  38738. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  38739. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  38740. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  38741. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  38742. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  38743. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  38744. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  38745. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  38746. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  38747. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  38748. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  38749. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  38750. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  38751. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  38752. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  38753. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  38754. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  38755. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  38756. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  38757. /** @hidden */
  38758. export var defaultVertexShader: {
  38759. name: string;
  38760. shader: string;
  38761. };
  38762. }
  38763. declare module "babylonjs/Materials/standardMaterial" {
  38764. import { SmartArray } from "babylonjs/Misc/smartArray";
  38765. import { IAnimatable } from "babylonjs/Misc/tools";
  38766. import { Nullable } from "babylonjs/types";
  38767. import { Scene } from "babylonjs/scene";
  38768. import { Matrix, Color3 } from "babylonjs/Maths/math";
  38769. import { SubMesh } from "babylonjs/Meshes/subMesh";
  38770. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38771. import { Mesh } from "babylonjs/Meshes/mesh";
  38772. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  38773. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  38774. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  38775. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  38776. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  38777. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  38778. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  38779. import "babylonjs/Shaders/default.fragment";
  38780. import "babylonjs/Shaders/default.vertex";
  38781. /** @hidden */
  38782. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  38783. MAINUV1: boolean;
  38784. MAINUV2: boolean;
  38785. DIFFUSE: boolean;
  38786. DIFFUSEDIRECTUV: number;
  38787. AMBIENT: boolean;
  38788. AMBIENTDIRECTUV: number;
  38789. OPACITY: boolean;
  38790. OPACITYDIRECTUV: number;
  38791. OPACITYRGB: boolean;
  38792. REFLECTION: boolean;
  38793. EMISSIVE: boolean;
  38794. EMISSIVEDIRECTUV: number;
  38795. SPECULAR: boolean;
  38796. SPECULARDIRECTUV: number;
  38797. BUMP: boolean;
  38798. BUMPDIRECTUV: number;
  38799. PARALLAX: boolean;
  38800. PARALLAXOCCLUSION: boolean;
  38801. SPECULAROVERALPHA: boolean;
  38802. CLIPPLANE: boolean;
  38803. CLIPPLANE2: boolean;
  38804. CLIPPLANE3: boolean;
  38805. CLIPPLANE4: boolean;
  38806. ALPHATEST: boolean;
  38807. DEPTHPREPASS: boolean;
  38808. ALPHAFROMDIFFUSE: boolean;
  38809. POINTSIZE: boolean;
  38810. FOG: boolean;
  38811. SPECULARTERM: boolean;
  38812. DIFFUSEFRESNEL: boolean;
  38813. OPACITYFRESNEL: boolean;
  38814. REFLECTIONFRESNEL: boolean;
  38815. REFRACTIONFRESNEL: boolean;
  38816. EMISSIVEFRESNEL: boolean;
  38817. FRESNEL: boolean;
  38818. NORMAL: boolean;
  38819. UV1: boolean;
  38820. UV2: boolean;
  38821. VERTEXCOLOR: boolean;
  38822. VERTEXALPHA: boolean;
  38823. NUM_BONE_INFLUENCERS: number;
  38824. BonesPerMesh: number;
  38825. BONETEXTURE: boolean;
  38826. INSTANCES: boolean;
  38827. GLOSSINESS: boolean;
  38828. ROUGHNESS: boolean;
  38829. EMISSIVEASILLUMINATION: boolean;
  38830. LINKEMISSIVEWITHDIFFUSE: boolean;
  38831. REFLECTIONFRESNELFROMSPECULAR: boolean;
  38832. LIGHTMAP: boolean;
  38833. LIGHTMAPDIRECTUV: number;
  38834. OBJECTSPACE_NORMALMAP: boolean;
  38835. USELIGHTMAPASSHADOWMAP: boolean;
  38836. REFLECTIONMAP_3D: boolean;
  38837. REFLECTIONMAP_SPHERICAL: boolean;
  38838. REFLECTIONMAP_PLANAR: boolean;
  38839. REFLECTIONMAP_CUBIC: boolean;
  38840. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  38841. REFLECTIONMAP_PROJECTION: boolean;
  38842. REFLECTIONMAP_SKYBOX: boolean;
  38843. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  38844. REFLECTIONMAP_EXPLICIT: boolean;
  38845. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  38846. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  38847. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  38848. INVERTCUBICMAP: boolean;
  38849. LOGARITHMICDEPTH: boolean;
  38850. REFRACTION: boolean;
  38851. REFRACTIONMAP_3D: boolean;
  38852. REFLECTIONOVERALPHA: boolean;
  38853. TWOSIDEDLIGHTING: boolean;
  38854. SHADOWFLOAT: boolean;
  38855. MORPHTARGETS: boolean;
  38856. MORPHTARGETS_NORMAL: boolean;
  38857. MORPHTARGETS_TANGENT: boolean;
  38858. NUM_MORPH_INFLUENCERS: number;
  38859. NONUNIFORMSCALING: boolean;
  38860. PREMULTIPLYALPHA: boolean;
  38861. IMAGEPROCESSING: boolean;
  38862. VIGNETTE: boolean;
  38863. VIGNETTEBLENDMODEMULTIPLY: boolean;
  38864. VIGNETTEBLENDMODEOPAQUE: boolean;
  38865. TONEMAPPING: boolean;
  38866. TONEMAPPING_ACES: boolean;
  38867. CONTRAST: boolean;
  38868. COLORCURVES: boolean;
  38869. COLORGRADING: boolean;
  38870. COLORGRADING3D: boolean;
  38871. SAMPLER3DGREENDEPTH: boolean;
  38872. SAMPLER3DBGRMAP: boolean;
  38873. IMAGEPROCESSINGPOSTPROCESS: boolean;
  38874. /**
  38875. * If the reflection texture on this material is in linear color space
  38876. * @hidden
  38877. */
  38878. IS_REFLECTION_LINEAR: boolean;
  38879. /**
  38880. * If the refraction texture on this material is in linear color space
  38881. * @hidden
  38882. */
  38883. IS_REFRACTION_LINEAR: boolean;
  38884. EXPOSURE: boolean;
  38885. constructor();
  38886. setReflectionMode(modeToEnable: string): void;
  38887. }
  38888. /**
  38889. * This is the default material used in Babylon. It is the best trade off between quality
  38890. * and performances.
  38891. * @see http://doc.babylonjs.com/babylon101/materials
  38892. */
  38893. export class StandardMaterial extends PushMaterial {
  38894. private _diffuseTexture;
  38895. /**
  38896. * The basic texture of the material as viewed under a light.
  38897. */
  38898. diffuseTexture: Nullable<BaseTexture>;
  38899. private _ambientTexture;
  38900. /**
  38901. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  38902. */
  38903. ambientTexture: Nullable<BaseTexture>;
  38904. private _opacityTexture;
  38905. /**
  38906. * Define the transparency of the material from a texture.
  38907. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  38908. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  38909. */
  38910. opacityTexture: Nullable<BaseTexture>;
  38911. private _reflectionTexture;
  38912. /**
  38913. * Define the texture used to display the reflection.
  38914. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  38915. */
  38916. reflectionTexture: Nullable<BaseTexture>;
  38917. private _emissiveTexture;
  38918. /**
  38919. * Define texture of the material as if self lit.
  38920. * This will be mixed in the final result even in the absence of light.
  38921. */
  38922. emissiveTexture: Nullable<BaseTexture>;
  38923. private _specularTexture;
  38924. /**
  38925. * Define how the color and intensity of the highlight given by the light in the material.
  38926. */
  38927. specularTexture: Nullable<BaseTexture>;
  38928. private _bumpTexture;
  38929. /**
  38930. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  38931. * 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.
  38932. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  38933. */
  38934. bumpTexture: Nullable<BaseTexture>;
  38935. private _lightmapTexture;
  38936. /**
  38937. * Complex lighting can be computationally expensive to compute at runtime.
  38938. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  38939. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  38940. */
  38941. lightmapTexture: Nullable<BaseTexture>;
  38942. private _refractionTexture;
  38943. /**
  38944. * Define the texture used to display the refraction.
  38945. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  38946. */
  38947. refractionTexture: Nullable<BaseTexture>;
  38948. /**
  38949. * The color of the material lit by the environmental background lighting.
  38950. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  38951. */
  38952. ambientColor: Color3;
  38953. /**
  38954. * The basic color of the material as viewed under a light.
  38955. */
  38956. diffuseColor: Color3;
  38957. /**
  38958. * Define how the color and intensity of the highlight given by the light in the material.
  38959. */
  38960. specularColor: Color3;
  38961. /**
  38962. * Define the color of the material as if self lit.
  38963. * This will be mixed in the final result even in the absence of light.
  38964. */
  38965. emissiveColor: Color3;
  38966. /**
  38967. * Defines how sharp are the highlights in the material.
  38968. * The bigger the value the sharper giving a more glossy feeling to the result.
  38969. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  38970. */
  38971. specularPower: number;
  38972. private _useAlphaFromDiffuseTexture;
  38973. /**
  38974. * Does the transparency come from the diffuse texture alpha channel.
  38975. */
  38976. useAlphaFromDiffuseTexture: boolean;
  38977. private _useEmissiveAsIllumination;
  38978. /**
  38979. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  38980. */
  38981. useEmissiveAsIllumination: boolean;
  38982. private _linkEmissiveWithDiffuse;
  38983. /**
  38984. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  38985. * the emissive level when the final color is close to one.
  38986. */
  38987. linkEmissiveWithDiffuse: boolean;
  38988. private _useSpecularOverAlpha;
  38989. /**
  38990. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  38991. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  38992. */
  38993. useSpecularOverAlpha: boolean;
  38994. private _useReflectionOverAlpha;
  38995. /**
  38996. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  38997. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  38998. */
  38999. useReflectionOverAlpha: boolean;
  39000. private _disableLighting;
  39001. /**
  39002. * Does lights from the scene impacts this material.
  39003. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  39004. */
  39005. disableLighting: boolean;
  39006. private _useObjectSpaceNormalMap;
  39007. /**
  39008. * Allows using an object space normal map (instead of tangent space).
  39009. */
  39010. useObjectSpaceNormalMap: boolean;
  39011. private _useParallax;
  39012. /**
  39013. * Is parallax enabled or not.
  39014. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  39015. */
  39016. useParallax: boolean;
  39017. private _useParallaxOcclusion;
  39018. /**
  39019. * Is parallax occlusion enabled or not.
  39020. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  39021. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  39022. */
  39023. useParallaxOcclusion: boolean;
  39024. /**
  39025. * 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.
  39026. */
  39027. parallaxScaleBias: number;
  39028. private _roughness;
  39029. /**
  39030. * Helps to define how blurry the reflections should appears in the material.
  39031. */
  39032. roughness: number;
  39033. /**
  39034. * In case of refraction, define the value of the indice of refraction.
  39035. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39036. */
  39037. indexOfRefraction: number;
  39038. /**
  39039. * Invert the refraction texture alongside the y axis.
  39040. * It can be useful with procedural textures or probe for instance.
  39041. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39042. */
  39043. invertRefractionY: boolean;
  39044. /**
  39045. * Defines the alpha limits in alpha test mode.
  39046. */
  39047. alphaCutOff: number;
  39048. private _useLightmapAsShadowmap;
  39049. /**
  39050. * In case of light mapping, define whether the map contains light or shadow informations.
  39051. */
  39052. useLightmapAsShadowmap: boolean;
  39053. private _diffuseFresnelParameters;
  39054. /**
  39055. * Define the diffuse fresnel parameters of the material.
  39056. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39057. */
  39058. diffuseFresnelParameters: FresnelParameters;
  39059. private _opacityFresnelParameters;
  39060. /**
  39061. * Define the opacity fresnel parameters of the material.
  39062. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39063. */
  39064. opacityFresnelParameters: FresnelParameters;
  39065. private _reflectionFresnelParameters;
  39066. /**
  39067. * Define the reflection fresnel parameters of the material.
  39068. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39069. */
  39070. reflectionFresnelParameters: FresnelParameters;
  39071. private _refractionFresnelParameters;
  39072. /**
  39073. * Define the refraction fresnel parameters of the material.
  39074. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39075. */
  39076. refractionFresnelParameters: FresnelParameters;
  39077. private _emissiveFresnelParameters;
  39078. /**
  39079. * Define the emissive fresnel parameters of the material.
  39080. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39081. */
  39082. emissiveFresnelParameters: FresnelParameters;
  39083. private _useReflectionFresnelFromSpecular;
  39084. /**
  39085. * If true automatically deducts the fresnels values from the material specularity.
  39086. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39087. */
  39088. useReflectionFresnelFromSpecular: boolean;
  39089. private _useGlossinessFromSpecularMapAlpha;
  39090. /**
  39091. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  39092. */
  39093. useGlossinessFromSpecularMapAlpha: boolean;
  39094. private _maxSimultaneousLights;
  39095. /**
  39096. * Defines the maximum number of lights that can be used in the material
  39097. */
  39098. maxSimultaneousLights: number;
  39099. private _invertNormalMapX;
  39100. /**
  39101. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  39102. */
  39103. invertNormalMapX: boolean;
  39104. private _invertNormalMapY;
  39105. /**
  39106. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  39107. */
  39108. invertNormalMapY: boolean;
  39109. private _twoSidedLighting;
  39110. /**
  39111. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  39112. */
  39113. twoSidedLighting: boolean;
  39114. /**
  39115. * Default configuration related to image processing available in the standard Material.
  39116. */
  39117. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  39118. /**
  39119. * Gets the image processing configuration used either in this material.
  39120. */
  39121. /**
  39122. * Sets the Default image processing configuration used either in the this material.
  39123. *
  39124. * If sets to null, the scene one is in use.
  39125. */
  39126. imageProcessingConfiguration: ImageProcessingConfiguration;
  39127. /**
  39128. * Keep track of the image processing observer to allow dispose and replace.
  39129. */
  39130. private _imageProcessingObserver;
  39131. /**
  39132. * Attaches a new image processing configuration to the Standard Material.
  39133. * @param configuration
  39134. */
  39135. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  39136. /**
  39137. * Gets wether the color curves effect is enabled.
  39138. */
  39139. /**
  39140. * Sets wether the color curves effect is enabled.
  39141. */
  39142. cameraColorCurvesEnabled: boolean;
  39143. /**
  39144. * Gets wether the color grading effect is enabled.
  39145. */
  39146. /**
  39147. * Gets wether the color grading effect is enabled.
  39148. */
  39149. cameraColorGradingEnabled: boolean;
  39150. /**
  39151. * Gets wether tonemapping is enabled or not.
  39152. */
  39153. /**
  39154. * Sets wether tonemapping is enabled or not
  39155. */
  39156. cameraToneMappingEnabled: boolean;
  39157. /**
  39158. * The camera exposure used on this material.
  39159. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  39160. * This corresponds to a photographic exposure.
  39161. */
  39162. /**
  39163. * The camera exposure used on this material.
  39164. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  39165. * This corresponds to a photographic exposure.
  39166. */
  39167. cameraExposure: number;
  39168. /**
  39169. * Gets The camera contrast used on this material.
  39170. */
  39171. /**
  39172. * Sets The camera contrast used on this material.
  39173. */
  39174. cameraContrast: number;
  39175. /**
  39176. * Gets the Color Grading 2D Lookup Texture.
  39177. */
  39178. /**
  39179. * Sets the Color Grading 2D Lookup Texture.
  39180. */
  39181. cameraColorGradingTexture: Nullable<BaseTexture>;
  39182. /**
  39183. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  39184. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  39185. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  39186. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  39187. */
  39188. /**
  39189. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  39190. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  39191. * 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;
  39192. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  39193. */
  39194. cameraColorCurves: Nullable<ColorCurves>;
  39195. /**
  39196. * Custom callback helping to override the default shader used in the material.
  39197. */
  39198. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  39199. protected _renderTargets: SmartArray<RenderTargetTexture>;
  39200. protected _worldViewProjectionMatrix: Matrix;
  39201. protected _globalAmbientColor: Color3;
  39202. protected _useLogarithmicDepth: boolean;
  39203. /**
  39204. * Instantiates a new standard material.
  39205. * This is the default material used in Babylon. It is the best trade off between quality
  39206. * and performances.
  39207. * @see http://doc.babylonjs.com/babylon101/materials
  39208. * @param name Define the name of the material in the scene
  39209. * @param scene Define the scene the material belong to
  39210. */
  39211. constructor(name: string, scene: Scene);
  39212. /**
  39213. * Gets a boolean indicating that current material needs to register RTT
  39214. */
  39215. readonly hasRenderTargetTextures: boolean;
  39216. /**
  39217. * Gets the current class name of the material e.g. "StandardMaterial"
  39218. * Mainly use in serialization.
  39219. * @returns the class name
  39220. */
  39221. getClassName(): string;
  39222. /**
  39223. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  39224. * You can try switching to logarithmic depth.
  39225. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  39226. */
  39227. useLogarithmicDepth: boolean;
  39228. /**
  39229. * Specifies if the material will require alpha blending
  39230. * @returns a boolean specifying if alpha blending is needed
  39231. */
  39232. needAlphaBlending(): boolean;
  39233. /**
  39234. * Specifies if this material should be rendered in alpha test mode
  39235. * @returns a boolean specifying if an alpha test is needed.
  39236. */
  39237. needAlphaTesting(): boolean;
  39238. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  39239. /**
  39240. * Get the texture used for alpha test purpose.
  39241. * @returns the diffuse texture in case of the standard material.
  39242. */
  39243. getAlphaTestTexture(): Nullable<BaseTexture>;
  39244. /**
  39245. * Get if the submesh is ready to be used and all its information available.
  39246. * Child classes can use it to update shaders
  39247. * @param mesh defines the mesh to check
  39248. * @param subMesh defines which submesh to check
  39249. * @param useInstances specifies that instances should be used
  39250. * @returns a boolean indicating that the submesh is ready or not
  39251. */
  39252. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  39253. /**
  39254. * Builds the material UBO layouts.
  39255. * Used internally during the effect preparation.
  39256. */
  39257. buildUniformLayout(): void;
  39258. /**
  39259. * Unbinds the material from the mesh
  39260. */
  39261. unbind(): void;
  39262. /**
  39263. * Binds the submesh to this material by preparing the effect and shader to draw
  39264. * @param world defines the world transformation matrix
  39265. * @param mesh defines the mesh containing the submesh
  39266. * @param subMesh defines the submesh to bind the material to
  39267. */
  39268. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  39269. /**
  39270. * Get the list of animatables in the material.
  39271. * @returns the list of animatables object used in the material
  39272. */
  39273. getAnimatables(): IAnimatable[];
  39274. /**
  39275. * Gets the active textures from the material
  39276. * @returns an array of textures
  39277. */
  39278. getActiveTextures(): BaseTexture[];
  39279. /**
  39280. * Specifies if the material uses a texture
  39281. * @param texture defines the texture to check against the material
  39282. * @returns a boolean specifying if the material uses the texture
  39283. */
  39284. hasTexture(texture: BaseTexture): boolean;
  39285. /**
  39286. * Disposes the material
  39287. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  39288. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  39289. */
  39290. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  39291. /**
  39292. * Makes a duplicate of the material, and gives it a new name
  39293. * @param name defines the new name for the duplicated material
  39294. * @returns the cloned material
  39295. */
  39296. clone(name: string): StandardMaterial;
  39297. /**
  39298. * Serializes this material in a JSON representation
  39299. * @returns the serialized material object
  39300. */
  39301. serialize(): any;
  39302. /**
  39303. * Creates a standard material from parsed material data
  39304. * @param source defines the JSON representation of the material
  39305. * @param scene defines the hosting scene
  39306. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  39307. * @returns a new standard material
  39308. */
  39309. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  39310. /**
  39311. * Are diffuse textures enabled in the application.
  39312. */
  39313. static DiffuseTextureEnabled: boolean;
  39314. /**
  39315. * Are ambient textures enabled in the application.
  39316. */
  39317. static AmbientTextureEnabled: boolean;
  39318. /**
  39319. * Are opacity textures enabled in the application.
  39320. */
  39321. static OpacityTextureEnabled: boolean;
  39322. /**
  39323. * Are reflection textures enabled in the application.
  39324. */
  39325. static ReflectionTextureEnabled: boolean;
  39326. /**
  39327. * Are emissive textures enabled in the application.
  39328. */
  39329. static EmissiveTextureEnabled: boolean;
  39330. /**
  39331. * Are specular textures enabled in the application.
  39332. */
  39333. static SpecularTextureEnabled: boolean;
  39334. /**
  39335. * Are bump textures enabled in the application.
  39336. */
  39337. static BumpTextureEnabled: boolean;
  39338. /**
  39339. * Are lightmap textures enabled in the application.
  39340. */
  39341. static LightmapTextureEnabled: boolean;
  39342. /**
  39343. * Are refraction textures enabled in the application.
  39344. */
  39345. static RefractionTextureEnabled: boolean;
  39346. /**
  39347. * Are color grading textures enabled in the application.
  39348. */
  39349. static ColorGradingTextureEnabled: boolean;
  39350. /**
  39351. * Are fresnels enabled in the application.
  39352. */
  39353. static FresnelEnabled: boolean;
  39354. }
  39355. }
  39356. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  39357. import { Scene } from "babylonjs/scene";
  39358. import { Texture } from "babylonjs/Materials/Textures/texture";
  39359. /**
  39360. * A class extending Texture allowing drawing on a texture
  39361. * @see http://doc.babylonjs.com/how_to/dynamictexture
  39362. */
  39363. export class DynamicTexture extends Texture {
  39364. private _generateMipMaps;
  39365. private _canvas;
  39366. private _context;
  39367. private _engine;
  39368. /**
  39369. * Creates a DynamicTexture
  39370. * @param name defines the name of the texture
  39371. * @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
  39372. * @param scene defines the scene where you want the texture
  39373. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  39374. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  39375. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  39376. */
  39377. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  39378. /**
  39379. * Get the current class name of the texture useful for serialization or dynamic coding.
  39380. * @returns "DynamicTexture"
  39381. */
  39382. getClassName(): string;
  39383. /**
  39384. * Gets the current state of canRescale
  39385. */
  39386. readonly canRescale: boolean;
  39387. private _recreate;
  39388. /**
  39389. * Scales the texture
  39390. * @param ratio the scale factor to apply to both width and height
  39391. */
  39392. scale(ratio: number): void;
  39393. /**
  39394. * Resizes the texture
  39395. * @param width the new width
  39396. * @param height the new height
  39397. */
  39398. scaleTo(width: number, height: number): void;
  39399. /**
  39400. * Gets the context of the canvas used by the texture
  39401. * @returns the canvas context of the dynamic texture
  39402. */
  39403. getContext(): CanvasRenderingContext2D;
  39404. /**
  39405. * Clears the texture
  39406. */
  39407. clear(): void;
  39408. /**
  39409. * Updates the texture
  39410. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  39411. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  39412. */
  39413. update(invertY?: boolean, premulAlpha?: boolean): void;
  39414. /**
  39415. * Draws text onto the texture
  39416. * @param text defines the text to be drawn
  39417. * @param x defines the placement of the text from the left
  39418. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  39419. * @param font defines the font to be used with font-style, font-size, font-name
  39420. * @param color defines the color used for the text
  39421. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  39422. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  39423. * @param update defines whether texture is immediately update (default is true)
  39424. */
  39425. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  39426. /**
  39427. * Clones the texture
  39428. * @returns the clone of the texture.
  39429. */
  39430. clone(): DynamicTexture;
  39431. /**
  39432. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  39433. * @returns a serialized dynamic texture object
  39434. */
  39435. serialize(): any;
  39436. /** @hidden */
  39437. _rebuild(): void;
  39438. }
  39439. }
  39440. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  39441. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  39442. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  39443. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  39444. /** @hidden */
  39445. export var imageProcessingPixelShader: {
  39446. name: string;
  39447. shader: string;
  39448. };
  39449. }
  39450. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  39451. import { Nullable } from "babylonjs/types";
  39452. import { Color4 } from "babylonjs/Maths/math";
  39453. import { Camera } from "babylonjs/Cameras/camera";
  39454. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  39455. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  39456. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  39457. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  39458. import { Engine } from "babylonjs/Engines/engine";
  39459. import "babylonjs/Shaders/imageProcessing.fragment";
  39460. import "babylonjs/Shaders/postprocess.vertex";
  39461. /**
  39462. * ImageProcessingPostProcess
  39463. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  39464. */
  39465. export class ImageProcessingPostProcess extends PostProcess {
  39466. /**
  39467. * Default configuration related to image processing available in the PBR Material.
  39468. */
  39469. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  39470. /**
  39471. * Gets the image processing configuration used either in this material.
  39472. */
  39473. /**
  39474. * Sets the Default image processing configuration used either in the this material.
  39475. *
  39476. * If sets to null, the scene one is in use.
  39477. */
  39478. imageProcessingConfiguration: ImageProcessingConfiguration;
  39479. /**
  39480. * Keep track of the image processing observer to allow dispose and replace.
  39481. */
  39482. private _imageProcessingObserver;
  39483. /**
  39484. * Attaches a new image processing configuration to the PBR Material.
  39485. * @param configuration
  39486. */
  39487. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  39488. /**
  39489. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  39490. */
  39491. /**
  39492. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  39493. */
  39494. colorCurves: Nullable<ColorCurves>;
  39495. /**
  39496. * Gets wether the color curves effect is enabled.
  39497. */
  39498. /**
  39499. * Sets wether the color curves effect is enabled.
  39500. */
  39501. colorCurvesEnabled: boolean;
  39502. /**
  39503. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  39504. */
  39505. /**
  39506. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  39507. */
  39508. colorGradingTexture: Nullable<BaseTexture>;
  39509. /**
  39510. * Gets wether the color grading effect is enabled.
  39511. */
  39512. /**
  39513. * Gets wether the color grading effect is enabled.
  39514. */
  39515. colorGradingEnabled: boolean;
  39516. /**
  39517. * Gets exposure used in the effect.
  39518. */
  39519. /**
  39520. * Sets exposure used in the effect.
  39521. */
  39522. exposure: number;
  39523. /**
  39524. * Gets wether tonemapping is enabled or not.
  39525. */
  39526. /**
  39527. * Sets wether tonemapping is enabled or not
  39528. */
  39529. toneMappingEnabled: boolean;
  39530. /**
  39531. * Gets the type of tone mapping effect.
  39532. */
  39533. /**
  39534. * Sets the type of tone mapping effect.
  39535. */
  39536. toneMappingType: number;
  39537. /**
  39538. * Gets contrast used in the effect.
  39539. */
  39540. /**
  39541. * Sets contrast used in the effect.
  39542. */
  39543. contrast: number;
  39544. /**
  39545. * Gets Vignette stretch size.
  39546. */
  39547. /**
  39548. * Sets Vignette stretch size.
  39549. */
  39550. vignetteStretch: number;
  39551. /**
  39552. * Gets Vignette centre X Offset.
  39553. */
  39554. /**
  39555. * Sets Vignette centre X Offset.
  39556. */
  39557. vignetteCentreX: number;
  39558. /**
  39559. * Gets Vignette centre Y Offset.
  39560. */
  39561. /**
  39562. * Sets Vignette centre Y Offset.
  39563. */
  39564. vignetteCentreY: number;
  39565. /**
  39566. * Gets Vignette weight or intensity of the vignette effect.
  39567. */
  39568. /**
  39569. * Sets Vignette weight or intensity of the vignette effect.
  39570. */
  39571. vignetteWeight: number;
  39572. /**
  39573. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  39574. * if vignetteEnabled is set to true.
  39575. */
  39576. /**
  39577. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  39578. * if vignetteEnabled is set to true.
  39579. */
  39580. vignetteColor: Color4;
  39581. /**
  39582. * Gets Camera field of view used by the Vignette effect.
  39583. */
  39584. /**
  39585. * Sets Camera field of view used by the Vignette effect.
  39586. */
  39587. vignetteCameraFov: number;
  39588. /**
  39589. * Gets the vignette blend mode allowing different kind of effect.
  39590. */
  39591. /**
  39592. * Sets the vignette blend mode allowing different kind of effect.
  39593. */
  39594. vignetteBlendMode: number;
  39595. /**
  39596. * Gets wether the vignette effect is enabled.
  39597. */
  39598. /**
  39599. * Sets wether the vignette effect is enabled.
  39600. */
  39601. vignetteEnabled: boolean;
  39602. private _fromLinearSpace;
  39603. /**
  39604. * Gets wether the input of the processing is in Gamma or Linear Space.
  39605. */
  39606. /**
  39607. * Sets wether the input of the processing is in Gamma or Linear Space.
  39608. */
  39609. fromLinearSpace: boolean;
  39610. /**
  39611. * Defines cache preventing GC.
  39612. */
  39613. private _defines;
  39614. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  39615. /**
  39616. * "ImageProcessingPostProcess"
  39617. * @returns "ImageProcessingPostProcess"
  39618. */
  39619. getClassName(): string;
  39620. protected _updateParameters(): void;
  39621. dispose(camera?: Camera): void;
  39622. }
  39623. }
  39624. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  39625. import { Scene } from "babylonjs/scene";
  39626. import { Color3 } from "babylonjs/Maths/math";
  39627. import { Mesh } from "babylonjs/Meshes/mesh";
  39628. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  39629. /**
  39630. * Class containing static functions to help procedurally build meshes
  39631. */
  39632. export class GroundBuilder {
  39633. /**
  39634. * Creates a ground mesh
  39635. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  39636. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  39637. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  39638. * @param name defines the name of the mesh
  39639. * @param options defines the options used to create the mesh
  39640. * @param scene defines the hosting scene
  39641. * @returns the ground mesh
  39642. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  39643. */
  39644. static CreateGround(name: string, options: {
  39645. width?: number;
  39646. height?: number;
  39647. subdivisions?: number;
  39648. subdivisionsX?: number;
  39649. subdivisionsY?: number;
  39650. updatable?: boolean;
  39651. }, scene: any): Mesh;
  39652. /**
  39653. * Creates a tiled ground mesh
  39654. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  39655. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  39656. * * 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
  39657. * * 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
  39658. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39659. * @param name defines the name of the mesh
  39660. * @param options defines the options used to create the mesh
  39661. * @param scene defines the hosting scene
  39662. * @returns the tiled ground mesh
  39663. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  39664. */
  39665. static CreateTiledGround(name: string, options: {
  39666. xmin: number;
  39667. zmin: number;
  39668. xmax: number;
  39669. zmax: number;
  39670. subdivisions?: {
  39671. w: number;
  39672. h: number;
  39673. };
  39674. precision?: {
  39675. w: number;
  39676. h: number;
  39677. };
  39678. updatable?: boolean;
  39679. }, scene: Scene): Mesh;
  39680. /**
  39681. * Creates a ground mesh from a height map
  39682. * * The parameter `url` sets the URL of the height map image resource.
  39683. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  39684. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  39685. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  39686. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  39687. * * 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.
  39688. * * 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).
  39689. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  39690. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39691. * @param name defines the name of the mesh
  39692. * @param url defines the url to the height map
  39693. * @param options defines the options used to create the mesh
  39694. * @param scene defines the hosting scene
  39695. * @returns the ground mesh
  39696. * @see https://doc.babylonjs.com/babylon101/height_map
  39697. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  39698. */
  39699. static CreateGroundFromHeightMap(name: string, url: string, options: {
  39700. width?: number;
  39701. height?: number;
  39702. subdivisions?: number;
  39703. minHeight?: number;
  39704. maxHeight?: number;
  39705. colorFilter?: Color3;
  39706. alphaFilter?: number;
  39707. updatable?: boolean;
  39708. onReady?: (mesh: GroundMesh) => void;
  39709. }, scene: Scene): GroundMesh;
  39710. }
  39711. }
  39712. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  39713. import { Vector4 } from "babylonjs/Maths/math";
  39714. import { Mesh } from "babylonjs/Meshes/mesh";
  39715. /**
  39716. * Class containing static functions to help procedurally build meshes
  39717. */
  39718. export class TorusBuilder {
  39719. /**
  39720. * Creates a torus mesh
  39721. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  39722. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  39723. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  39724. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  39725. * * If you create a double-sided mesh, you can choose what parts of 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
  39726. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39727. * @param name defines the name of the mesh
  39728. * @param options defines the options used to create the mesh
  39729. * @param scene defines the hosting scene
  39730. * @returns the torus mesh
  39731. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  39732. */
  39733. static CreateTorus(name: string, options: {
  39734. diameter?: number;
  39735. thickness?: number;
  39736. tessellation?: number;
  39737. updatable?: boolean;
  39738. sideOrientation?: number;
  39739. frontUVs?: Vector4;
  39740. backUVs?: Vector4;
  39741. }, scene: any): Mesh;
  39742. }
  39743. }
  39744. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  39745. import { Color4, Vector4 } from "babylonjs/Maths/math";
  39746. import { Mesh } from "babylonjs/Meshes/mesh";
  39747. /**
  39748. * Class containing static functions to help procedurally build meshes
  39749. */
  39750. export class CylinderBuilder {
  39751. /**
  39752. * Creates a cylinder or a cone mesh
  39753. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  39754. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  39755. * * 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.
  39756. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  39757. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  39758. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  39759. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  39760. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  39761. * * 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).
  39762. * * 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
  39763. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  39764. * * 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
  39765. * * 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.
  39766. * * If `enclose` is false, a ring surface is one element.
  39767. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  39768. * * 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
  39769. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  39770. * * If you create a double-sided mesh, you can choose what parts of 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
  39771. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39772. * @param name defines the name of the mesh
  39773. * @param options defines the options used to create the mesh
  39774. * @param scene defines the hosting scene
  39775. * @returns the cylinder mesh
  39776. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  39777. */
  39778. static CreateCylinder(name: string, options: {
  39779. height?: number;
  39780. diameterTop?: number;
  39781. diameterBottom?: number;
  39782. diameter?: number;
  39783. tessellation?: number;
  39784. subdivisions?: number;
  39785. arc?: number;
  39786. faceColors?: Color4[];
  39787. faceUV?: Vector4[];
  39788. updatable?: boolean;
  39789. hasRings?: boolean;
  39790. enclose?: boolean;
  39791. sideOrientation?: number;
  39792. frontUVs?: Vector4;
  39793. backUVs?: Vector4;
  39794. }, scene: any): Mesh;
  39795. }
  39796. }
  39797. declare module "babylonjs/Gamepads/gamepadManager" {
  39798. import { Observable } from "babylonjs/Misc/observable";
  39799. import { Nullable } from "babylonjs/types";
  39800. import { Scene } from "babylonjs/scene";
  39801. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39802. /**
  39803. * Manager for handling gamepads
  39804. */
  39805. export class GamepadManager {
  39806. private _scene?;
  39807. private _babylonGamepads;
  39808. private _oneGamepadConnected;
  39809. /** @hidden */
  39810. _isMonitoring: boolean;
  39811. private _gamepadEventSupported;
  39812. private _gamepadSupport;
  39813. /**
  39814. * observable to be triggered when the gamepad controller has been connected
  39815. */
  39816. onGamepadConnectedObservable: Observable<Gamepad>;
  39817. /**
  39818. * observable to be triggered when the gamepad controller has been disconnected
  39819. */
  39820. onGamepadDisconnectedObservable: Observable<Gamepad>;
  39821. private _onGamepadConnectedEvent;
  39822. private _onGamepadDisconnectedEvent;
  39823. /**
  39824. * Initializes the gamepad manager
  39825. * @param _scene BabylonJS scene
  39826. */
  39827. constructor(_scene?: Scene | undefined);
  39828. /**
  39829. * The gamepads in the game pad manager
  39830. */
  39831. readonly gamepads: Gamepad[];
  39832. /**
  39833. * Get the gamepad controllers based on type
  39834. * @param type The type of gamepad controller
  39835. * @returns Nullable gamepad
  39836. */
  39837. getGamepadByType(type?: number): Nullable<Gamepad>;
  39838. /**
  39839. * Disposes the gamepad manager
  39840. */
  39841. dispose(): void;
  39842. private _addNewGamepad;
  39843. private _startMonitoringGamepads;
  39844. private _stopMonitoringGamepads;
  39845. /** @hidden */
  39846. _checkGamepadsStatus(): void;
  39847. private _updateGamepadObjects;
  39848. }
  39849. }
  39850. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  39851. import { Nullable } from "babylonjs/types";
  39852. import { Scene } from "babylonjs/scene";
  39853. import { ISceneComponent } from "babylonjs/sceneComponent";
  39854. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  39855. module "babylonjs/scene" {
  39856. interface Scene {
  39857. /** @hidden */
  39858. _gamepadManager: Nullable<GamepadManager>;
  39859. /**
  39860. * Gets the gamepad manager associated with the scene
  39861. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  39862. */
  39863. gamepadManager: GamepadManager;
  39864. }
  39865. }
  39866. module "babylonjs/Cameras/freeCameraInputsManager" {
  39867. /**
  39868. * Interface representing a free camera inputs manager
  39869. */
  39870. interface FreeCameraInputsManager {
  39871. /**
  39872. * Adds gamepad input support to the FreeCameraInputsManager.
  39873. * @returns the FreeCameraInputsManager
  39874. */
  39875. addGamepad(): FreeCameraInputsManager;
  39876. }
  39877. }
  39878. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  39879. /**
  39880. * Interface representing an arc rotate camera inputs manager
  39881. */
  39882. interface ArcRotateCameraInputsManager {
  39883. /**
  39884. * Adds gamepad input support to the ArcRotateCamera InputManager.
  39885. * @returns the camera inputs manager
  39886. */
  39887. addGamepad(): ArcRotateCameraInputsManager;
  39888. }
  39889. }
  39890. /**
  39891. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  39892. */
  39893. export class GamepadSystemSceneComponent implements ISceneComponent {
  39894. /**
  39895. * The component name helpfull to identify the component in the list of scene components.
  39896. */
  39897. readonly name: string;
  39898. /**
  39899. * The scene the component belongs to.
  39900. */
  39901. scene: Scene;
  39902. /**
  39903. * Creates a new instance of the component for the given scene
  39904. * @param scene Defines the scene to register the component in
  39905. */
  39906. constructor(scene: Scene);
  39907. /**
  39908. * Registers the component in a given scene
  39909. */
  39910. register(): void;
  39911. /**
  39912. * Rebuilds the elements related to this component in case of
  39913. * context lost for instance.
  39914. */
  39915. rebuild(): void;
  39916. /**
  39917. * Disposes the component and the associated ressources
  39918. */
  39919. dispose(): void;
  39920. private _beforeCameraUpdate;
  39921. }
  39922. }
  39923. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  39924. import { Observable } from "babylonjs/Misc/observable";
  39925. import { Nullable } from "babylonjs/types";
  39926. import { Camera } from "babylonjs/Cameras/camera";
  39927. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  39928. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  39929. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  39930. import { Scene } from "babylonjs/scene";
  39931. import { Vector3, Color3 } from "babylonjs/Maths/math";
  39932. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  39933. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39934. import { Mesh } from "babylonjs/Meshes/mesh";
  39935. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  39936. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  39937. import "babylonjs/Meshes/Builders/groundBuilder";
  39938. import "babylonjs/Meshes/Builders/torusBuilder";
  39939. import "babylonjs/Meshes/Builders/cylinderBuilder";
  39940. import "babylonjs/Gamepads/gamepadSceneComponent";
  39941. import "babylonjs/Animations/animatable";
  39942. /**
  39943. * Options to modify the vr teleportation behavior.
  39944. */
  39945. export interface VRTeleportationOptions {
  39946. /**
  39947. * The name of the mesh which should be used as the teleportation floor. (default: null)
  39948. */
  39949. floorMeshName?: string;
  39950. /**
  39951. * A list of meshes to be used as the teleportation floor. (default: empty)
  39952. */
  39953. floorMeshes?: Mesh[];
  39954. }
  39955. /**
  39956. * Options to modify the vr experience helper's behavior.
  39957. */
  39958. export interface VRExperienceHelperOptions extends WebVROptions {
  39959. /**
  39960. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  39961. */
  39962. createDeviceOrientationCamera?: boolean;
  39963. /**
  39964. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  39965. */
  39966. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  39967. /**
  39968. * Uses the main button on the controller to toggle the laser casted. (default: true)
  39969. */
  39970. laserToggle?: boolean;
  39971. /**
  39972. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  39973. */
  39974. floorMeshes?: Mesh[];
  39975. /**
  39976. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  39977. */
  39978. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  39979. }
  39980. /**
  39981. * Event containing information after VR has been entered
  39982. */
  39983. export class OnAfterEnteringVRObservableEvent {
  39984. /**
  39985. * If entering vr was successful
  39986. */
  39987. success: boolean;
  39988. }
  39989. /**
  39990. * Helps to quickly add VR support to an existing scene.
  39991. * See http://doc.babylonjs.com/how_to/webvr_helper
  39992. */
  39993. export class VRExperienceHelper {
  39994. /** Options to modify the vr experience helper's behavior. */
  39995. webVROptions: VRExperienceHelperOptions;
  39996. private _scene;
  39997. private _position;
  39998. private _btnVR;
  39999. private _btnVRDisplayed;
  40000. private _webVRsupported;
  40001. private _webVRready;
  40002. private _webVRrequesting;
  40003. private _webVRpresenting;
  40004. private _hasEnteredVR;
  40005. private _fullscreenVRpresenting;
  40006. private _canvas;
  40007. private _webVRCamera;
  40008. private _vrDeviceOrientationCamera;
  40009. private _deviceOrientationCamera;
  40010. private _existingCamera;
  40011. private _onKeyDown;
  40012. private _onVrDisplayPresentChange;
  40013. private _onVRDisplayChanged;
  40014. private _onVRRequestPresentStart;
  40015. private _onVRRequestPresentComplete;
  40016. /**
  40017. * Observable raised right before entering VR.
  40018. */
  40019. onEnteringVRObservable: Observable<VRExperienceHelper>;
  40020. /**
  40021. * Observable raised when entering VR has completed.
  40022. */
  40023. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  40024. /**
  40025. * Observable raised when exiting VR.
  40026. */
  40027. onExitingVRObservable: Observable<VRExperienceHelper>;
  40028. /**
  40029. * Observable raised when controller mesh is loaded.
  40030. */
  40031. onControllerMeshLoadedObservable: Observable<WebVRController>;
  40032. /** Return this.onEnteringVRObservable
  40033. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  40034. */
  40035. readonly onEnteringVR: Observable<VRExperienceHelper>;
  40036. /** Return this.onExitingVRObservable
  40037. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  40038. */
  40039. readonly onExitingVR: Observable<VRExperienceHelper>;
  40040. /** Return this.onControllerMeshLoadedObservable
  40041. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  40042. */
  40043. readonly onControllerMeshLoaded: Observable<WebVRController>;
  40044. private _rayLength;
  40045. private _useCustomVRButton;
  40046. private _teleportationRequested;
  40047. private _teleportActive;
  40048. private _floorMeshName;
  40049. private _floorMeshesCollection;
  40050. private _rotationAllowed;
  40051. private _teleportBackwardsVector;
  40052. private _teleportationTarget;
  40053. private _isDefaultTeleportationTarget;
  40054. private _postProcessMove;
  40055. private _teleportationFillColor;
  40056. private _teleportationBorderColor;
  40057. private _rotationAngle;
  40058. private _haloCenter;
  40059. private _cameraGazer;
  40060. private _padSensibilityUp;
  40061. private _padSensibilityDown;
  40062. private _leftController;
  40063. private _rightController;
  40064. /**
  40065. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  40066. */
  40067. onNewMeshSelected: Observable<AbstractMesh>;
  40068. /**
  40069. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  40070. */
  40071. onNewMeshPicked: Observable<PickingInfo>;
  40072. private _circleEase;
  40073. /**
  40074. * Observable raised before camera teleportation
  40075. */
  40076. onBeforeCameraTeleport: Observable<Vector3>;
  40077. /**
  40078. * Observable raised after camera teleportation
  40079. */
  40080. onAfterCameraTeleport: Observable<Vector3>;
  40081. /**
  40082. * Observable raised when current selected mesh gets unselected
  40083. */
  40084. onSelectedMeshUnselected: Observable<AbstractMesh>;
  40085. private _raySelectionPredicate;
  40086. /**
  40087. * To be optionaly changed by user to define custom ray selection
  40088. */
  40089. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  40090. /**
  40091. * To be optionaly changed by user to define custom selection logic (after ray selection)
  40092. */
  40093. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  40094. /**
  40095. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  40096. */
  40097. teleportationEnabled: boolean;
  40098. private _defaultHeight;
  40099. private _teleportationInitialized;
  40100. private _interactionsEnabled;
  40101. private _interactionsRequested;
  40102. private _displayGaze;
  40103. private _displayLaserPointer;
  40104. /**
  40105. * The mesh used to display where the user is going to teleport.
  40106. */
  40107. /**
  40108. * Sets the mesh to be used to display where the user is going to teleport.
  40109. */
  40110. teleportationTarget: Mesh;
  40111. /**
  40112. * 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
  40113. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  40114. * See http://doc.babylonjs.com/resources/baking_transformations
  40115. */
  40116. gazeTrackerMesh: Mesh;
  40117. /**
  40118. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  40119. */
  40120. updateGazeTrackerScale: boolean;
  40121. /**
  40122. * If the gaze trackers color should be updated when selecting meshes
  40123. */
  40124. updateGazeTrackerColor: boolean;
  40125. /**
  40126. * The gaze tracking mesh corresponding to the left controller
  40127. */
  40128. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  40129. /**
  40130. * The gaze tracking mesh corresponding to the right controller
  40131. */
  40132. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  40133. /**
  40134. * If the ray of the gaze should be displayed.
  40135. */
  40136. /**
  40137. * Sets if the ray of the gaze should be displayed.
  40138. */
  40139. displayGaze: boolean;
  40140. /**
  40141. * If the ray of the LaserPointer should be displayed.
  40142. */
  40143. /**
  40144. * Sets if the ray of the LaserPointer should be displayed.
  40145. */
  40146. displayLaserPointer: boolean;
  40147. /**
  40148. * The deviceOrientationCamera used as the camera when not in VR.
  40149. */
  40150. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  40151. /**
  40152. * Based on the current WebVR support, returns the current VR camera used.
  40153. */
  40154. readonly currentVRCamera: Nullable<Camera>;
  40155. /**
  40156. * The webVRCamera which is used when in VR.
  40157. */
  40158. readonly webVRCamera: WebVRFreeCamera;
  40159. /**
  40160. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  40161. */
  40162. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  40163. private readonly _teleportationRequestInitiated;
  40164. /**
  40165. * Defines wether or not Pointer lock should be requested when switching to
  40166. * full screen.
  40167. */
  40168. requestPointerLockOnFullScreen: boolean;
  40169. /**
  40170. * Instantiates a VRExperienceHelper.
  40171. * Helps to quickly add VR support to an existing scene.
  40172. * @param scene The scene the VRExperienceHelper belongs to.
  40173. * @param webVROptions Options to modify the vr experience helper's behavior.
  40174. */
  40175. constructor(scene: Scene,
  40176. /** Options to modify the vr experience helper's behavior. */
  40177. webVROptions?: VRExperienceHelperOptions);
  40178. private _onDefaultMeshLoaded;
  40179. private _onResize;
  40180. private _onFullscreenChange;
  40181. /**
  40182. * Gets a value indicating if we are currently in VR mode.
  40183. */
  40184. readonly isInVRMode: boolean;
  40185. private onVrDisplayPresentChange;
  40186. private onVRDisplayChanged;
  40187. private moveButtonToBottomRight;
  40188. private displayVRButton;
  40189. private updateButtonVisibility;
  40190. private _cachedAngularSensibility;
  40191. /**
  40192. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  40193. * Otherwise, will use the fullscreen API.
  40194. */
  40195. enterVR(): void;
  40196. /**
  40197. * Attempt to exit VR, or fullscreen.
  40198. */
  40199. exitVR(): void;
  40200. /**
  40201. * The position of the vr experience helper.
  40202. */
  40203. /**
  40204. * Sets the position of the vr experience helper.
  40205. */
  40206. position: Vector3;
  40207. /**
  40208. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  40209. */
  40210. enableInteractions(): void;
  40211. private readonly _noControllerIsActive;
  40212. private beforeRender;
  40213. private _isTeleportationFloor;
  40214. /**
  40215. * Adds a floor mesh to be used for teleportation.
  40216. * @param floorMesh the mesh to be used for teleportation.
  40217. */
  40218. addFloorMesh(floorMesh: Mesh): void;
  40219. /**
  40220. * Removes a floor mesh from being used for teleportation.
  40221. * @param floorMesh the mesh to be removed.
  40222. */
  40223. removeFloorMesh(floorMesh: Mesh): void;
  40224. /**
  40225. * Enables interactions and teleportation using the VR controllers and gaze.
  40226. * @param vrTeleportationOptions options to modify teleportation behavior.
  40227. */
  40228. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  40229. private _onNewGamepadConnected;
  40230. private _tryEnableInteractionOnController;
  40231. private _onNewGamepadDisconnected;
  40232. private _enableInteractionOnController;
  40233. private _checkTeleportWithRay;
  40234. private _checkRotate;
  40235. private _checkTeleportBackwards;
  40236. private _enableTeleportationOnController;
  40237. private _createTeleportationCircles;
  40238. private _displayTeleportationTarget;
  40239. private _hideTeleportationTarget;
  40240. private _rotateCamera;
  40241. private _moveTeleportationSelectorTo;
  40242. private _workingVector;
  40243. private _workingQuaternion;
  40244. private _workingMatrix;
  40245. /**
  40246. * Teleports the users feet to the desired location
  40247. * @param location The location where the user's feet should be placed
  40248. */
  40249. teleportCamera(location: Vector3): void;
  40250. private _convertNormalToDirectionOfRay;
  40251. private _castRayAndSelectObject;
  40252. private _notifySelectedMeshUnselected;
  40253. /**
  40254. * Sets the color of the laser ray from the vr controllers.
  40255. * @param color new color for the ray.
  40256. */
  40257. changeLaserColor(color: Color3): void;
  40258. /**
  40259. * Sets the color of the ray from the vr headsets gaze.
  40260. * @param color new color for the ray.
  40261. */
  40262. changeGazeColor(color: Color3): void;
  40263. /**
  40264. * Exits VR and disposes of the vr experience helper
  40265. */
  40266. dispose(): void;
  40267. /**
  40268. * Gets the name of the VRExperienceHelper class
  40269. * @returns "VRExperienceHelper"
  40270. */
  40271. getClassName(): string;
  40272. }
  40273. }
  40274. declare module "babylonjs/Cameras/VR/index" {
  40275. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  40276. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  40277. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  40278. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  40279. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  40280. export * from "babylonjs/Cameras/VR/webVRCamera";
  40281. }
  40282. declare module "babylonjs/Cameras/XR/webXRSessionManager" {
  40283. import { Observable } from "babylonjs/Misc/observable";
  40284. import { Nullable } from "babylonjs/types";
  40285. import { IDisposable, Scene } from "babylonjs/scene";
  40286. import { Vector3 } from "babylonjs/Maths/math";
  40287. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  40288. import { Ray } from "babylonjs/Culling/ray";
  40289. /**
  40290. * Manages an XRSession
  40291. * @see https://doc.babylonjs.com/how_to/webxr
  40292. */
  40293. export class WebXRSessionManager implements IDisposable {
  40294. private scene;
  40295. /**
  40296. * Fires every time a new xrFrame arrives which can be used to update the camera
  40297. */
  40298. onXRFrameObservable: Observable<any>;
  40299. /**
  40300. * Fires when the xr session is ended either by the device or manually done
  40301. */
  40302. onXRSessionEnded: Observable<any>;
  40303. /** @hidden */
  40304. _xrSession: XRSession;
  40305. /** @hidden */
  40306. _frameOfReference: XRFrameOfReference;
  40307. /** @hidden */
  40308. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  40309. /** @hidden */
  40310. _currentXRFrame: Nullable<XRFrame>;
  40311. private _xrNavigator;
  40312. private _xrDevice;
  40313. private _tmpMatrix;
  40314. /**
  40315. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  40316. * @param scene The scene which the session should be created for
  40317. */
  40318. constructor(scene: Scene);
  40319. /**
  40320. * Initializes the manager
  40321. * After initialization enterXR can be called to start an XR session
  40322. * @returns Promise which resolves after it is initialized
  40323. */
  40324. initializeAsync(): Promise<void>;
  40325. /**
  40326. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  40327. * @param sessionCreationOptions xr options to create the session with
  40328. * @param frameOfReferenceType option to configure how the xr pose is expressed
  40329. * @returns Promise which resolves after it enters XR
  40330. */
  40331. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  40332. /**
  40333. * Stops the xrSession and restores the renderloop
  40334. * @returns Promise which resolves after it exits XR
  40335. */
  40336. exitXRAsync(): Promise<void>;
  40337. /**
  40338. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  40339. * @param ray ray to cast into the environment
  40340. * @returns Promise which resolves with a collision point in the environment if it exists
  40341. */
  40342. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  40343. /**
  40344. * Checks if a session would be supported for the creation options specified
  40345. * @param options creation options to check if they are supported
  40346. * @returns true if supported
  40347. */
  40348. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  40349. /**
  40350. * @hidden
  40351. * Converts the render layer of xrSession to a render target
  40352. * @param session session to create render target for
  40353. * @param scene scene the new render target should be created for
  40354. */
  40355. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  40356. /**
  40357. * Disposes of the session manager
  40358. */
  40359. dispose(): void;
  40360. }
  40361. }
  40362. declare module "babylonjs/Cameras/XR/webXRCamera" {
  40363. import { Scene } from "babylonjs/scene";
  40364. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40365. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  40366. /**
  40367. * WebXR Camera which holds the views for the xrSession
  40368. * @see https://doc.babylonjs.com/how_to/webxr
  40369. */
  40370. export class WebXRCamera extends FreeCamera {
  40371. private static _TmpMatrix;
  40372. /**
  40373. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  40374. * @param name the name of the camera
  40375. * @param scene the scene to add the camera to
  40376. */
  40377. constructor(name: string, scene: Scene);
  40378. private _updateNumberOfRigCameras;
  40379. /** @hidden */
  40380. _updateForDualEyeDebugging(pupilDistance?: number): void;
  40381. /**
  40382. * Updates the cameras position from the current pose information of the XR session
  40383. * @param xrSessionManager the session containing pose information
  40384. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  40385. */
  40386. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  40387. }
  40388. }
  40389. declare module "babylonjs/Cameras/XR/webXRExperienceHelper" {
  40390. import { Nullable } from "babylonjs/types";
  40391. import { Observable } from "babylonjs/Misc/observable";
  40392. import { IDisposable, Scene } from "babylonjs/scene";
  40393. import { Quaternion, Vector3 } from "babylonjs/Maths/math";
  40394. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40395. import { Ray } from "babylonjs/Culling/ray";
  40396. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  40397. import { WebXRCamera } from "babylonjs/Cameras/XR/webXRCamera";
  40398. /**
  40399. * States of the webXR experience
  40400. */
  40401. export enum WebXRState {
  40402. /**
  40403. * Transitioning to being in XR mode
  40404. */
  40405. ENTERING_XR = 0,
  40406. /**
  40407. * Transitioning to non XR mode
  40408. */
  40409. EXITING_XR = 1,
  40410. /**
  40411. * In XR mode and presenting
  40412. */
  40413. IN_XR = 2,
  40414. /**
  40415. * Not entered XR mode
  40416. */
  40417. NOT_IN_XR = 3
  40418. }
  40419. /**
  40420. * Helper class used to enable XR
  40421. * @see https://doc.babylonjs.com/how_to/webxr
  40422. */
  40423. export class WebXRExperienceHelper implements IDisposable {
  40424. private scene;
  40425. /**
  40426. * 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
  40427. */
  40428. container: AbstractMesh;
  40429. /**
  40430. * Camera used to render xr content
  40431. */
  40432. camera: WebXRCamera;
  40433. /**
  40434. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  40435. */
  40436. state: WebXRState;
  40437. private _setState;
  40438. private static _TmpVector;
  40439. /**
  40440. * Fires when the state of the experience helper has changed
  40441. */
  40442. onStateChangedObservable: Observable<WebXRState>;
  40443. /** @hidden */
  40444. _sessionManager: WebXRSessionManager;
  40445. private _nonVRCamera;
  40446. private _originalSceneAutoClear;
  40447. private _supported;
  40448. /**
  40449. * Creates the experience helper
  40450. * @param scene the scene to attach the experience helper to
  40451. * @returns a promise for the experience helper
  40452. */
  40453. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  40454. /**
  40455. * Creates a WebXRExperienceHelper
  40456. * @param scene The scene the helper should be created in
  40457. */
  40458. private constructor();
  40459. /**
  40460. * Exits XR mode and returns the scene to its original state
  40461. * @returns promise that resolves after xr mode has exited
  40462. */
  40463. exitXRAsync(): Promise<void>;
  40464. /**
  40465. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  40466. * @param sessionCreationOptions options for the XR session
  40467. * @param frameOfReference frame of reference of the XR session
  40468. * @returns promise that resolves after xr mode has entered
  40469. */
  40470. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  40471. /**
  40472. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  40473. * @param ray ray to cast into the environment
  40474. * @returns Promise which resolves with a collision point in the environment if it exists
  40475. */
  40476. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  40477. /**
  40478. * Updates the global position of the camera by moving the camera's container
  40479. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  40480. * @param position The desired global position of the camera
  40481. */
  40482. setPositionOfCameraUsingContainer(position: Vector3): void;
  40483. /**
  40484. * Rotates the xr camera by rotating the camera's container around the camera's position
  40485. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  40486. * @param rotation the desired quaternion rotation to apply to the camera
  40487. */
  40488. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  40489. /**
  40490. * Checks if the creation options are supported by the xr session
  40491. * @param options creation options
  40492. * @returns true if supported
  40493. */
  40494. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  40495. /**
  40496. * Disposes of the experience helper
  40497. */
  40498. dispose(): void;
  40499. }
  40500. }
  40501. declare module "babylonjs/Cameras/XR/webXREnterExitUI" {
  40502. import { Nullable } from "babylonjs/types";
  40503. import { Observable } from "babylonjs/Misc/observable";
  40504. import { IDisposable, Scene } from "babylonjs/scene";
  40505. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  40506. /**
  40507. * Button which can be used to enter a different mode of XR
  40508. */
  40509. export class WebXREnterExitUIButton {
  40510. /** button element */
  40511. element: HTMLElement;
  40512. /** XR initialization options for the button */
  40513. initializationOptions: XRSessionCreationOptions;
  40514. /**
  40515. * Creates a WebXREnterExitUIButton
  40516. * @param element button element
  40517. * @param initializationOptions XR initialization options for the button
  40518. */
  40519. constructor(
  40520. /** button element */
  40521. element: HTMLElement,
  40522. /** XR initialization options for the button */
  40523. initializationOptions: XRSessionCreationOptions);
  40524. /**
  40525. * Overwritable function which can be used to update the button's visuals when the state changes
  40526. * @param activeButton the current active button in the UI
  40527. */
  40528. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  40529. }
  40530. /**
  40531. * Options to create the webXR UI
  40532. */
  40533. export class WebXREnterExitUIOptions {
  40534. /**
  40535. * Context to enter xr with
  40536. */
  40537. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  40538. /**
  40539. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  40540. */
  40541. customButtons?: Array<WebXREnterExitUIButton>;
  40542. }
  40543. /**
  40544. * UI to allow the user to enter/exit XR mode
  40545. */
  40546. export class WebXREnterExitUI implements IDisposable {
  40547. private scene;
  40548. private _overlay;
  40549. private _buttons;
  40550. private _activeButton;
  40551. /**
  40552. * Fired every time the active button is changed.
  40553. *
  40554. * When xr is entered via a button that launches xr that button will be the callback parameter
  40555. *
  40556. * When exiting xr the callback parameter will be null)
  40557. */
  40558. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  40559. /**
  40560. * Creates UI to allow the user to enter/exit XR mode
  40561. * @param scene the scene to add the ui to
  40562. * @param helper the xr experience helper to enter/exit xr with
  40563. * @param options options to configure the UI
  40564. * @returns the created ui
  40565. */
  40566. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  40567. private constructor();
  40568. private _updateButtons;
  40569. /**
  40570. * Disposes of the object
  40571. */
  40572. dispose(): void;
  40573. }
  40574. }
  40575. declare module "babylonjs/Cameras/XR/webXRInput" {
  40576. import { IDisposable, Scene } from "babylonjs/scene";
  40577. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40578. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  40579. /**
  40580. * Represents an XR input
  40581. */
  40582. export class WebXRController {
  40583. /**
  40584. * 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
  40585. */
  40586. grip?: AbstractMesh;
  40587. /**
  40588. * Pointer which can be used to select objects or attach a visible laser to
  40589. */
  40590. pointer: AbstractMesh;
  40591. /**
  40592. * Creates the controller
  40593. * @see https://doc.babylonjs.com/how_to/webxr
  40594. * @param scene the scene which the controller should be associated to
  40595. */
  40596. constructor(scene: Scene);
  40597. /**
  40598. * Disposes of the object
  40599. */
  40600. dispose(): void;
  40601. }
  40602. /**
  40603. * XR input used to track XR inputs such as controllers/rays
  40604. */
  40605. export class WebXRInput implements IDisposable {
  40606. private helper;
  40607. /**
  40608. * XR controllers being tracked
  40609. */
  40610. controllers: Array<WebXRController>;
  40611. private _tmpMatrix;
  40612. private _frameObserver;
  40613. /**
  40614. * Initializes the WebXRInput
  40615. * @param helper experience helper which the input should be created for
  40616. */
  40617. constructor(helper: WebXRExperienceHelper);
  40618. /**
  40619. * Disposes of the object
  40620. */
  40621. dispose(): void;
  40622. }
  40623. }
  40624. declare module "babylonjs/Cameras/XR/webXRManagedOutputCanvas" {
  40625. import { Nullable } from "babylonjs/types";
  40626. import { IDisposable } from "babylonjs/scene";
  40627. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  40628. /**
  40629. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  40630. */
  40631. export class WebXRManagedOutputCanvas implements IDisposable {
  40632. private _canvas;
  40633. /**
  40634. * xrpresent context of the canvas which can be used to display/mirror xr content
  40635. */
  40636. canvasContext: Nullable<WebGLRenderingContext>;
  40637. /**
  40638. * Initializes the canvas to be added/removed upon entering/exiting xr
  40639. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  40640. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  40641. */
  40642. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  40643. /**
  40644. * Disposes of the object
  40645. */
  40646. dispose(): void;
  40647. private _setManagedOutputCanvas;
  40648. private _addCanvas;
  40649. private _removeCanvas;
  40650. }
  40651. }
  40652. declare module "babylonjs/Cameras/XR/index" {
  40653. export * from "babylonjs/Cameras/XR/webXRCamera";
  40654. export * from "babylonjs/Cameras/XR/webXREnterExitUI";
  40655. export * from "babylonjs/Cameras/XR/webXRExperienceHelper";
  40656. export * from "babylonjs/Cameras/XR/webXRInput";
  40657. export * from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  40658. export * from "babylonjs/Cameras/XR/webXRSessionManager";
  40659. }
  40660. declare module "babylonjs/Cameras/RigModes/index" {
  40661. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40662. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40663. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  40664. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  40665. }
  40666. declare module "babylonjs/Cameras/index" {
  40667. export * from "babylonjs/Cameras/Inputs/index";
  40668. export * from "babylonjs/Cameras/cameraInputsManager";
  40669. export * from "babylonjs/Cameras/camera";
  40670. export * from "babylonjs/Cameras/targetCamera";
  40671. export * from "babylonjs/Cameras/freeCamera";
  40672. export * from "babylonjs/Cameras/freeCameraInputsManager";
  40673. export * from "babylonjs/Cameras/touchCamera";
  40674. export * from "babylonjs/Cameras/arcRotateCamera";
  40675. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  40676. export * from "babylonjs/Cameras/deviceOrientationCamera";
  40677. export * from "babylonjs/Cameras/flyCamera";
  40678. export * from "babylonjs/Cameras/flyCameraInputsManager";
  40679. export * from "babylonjs/Cameras/followCamera";
  40680. export * from "babylonjs/Cameras/gamepadCamera";
  40681. export * from "babylonjs/Cameras/Stereoscopic/index";
  40682. export * from "babylonjs/Cameras/universalCamera";
  40683. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  40684. export * from "babylonjs/Cameras/VR/index";
  40685. export * from "babylonjs/Cameras/XR/index";
  40686. export * from "babylonjs/Cameras/RigModes/index";
  40687. }
  40688. declare module "babylonjs/Collisions/index" {
  40689. export * from "babylonjs/Collisions/collider";
  40690. export * from "babylonjs/Collisions/collisionCoordinator";
  40691. export * from "babylonjs/Collisions/pickingInfo";
  40692. export * from "babylonjs/Collisions/intersectionInfo";
  40693. }
  40694. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  40695. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  40696. import { Vector3, Plane } from "babylonjs/Maths/math";
  40697. import { Ray } from "babylonjs/Culling/ray";
  40698. /**
  40699. * Contains an array of blocks representing the octree
  40700. */
  40701. export interface IOctreeContainer<T> {
  40702. /**
  40703. * Blocks within the octree
  40704. */
  40705. blocks: Array<OctreeBlock<T>>;
  40706. }
  40707. /**
  40708. * Class used to store a cell in an octree
  40709. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40710. */
  40711. export class OctreeBlock<T> {
  40712. /**
  40713. * Gets the content of the current block
  40714. */
  40715. entries: T[];
  40716. /**
  40717. * Gets the list of block children
  40718. */
  40719. blocks: Array<OctreeBlock<T>>;
  40720. private _depth;
  40721. private _maxDepth;
  40722. private _capacity;
  40723. private _minPoint;
  40724. private _maxPoint;
  40725. private _boundingVectors;
  40726. private _creationFunc;
  40727. /**
  40728. * Creates a new block
  40729. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  40730. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  40731. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  40732. * @param depth defines the current depth of this block in the octree
  40733. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  40734. * @param creationFunc defines a callback to call when an element is added to the block
  40735. */
  40736. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  40737. /**
  40738. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  40739. */
  40740. readonly capacity: number;
  40741. /**
  40742. * Gets the minimum vector (in world space) of the block's bounding box
  40743. */
  40744. readonly minPoint: Vector3;
  40745. /**
  40746. * Gets the maximum vector (in world space) of the block's bounding box
  40747. */
  40748. readonly maxPoint: Vector3;
  40749. /**
  40750. * Add a new element to this block
  40751. * @param entry defines the element to add
  40752. */
  40753. addEntry(entry: T): void;
  40754. /**
  40755. * Remove an element from this block
  40756. * @param entry defines the element to remove
  40757. */
  40758. removeEntry(entry: T): void;
  40759. /**
  40760. * Add an array of elements to this block
  40761. * @param entries defines the array of elements to add
  40762. */
  40763. addEntries(entries: T[]): void;
  40764. /**
  40765. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  40766. * @param frustumPlanes defines the frustum planes to test
  40767. * @param selection defines the array to store current content if selection is positive
  40768. * @param allowDuplicate defines if the selection array can contains duplicated entries
  40769. */
  40770. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  40771. /**
  40772. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  40773. * @param sphereCenter defines the bounding sphere center
  40774. * @param sphereRadius defines the bounding sphere radius
  40775. * @param selection defines the array to store current content if selection is positive
  40776. * @param allowDuplicate defines if the selection array can contains duplicated entries
  40777. */
  40778. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  40779. /**
  40780. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  40781. * @param ray defines the ray to test with
  40782. * @param selection defines the array to store current content if selection is positive
  40783. */
  40784. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  40785. /**
  40786. * Subdivide the content into child blocks (this block will then be empty)
  40787. */
  40788. createInnerBlocks(): void;
  40789. /**
  40790. * @hidden
  40791. */
  40792. 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;
  40793. }
  40794. }
  40795. declare module "babylonjs/Culling/Octrees/octree" {
  40796. import { SmartArray } from "babylonjs/Misc/smartArray";
  40797. import { Vector3, Plane } from "babylonjs/Maths/math";
  40798. import { SubMesh } from "babylonjs/Meshes/subMesh";
  40799. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40800. import { Ray } from "babylonjs/Culling/ray";
  40801. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  40802. /**
  40803. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  40804. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40805. */
  40806. export class Octree<T> {
  40807. /** 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.) */
  40808. maxDepth: number;
  40809. /**
  40810. * Blocks within the octree containing objects
  40811. */
  40812. blocks: Array<OctreeBlock<T>>;
  40813. /**
  40814. * Content stored in the octree
  40815. */
  40816. dynamicContent: T[];
  40817. private _maxBlockCapacity;
  40818. private _selectionContent;
  40819. private _creationFunc;
  40820. /**
  40821. * Creates a octree
  40822. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40823. * @param creationFunc function to be used to instatiate the octree
  40824. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  40825. * @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.)
  40826. */
  40827. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  40828. /** 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.) */
  40829. maxDepth?: number);
  40830. /**
  40831. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  40832. * @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);
  40833. * @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);
  40834. * @param entries meshes to be added to the octree blocks
  40835. */
  40836. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  40837. /**
  40838. * Adds a mesh to the octree
  40839. * @param entry Mesh to add to the octree
  40840. */
  40841. addMesh(entry: T): void;
  40842. /**
  40843. * Remove an element from the octree
  40844. * @param entry defines the element to remove
  40845. */
  40846. removeMesh(entry: T): void;
  40847. /**
  40848. * Selects an array of meshes within the frustum
  40849. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  40850. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  40851. * @returns array of meshes within the frustum
  40852. */
  40853. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  40854. /**
  40855. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  40856. * @param sphereCenter defines the bounding sphere center
  40857. * @param sphereRadius defines the bounding sphere radius
  40858. * @param allowDuplicate defines if the selection array can contains duplicated entries
  40859. * @returns an array of objects that intersect the sphere
  40860. */
  40861. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  40862. /**
  40863. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  40864. * @param ray defines the ray to test with
  40865. * @returns array of intersected objects
  40866. */
  40867. intersectsRay(ray: Ray): SmartArray<T>;
  40868. /**
  40869. * Adds a mesh into the octree block if it intersects the block
  40870. */
  40871. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  40872. /**
  40873. * Adds a submesh into the octree block if it intersects the block
  40874. */
  40875. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  40876. }
  40877. }
  40878. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  40879. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  40880. import { Scene } from "babylonjs/scene";
  40881. import { SubMesh } from "babylonjs/Meshes/subMesh";
  40882. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40883. import { Ray } from "babylonjs/Culling/ray";
  40884. import { Octree } from "babylonjs/Culling/Octrees/octree";
  40885. import { Collider } from "babylonjs/Collisions/collider";
  40886. module "babylonjs/scene" {
  40887. interface Scene {
  40888. /**
  40889. * @hidden
  40890. * Backing Filed
  40891. */
  40892. _selectionOctree: Octree<AbstractMesh>;
  40893. /**
  40894. * Gets the octree used to boost mesh selection (picking)
  40895. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40896. */
  40897. selectionOctree: Octree<AbstractMesh>;
  40898. /**
  40899. * Creates or updates the octree used to boost selection (picking)
  40900. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40901. * @param maxCapacity defines the maximum capacity per leaf
  40902. * @param maxDepth defines the maximum depth of the octree
  40903. * @returns an octree of AbstractMesh
  40904. */
  40905. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  40906. }
  40907. }
  40908. module "babylonjs/Meshes/abstractMesh" {
  40909. interface AbstractMesh {
  40910. /**
  40911. * @hidden
  40912. * Backing Field
  40913. */
  40914. _submeshesOctree: Octree<SubMesh>;
  40915. /**
  40916. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  40917. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  40918. * @param maxCapacity defines the maximum size of each block (64 by default)
  40919. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  40920. * @returns the new octree
  40921. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  40922. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40923. */
  40924. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  40925. }
  40926. }
  40927. /**
  40928. * Defines the octree scene component responsible to manage any octrees
  40929. * in a given scene.
  40930. */
  40931. export class OctreeSceneComponent {
  40932. /**
  40933. * The component name helpfull to identify the component in the list of scene components.
  40934. */
  40935. readonly name: string;
  40936. /**
  40937. * The scene the component belongs to.
  40938. */
  40939. scene: Scene;
  40940. /**
  40941. * Indicates if the meshes have been checked to make sure they are isEnabled()
  40942. */
  40943. readonly checksIsEnabled: boolean;
  40944. /**
  40945. * Creates a new instance of the component for the given scene
  40946. * @param scene Defines the scene to register the component in
  40947. */
  40948. constructor(scene: Scene);
  40949. /**
  40950. * Registers the component in a given scene
  40951. */
  40952. register(): void;
  40953. /**
  40954. * Return the list of active meshes
  40955. * @returns the list of active meshes
  40956. */
  40957. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  40958. /**
  40959. * Return the list of active sub meshes
  40960. * @param mesh The mesh to get the candidates sub meshes from
  40961. * @returns the list of active sub meshes
  40962. */
  40963. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  40964. private _tempRay;
  40965. /**
  40966. * Return the list of sub meshes intersecting with a given local ray
  40967. * @param mesh defines the mesh to find the submesh for
  40968. * @param localRay defines the ray in local space
  40969. * @returns the list of intersecting sub meshes
  40970. */
  40971. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  40972. /**
  40973. * Return the list of sub meshes colliding with a collider
  40974. * @param mesh defines the mesh to find the submesh for
  40975. * @param collider defines the collider to evaluate the collision against
  40976. * @returns the list of colliding sub meshes
  40977. */
  40978. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  40979. /**
  40980. * Rebuilds the elements related to this component in case of
  40981. * context lost for instance.
  40982. */
  40983. rebuild(): void;
  40984. /**
  40985. * Disposes the component and the associated ressources.
  40986. */
  40987. dispose(): void;
  40988. }
  40989. }
  40990. declare module "babylonjs/Culling/Octrees/index" {
  40991. export * from "babylonjs/Culling/Octrees/octree";
  40992. export * from "babylonjs/Culling/Octrees/octreeBlock";
  40993. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  40994. }
  40995. declare module "babylonjs/Culling/index" {
  40996. export * from "babylonjs/Culling/boundingBox";
  40997. export * from "babylonjs/Culling/boundingInfo";
  40998. export * from "babylonjs/Culling/boundingSphere";
  40999. export * from "babylonjs/Culling/Octrees/index";
  41000. export * from "babylonjs/Culling/ray";
  41001. }
  41002. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  41003. import { Vector3, Color4 } from "babylonjs/Maths/math";
  41004. import { Nullable } from "babylonjs/types";
  41005. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  41006. import { Scene } from "babylonjs/scene";
  41007. /**
  41008. * Class containing static functions to help procedurally build meshes
  41009. */
  41010. export class LinesBuilder {
  41011. /**
  41012. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  41013. * * 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
  41014. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  41015. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  41016. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  41017. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  41018. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  41019. * * 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
  41020. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  41021. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41022. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  41023. * @param name defines the name of the new line system
  41024. * @param options defines the options used to create the line system
  41025. * @param scene defines the hosting scene
  41026. * @returns a new line system mesh
  41027. */
  41028. static CreateLineSystem(name: string, options: {
  41029. lines: Vector3[][];
  41030. updatable?: boolean;
  41031. instance?: Nullable<LinesMesh>;
  41032. colors?: Nullable<Color4[][]>;
  41033. useVertexAlpha?: boolean;
  41034. }, scene: Nullable<Scene>): LinesMesh;
  41035. /**
  41036. * Creates a line mesh
  41037. * 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
  41038. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  41039. * * The parameter `points` is an array successive Vector3
  41040. * * 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
  41041. * * The optional parameter `colors` is an array of successive Color4, one per line point
  41042. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  41043. * * When updating an instance, remember that only point positions can change, not the number of points
  41044. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41045. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  41046. * @param name defines the name of the new line system
  41047. * @param options defines the options used to create the line system
  41048. * @param scene defines the hosting scene
  41049. * @returns a new line mesh
  41050. */
  41051. static CreateLines(name: string, options: {
  41052. points: Vector3[];
  41053. updatable?: boolean;
  41054. instance?: Nullable<LinesMesh>;
  41055. colors?: Color4[];
  41056. useVertexAlpha?: boolean;
  41057. }, scene?: Nullable<Scene>): LinesMesh;
  41058. /**
  41059. * Creates a dashed line mesh
  41060. * * 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
  41061. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  41062. * * The parameter `points` is an array successive Vector3
  41063. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  41064. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  41065. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  41066. * * 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
  41067. * * When updating an instance, remember that only point positions can change, not the number of points
  41068. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41069. * @param name defines the name of the mesh
  41070. * @param options defines the options used to create the mesh
  41071. * @param scene defines the hosting scene
  41072. * @returns the dashed line mesh
  41073. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  41074. */
  41075. static CreateDashedLines(name: string, options: {
  41076. points: Vector3[];
  41077. dashSize?: number;
  41078. gapSize?: number;
  41079. dashNb?: number;
  41080. updatable?: boolean;
  41081. instance?: LinesMesh;
  41082. }, scene?: Nullable<Scene>): LinesMesh;
  41083. }
  41084. }
  41085. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  41086. import { IDisposable, Scene } from "babylonjs/scene";
  41087. import { Nullable } from "babylonjs/types";
  41088. import { Observable } from "babylonjs/Misc/observable";
  41089. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41090. /**
  41091. * Renders a layer on top of an existing scene
  41092. */
  41093. export class UtilityLayerRenderer implements IDisposable {
  41094. /** the original scene that will be rendered on top of */
  41095. originalScene: Scene;
  41096. private _pointerCaptures;
  41097. private _lastPointerEvents;
  41098. private static _DefaultUtilityLayer;
  41099. private static _DefaultKeepDepthUtilityLayer;
  41100. /**
  41101. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  41102. */
  41103. pickUtilitySceneFirst: boolean;
  41104. /**
  41105. * 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)
  41106. */
  41107. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  41108. /**
  41109. * 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)
  41110. */
  41111. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  41112. /**
  41113. * The scene that is rendered on top of the original scene
  41114. */
  41115. utilityLayerScene: Scene;
  41116. /**
  41117. * If the utility layer should automatically be rendered on top of existing scene
  41118. */
  41119. shouldRender: boolean;
  41120. /**
  41121. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  41122. */
  41123. onlyCheckPointerDownEvents: boolean;
  41124. /**
  41125. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  41126. */
  41127. processAllEvents: boolean;
  41128. /**
  41129. * Observable raised when the pointer move from the utility layer scene to the main scene
  41130. */
  41131. onPointerOutObservable: Observable<number>;
  41132. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  41133. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  41134. private _afterRenderObserver;
  41135. private _sceneDisposeObserver;
  41136. private _originalPointerObserver;
  41137. /**
  41138. * Instantiates a UtilityLayerRenderer
  41139. * @param originalScene the original scene that will be rendered on top of
  41140. * @param handleEvents boolean indicating if the utility layer should handle events
  41141. */
  41142. constructor(
  41143. /** the original scene that will be rendered on top of */
  41144. originalScene: Scene, handleEvents?: boolean);
  41145. private _notifyObservers;
  41146. /**
  41147. * Renders the utility layers scene on top of the original scene
  41148. */
  41149. render(): void;
  41150. /**
  41151. * Disposes of the renderer
  41152. */
  41153. dispose(): void;
  41154. private _updateCamera;
  41155. }
  41156. }
  41157. declare module "babylonjs/Gizmos/gizmo" {
  41158. import { Nullable } from "babylonjs/types";
  41159. import { IDisposable } from "babylonjs/scene";
  41160. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41161. import { Mesh } from "babylonjs/Meshes/mesh";
  41162. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  41163. /**
  41164. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  41165. */
  41166. export class Gizmo implements IDisposable {
  41167. /** The utility layer the gizmo will be added to */
  41168. gizmoLayer: UtilityLayerRenderer;
  41169. /**
  41170. * The root mesh of the gizmo
  41171. */
  41172. _rootMesh: Mesh;
  41173. private _attachedMesh;
  41174. /**
  41175. * Ratio for the scale of the gizmo (Default: 1)
  41176. */
  41177. scaleRatio: number;
  41178. private _tmpMatrix;
  41179. /**
  41180. * If a custom mesh has been set (Default: false)
  41181. */
  41182. protected _customMeshSet: boolean;
  41183. /**
  41184. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  41185. * * When set, interactions will be enabled
  41186. */
  41187. attachedMesh: Nullable<AbstractMesh>;
  41188. /**
  41189. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  41190. * @param mesh The mesh to replace the default mesh of the gizmo
  41191. */
  41192. setCustomMesh(mesh: Mesh): void;
  41193. /**
  41194. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  41195. */
  41196. updateGizmoRotationToMatchAttachedMesh: boolean;
  41197. /**
  41198. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  41199. */
  41200. updateGizmoPositionToMatchAttachedMesh: boolean;
  41201. /**
  41202. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  41203. */
  41204. protected _updateScale: boolean;
  41205. protected _interactionsEnabled: boolean;
  41206. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  41207. private _beforeRenderObserver;
  41208. /**
  41209. * Creates a gizmo
  41210. * @param gizmoLayer The utility layer the gizmo will be added to
  41211. */
  41212. constructor(
  41213. /** The utility layer the gizmo will be added to */
  41214. gizmoLayer?: UtilityLayerRenderer);
  41215. private _tempVector;
  41216. /**
  41217. * @hidden
  41218. * Updates the gizmo to match the attached mesh's position/rotation
  41219. */
  41220. protected _update(): void;
  41221. /**
  41222. * Disposes of the gizmo
  41223. */
  41224. dispose(): void;
  41225. }
  41226. }
  41227. declare module "babylonjs/Gizmos/axisDragGizmo" {
  41228. import { Observable } from "babylonjs/Misc/observable";
  41229. import { Nullable } from "babylonjs/types";
  41230. import { Vector3, Color3 } from "babylonjs/Maths/math";
  41231. import { TransformNode } from "babylonjs/Meshes/transformNode";
  41232. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41233. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  41234. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  41235. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  41236. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  41237. import { Scene } from "babylonjs/scene";
  41238. /**
  41239. * Single axis drag gizmo
  41240. */
  41241. export class AxisDragGizmo extends Gizmo {
  41242. /**
  41243. * Drag behavior responsible for the gizmos dragging interactions
  41244. */
  41245. dragBehavior: PointerDragBehavior;
  41246. private _pointerObserver;
  41247. /**
  41248. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  41249. */
  41250. snapDistance: number;
  41251. /**
  41252. * Event that fires each time the gizmo snaps to a new location.
  41253. * * snapDistance is the the change in distance
  41254. */
  41255. onSnapObservable: Observable<{
  41256. snapDistance: number;
  41257. }>;
  41258. /** @hidden */
  41259. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  41260. /** @hidden */
  41261. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  41262. /**
  41263. * Creates an AxisDragGizmo
  41264. * @param gizmoLayer The utility layer the gizmo will be added to
  41265. * @param dragAxis The axis which the gizmo will be able to drag on
  41266. * @param color The color of the gizmo
  41267. */
  41268. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  41269. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  41270. /**
  41271. * Disposes of the gizmo
  41272. */
  41273. dispose(): void;
  41274. }
  41275. }
  41276. declare module "babylonjs/Debug/axesViewer" {
  41277. import { Vector3 } from "babylonjs/Maths/math";
  41278. import { Nullable } from "babylonjs/types";
  41279. import { Scene } from "babylonjs/scene";
  41280. import { TransformNode } from "babylonjs/Meshes/transformNode";
  41281. /**
  41282. * The Axes viewer will show 3 axes in a specific point in space
  41283. */
  41284. export class AxesViewer {
  41285. private _xAxis;
  41286. private _yAxis;
  41287. private _zAxis;
  41288. private _scaleLinesFactor;
  41289. private _instanced;
  41290. /**
  41291. * Gets the hosting scene
  41292. */
  41293. scene: Scene;
  41294. /**
  41295. * Gets or sets a number used to scale line length
  41296. */
  41297. scaleLines: number;
  41298. /** Gets the node hierarchy used to render x-axis */
  41299. readonly xAxis: TransformNode;
  41300. /** Gets the node hierarchy used to render y-axis */
  41301. readonly yAxis: TransformNode;
  41302. /** Gets the node hierarchy used to render z-axis */
  41303. readonly zAxis: TransformNode;
  41304. /**
  41305. * Creates a new AxesViewer
  41306. * @param scene defines the hosting scene
  41307. * @param scaleLines defines a number used to scale line length (1 by default)
  41308. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  41309. * @param xAxis defines the node hierarchy used to render the x-axis
  41310. * @param yAxis defines the node hierarchy used to render the y-axis
  41311. * @param zAxis defines the node hierarchy used to render the z-axis
  41312. */
  41313. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  41314. /**
  41315. * Force the viewer to update
  41316. * @param position defines the position of the viewer
  41317. * @param xaxis defines the x axis of the viewer
  41318. * @param yaxis defines the y axis of the viewer
  41319. * @param zaxis defines the z axis of the viewer
  41320. */
  41321. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  41322. /**
  41323. * Creates an instance of this axes viewer.
  41324. * @returns a new axes viewer with instanced meshes
  41325. */
  41326. createInstance(): AxesViewer;
  41327. /** Releases resources */
  41328. dispose(): void;
  41329. private static _SetRenderingGroupId;
  41330. }
  41331. }
  41332. declare module "babylonjs/Debug/boneAxesViewer" {
  41333. import { Nullable } from "babylonjs/types";
  41334. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  41335. import { Vector3 } from "babylonjs/Maths/math";
  41336. import { Mesh } from "babylonjs/Meshes/mesh";
  41337. import { Bone } from "babylonjs/Bones/bone";
  41338. import { Scene } from "babylonjs/scene";
  41339. /**
  41340. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  41341. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  41342. */
  41343. export class BoneAxesViewer extends AxesViewer {
  41344. /**
  41345. * Gets or sets the target mesh where to display the axes viewer
  41346. */
  41347. mesh: Nullable<Mesh>;
  41348. /**
  41349. * Gets or sets the target bone where to display the axes viewer
  41350. */
  41351. bone: Nullable<Bone>;
  41352. /** Gets current position */
  41353. pos: Vector3;
  41354. /** Gets direction of X axis */
  41355. xaxis: Vector3;
  41356. /** Gets direction of Y axis */
  41357. yaxis: Vector3;
  41358. /** Gets direction of Z axis */
  41359. zaxis: Vector3;
  41360. /**
  41361. * Creates a new BoneAxesViewer
  41362. * @param scene defines the hosting scene
  41363. * @param bone defines the target bone
  41364. * @param mesh defines the target mesh
  41365. * @param scaleLines defines a scaling factor for line length (1 by default)
  41366. */
  41367. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  41368. /**
  41369. * Force the viewer to update
  41370. */
  41371. update(): void;
  41372. /** Releases resources */
  41373. dispose(): void;
  41374. }
  41375. }
  41376. declare module "babylonjs/Debug/debugLayer" {
  41377. import { Observable } from "babylonjs/Misc/observable";
  41378. import { Scene } from "babylonjs/scene";
  41379. /**
  41380. * Interface used to define scene explorer extensibility option
  41381. */
  41382. export interface IExplorerExtensibilityOption {
  41383. /**
  41384. * Define the option label
  41385. */
  41386. label: string;
  41387. /**
  41388. * Defines the action to execute on click
  41389. */
  41390. action: (entity: any) => void;
  41391. }
  41392. /**
  41393. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  41394. */
  41395. export interface IExplorerExtensibilityGroup {
  41396. /**
  41397. * Defines a predicate to test if a given type mut be extended
  41398. */
  41399. predicate: (entity: any) => boolean;
  41400. /**
  41401. * Gets the list of options added to a type
  41402. */
  41403. entries: IExplorerExtensibilityOption[];
  41404. }
  41405. /**
  41406. * Interface used to define the options to use to create the Inspector
  41407. */
  41408. export interface IInspectorOptions {
  41409. /**
  41410. * Display in overlay mode (default: false)
  41411. */
  41412. overlay?: boolean;
  41413. /**
  41414. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  41415. */
  41416. globalRoot?: HTMLElement;
  41417. /**
  41418. * Display the Scene explorer
  41419. */
  41420. showExplorer?: boolean;
  41421. /**
  41422. * Display the property inspector
  41423. */
  41424. showInspector?: boolean;
  41425. /**
  41426. * Display in embed mode (both panes on the right)
  41427. */
  41428. embedMode?: boolean;
  41429. /**
  41430. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  41431. */
  41432. handleResize?: boolean;
  41433. /**
  41434. * Allow the panes to popup (default: true)
  41435. */
  41436. enablePopup?: boolean;
  41437. /**
  41438. * Allow the panes to be closed by users (default: true)
  41439. */
  41440. enableClose?: boolean;
  41441. /**
  41442. * Optional list of extensibility entries
  41443. */
  41444. explorerExtensibility?: IExplorerExtensibilityGroup[];
  41445. /**
  41446. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  41447. */
  41448. inspectorURL?: string;
  41449. }
  41450. module "babylonjs/scene" {
  41451. interface Scene {
  41452. /**
  41453. * @hidden
  41454. * Backing field
  41455. */
  41456. _debugLayer: DebugLayer;
  41457. /**
  41458. * Gets the debug layer (aka Inspector) associated with the scene
  41459. * @see http://doc.babylonjs.com/features/playground_debuglayer
  41460. */
  41461. debugLayer: DebugLayer;
  41462. }
  41463. }
  41464. /**
  41465. * The debug layer (aka Inspector) is the go to tool in order to better understand
  41466. * what is happening in your scene
  41467. * @see http://doc.babylonjs.com/features/playground_debuglayer
  41468. */
  41469. export class DebugLayer {
  41470. /**
  41471. * Define the url to get the inspector script from.
  41472. * By default it uses the babylonjs CDN.
  41473. * @ignoreNaming
  41474. */
  41475. static InspectorURL: string;
  41476. private _scene;
  41477. private BJSINSPECTOR;
  41478. /**
  41479. * Observable triggered when a property is changed through the inspector.
  41480. */
  41481. onPropertyChangedObservable: Observable<{
  41482. object: any;
  41483. property: string;
  41484. value: any;
  41485. initialValue: any;
  41486. }>;
  41487. /**
  41488. * Instantiates a new debug layer.
  41489. * The debug layer (aka Inspector) is the go to tool in order to better understand
  41490. * what is happening in your scene
  41491. * @see http://doc.babylonjs.com/features/playground_debuglayer
  41492. * @param scene Defines the scene to inspect
  41493. */
  41494. constructor(scene: Scene);
  41495. /** Creates the inspector window. */
  41496. private _createInspector;
  41497. /**
  41498. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  41499. * @param entity defines the entity to select
  41500. * @param lineContainerTitle defines the specific block to highlight
  41501. */
  41502. select(entity: any, lineContainerTitle?: string): void;
  41503. /** Get the inspector from bundle or global */
  41504. private _getGlobalInspector;
  41505. /**
  41506. * Get if the inspector is visible or not.
  41507. * @returns true if visible otherwise, false
  41508. */
  41509. isVisible(): boolean;
  41510. /**
  41511. * Hide the inspector and close its window.
  41512. */
  41513. hide(): void;
  41514. /**
  41515. * Launch the debugLayer.
  41516. * @param config Define the configuration of the inspector
  41517. * @return a promise fulfilled when the debug layer is visible
  41518. */
  41519. show(config?: IInspectorOptions): Promise<DebugLayer>;
  41520. }
  41521. }
  41522. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  41523. import { Nullable } from "babylonjs/types";
  41524. import { Scene } from "babylonjs/scene";
  41525. import { Vector4, Color4 } from "babylonjs/Maths/math";
  41526. import { Mesh } from "babylonjs/Meshes/mesh";
  41527. /**
  41528. * Class containing static functions to help procedurally build meshes
  41529. */
  41530. export class BoxBuilder {
  41531. /**
  41532. * Creates a box mesh
  41533. * * The parameter `size` sets the size (float) of each box side (default 1)
  41534. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  41535. * * 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)
  41536. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  41537. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  41538. * * If you create a double-sided mesh, you can choose what parts of 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
  41539. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41540. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  41541. * @param name defines the name of the mesh
  41542. * @param options defines the options used to create the mesh
  41543. * @param scene defines the hosting scene
  41544. * @returns the box mesh
  41545. */
  41546. static CreateBox(name: string, options: {
  41547. size?: number;
  41548. width?: number;
  41549. height?: number;
  41550. depth?: number;
  41551. faceUV?: Vector4[];
  41552. faceColors?: Color4[];
  41553. sideOrientation?: number;
  41554. frontUVs?: Vector4;
  41555. backUVs?: Vector4;
  41556. updatable?: boolean;
  41557. }, scene?: Nullable<Scene>): Mesh;
  41558. }
  41559. }
  41560. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  41561. import { Vector4 } from "babylonjs/Maths/math";
  41562. import { Mesh } from "babylonjs/Meshes/mesh";
  41563. /**
  41564. * Class containing static functions to help procedurally build meshes
  41565. */
  41566. export class SphereBuilder {
  41567. /**
  41568. * Creates a sphere mesh
  41569. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  41570. * * 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`)
  41571. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  41572. * * 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
  41573. * * 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)
  41574. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  41575. * * If you create a double-sided mesh, you can choose what parts of 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
  41576. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41577. * @param name defines the name of the mesh
  41578. * @param options defines the options used to create the mesh
  41579. * @param scene defines the hosting scene
  41580. * @returns the sphere mesh
  41581. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  41582. */
  41583. static CreateSphere(name: string, options: {
  41584. segments?: number;
  41585. diameter?: number;
  41586. diameterX?: number;
  41587. diameterY?: number;
  41588. diameterZ?: number;
  41589. arc?: number;
  41590. slice?: number;
  41591. sideOrientation?: number;
  41592. frontUVs?: Vector4;
  41593. backUVs?: Vector4;
  41594. updatable?: boolean;
  41595. }, scene: any): Mesh;
  41596. }
  41597. }
  41598. declare module "babylonjs/Debug/physicsViewer" {
  41599. import { Nullable } from "babylonjs/types";
  41600. import { Scene } from "babylonjs/scene";
  41601. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41602. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  41603. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  41604. /**
  41605. * Used to show the physics impostor around the specific mesh
  41606. */
  41607. export class PhysicsViewer {
  41608. /** @hidden */
  41609. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  41610. /** @hidden */
  41611. protected _meshes: Array<Nullable<AbstractMesh>>;
  41612. /** @hidden */
  41613. protected _scene: Nullable<Scene>;
  41614. /** @hidden */
  41615. protected _numMeshes: number;
  41616. /** @hidden */
  41617. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  41618. private _renderFunction;
  41619. private _utilityLayer;
  41620. private _debugBoxMesh;
  41621. private _debugSphereMesh;
  41622. private _debugMaterial;
  41623. /**
  41624. * Creates a new PhysicsViewer
  41625. * @param scene defines the hosting scene
  41626. */
  41627. constructor(scene: Scene);
  41628. /** @hidden */
  41629. protected _updateDebugMeshes(): void;
  41630. /**
  41631. * Renders a specified physic impostor
  41632. * @param impostor defines the impostor to render
  41633. * @returns the new debug mesh used to render the impostor
  41634. */
  41635. showImpostor(impostor: PhysicsImpostor): Nullable<AbstractMesh>;
  41636. /**
  41637. * Hides a specified physic impostor
  41638. * @param impostor defines the impostor to hide
  41639. */
  41640. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  41641. private _getDebugMaterial;
  41642. private _getDebugBoxMesh;
  41643. private _getDebugSphereMesh;
  41644. private _getDebugMesh;
  41645. /** Releases all resources */
  41646. dispose(): void;
  41647. }
  41648. }
  41649. declare module "babylonjs/Debug/rayHelper" {
  41650. import { Nullable } from "babylonjs/types";
  41651. import { Ray } from "babylonjs/Culling/ray";
  41652. import { Vector3, Color3 } from "babylonjs/Maths/math";
  41653. import { Scene } from "babylonjs/scene";
  41654. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41655. import "babylonjs/Meshes/Builders/linesBuilder";
  41656. /**
  41657. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  41658. * in order to better appreciate the issue one might have.
  41659. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  41660. */
  41661. export class RayHelper {
  41662. /**
  41663. * Defines the ray we are currently tryin to visualize.
  41664. */
  41665. ray: Nullable<Ray>;
  41666. private _renderPoints;
  41667. private _renderLine;
  41668. private _renderFunction;
  41669. private _scene;
  41670. private _updateToMeshFunction;
  41671. private _attachedToMesh;
  41672. private _meshSpaceDirection;
  41673. private _meshSpaceOrigin;
  41674. /**
  41675. * Helper function to create a colored helper in a scene in one line.
  41676. * @param ray Defines the ray we are currently tryin to visualize
  41677. * @param scene Defines the scene the ray is used in
  41678. * @param color Defines the color we want to see the ray in
  41679. * @returns The newly created ray helper.
  41680. */
  41681. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  41682. /**
  41683. * Instantiate a new ray helper.
  41684. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  41685. * in order to better appreciate the issue one might have.
  41686. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  41687. * @param ray Defines the ray we are currently tryin to visualize
  41688. */
  41689. constructor(ray: Ray);
  41690. /**
  41691. * Shows the ray we are willing to debug.
  41692. * @param scene Defines the scene the ray needs to be rendered in
  41693. * @param color Defines the color the ray needs to be rendered in
  41694. */
  41695. show(scene: Scene, color?: Color3): void;
  41696. /**
  41697. * Hides the ray we are debugging.
  41698. */
  41699. hide(): void;
  41700. private _render;
  41701. /**
  41702. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  41703. * @param mesh Defines the mesh we want the helper attached to
  41704. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  41705. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  41706. * @param length Defines the length of the ray
  41707. */
  41708. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  41709. /**
  41710. * Detach the ray helper from the mesh it has previously been attached to.
  41711. */
  41712. detachFromMesh(): void;
  41713. private _updateToMesh;
  41714. /**
  41715. * Dispose the helper and release its associated resources.
  41716. */
  41717. dispose(): void;
  41718. }
  41719. }
  41720. declare module "babylonjs/Debug/skeletonViewer" {
  41721. import { Color3 } from "babylonjs/Maths/math";
  41722. import { Scene } from "babylonjs/scene";
  41723. import { Nullable } from "babylonjs/types";
  41724. import { Skeleton } from "babylonjs/Bones/skeleton";
  41725. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41726. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  41727. /**
  41728. * Class used to render a debug view of a given skeleton
  41729. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  41730. */
  41731. export class SkeletonViewer {
  41732. /** defines the skeleton to render */
  41733. skeleton: Skeleton;
  41734. /** defines the mesh attached to the skeleton */
  41735. mesh: AbstractMesh;
  41736. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  41737. autoUpdateBonesMatrices: boolean;
  41738. /** defines the rendering group id to use with the viewer */
  41739. renderingGroupId: number;
  41740. /** Gets or sets the color used to render the skeleton */
  41741. color: Color3;
  41742. private _scene;
  41743. private _debugLines;
  41744. private _debugMesh;
  41745. private _isEnabled;
  41746. private _renderFunction;
  41747. private _utilityLayer;
  41748. /**
  41749. * Returns the mesh used to render the bones
  41750. */
  41751. readonly debugMesh: Nullable<LinesMesh>;
  41752. /**
  41753. * Creates a new SkeletonViewer
  41754. * @param skeleton defines the skeleton to render
  41755. * @param mesh defines the mesh attached to the skeleton
  41756. * @param scene defines the hosting scene
  41757. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  41758. * @param renderingGroupId defines the rendering group id to use with the viewer
  41759. */
  41760. constructor(
  41761. /** defines the skeleton to render */
  41762. skeleton: Skeleton,
  41763. /** defines the mesh attached to the skeleton */
  41764. mesh: AbstractMesh, scene: Scene,
  41765. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  41766. autoUpdateBonesMatrices?: boolean,
  41767. /** defines the rendering group id to use with the viewer */
  41768. renderingGroupId?: number);
  41769. /** Gets or sets a boolean indicating if the viewer is enabled */
  41770. isEnabled: boolean;
  41771. private _getBonePosition;
  41772. private _getLinesForBonesWithLength;
  41773. private _getLinesForBonesNoLength;
  41774. /** Update the viewer to sync with current skeleton state */
  41775. update(): void;
  41776. /** Release associated resources */
  41777. dispose(): void;
  41778. }
  41779. }
  41780. declare module "babylonjs/Debug/index" {
  41781. export * from "babylonjs/Debug/axesViewer";
  41782. export * from "babylonjs/Debug/boneAxesViewer";
  41783. export * from "babylonjs/Debug/debugLayer";
  41784. export * from "babylonjs/Debug/physicsViewer";
  41785. export * from "babylonjs/Debug/rayHelper";
  41786. export * from "babylonjs/Debug/skeletonViewer";
  41787. }
  41788. declare module "babylonjs/Engines/nullEngine" {
  41789. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  41790. import { Scene } from "babylonjs/scene";
  41791. import { Matrix, Color3, Color4, Viewport } from "babylonjs/Maths/math";
  41792. import { Engine } from "babylonjs/Engines/engine";
  41793. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  41794. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  41795. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  41796. import { Effect } from "babylonjs/Materials/effect";
  41797. /**
  41798. * Options to create the null engine
  41799. */
  41800. export class NullEngineOptions {
  41801. /**
  41802. * Render width (Default: 512)
  41803. */
  41804. renderWidth: number;
  41805. /**
  41806. * Render height (Default: 256)
  41807. */
  41808. renderHeight: number;
  41809. /**
  41810. * Texture size (Default: 512)
  41811. */
  41812. textureSize: number;
  41813. /**
  41814. * If delta time between frames should be constant
  41815. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41816. */
  41817. deterministicLockstep: boolean;
  41818. /**
  41819. * Maximum about of steps between frames (Default: 4)
  41820. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41821. */
  41822. lockstepMaxSteps: number;
  41823. }
  41824. /**
  41825. * The null engine class provides support for headless version of babylon.js.
  41826. * This can be used in server side scenario or for testing purposes
  41827. */
  41828. export class NullEngine extends Engine {
  41829. private _options;
  41830. /**
  41831. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41832. */
  41833. isDeterministicLockStep(): boolean;
  41834. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  41835. getLockstepMaxSteps(): number;
  41836. /**
  41837. * Sets hardware scaling, used to save performance if needed
  41838. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  41839. */
  41840. getHardwareScalingLevel(): number;
  41841. constructor(options?: NullEngineOptions);
  41842. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  41843. createIndexBuffer(indices: IndicesArray): WebGLBuffer;
  41844. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  41845. getRenderWidth(useScreen?: boolean): number;
  41846. getRenderHeight(useScreen?: boolean): number;
  41847. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  41848. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  41849. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  41850. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  41851. bindSamplers(effect: Effect): void;
  41852. enableEffect(effect: Effect): void;
  41853. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  41854. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  41855. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  41856. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  41857. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  41858. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  41859. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  41860. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  41861. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  41862. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  41863. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  41864. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  41865. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  41866. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  41867. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  41868. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  41869. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  41870. setFloat(uniform: WebGLUniformLocation, value: number): void;
  41871. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  41872. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  41873. setBool(uniform: WebGLUniformLocation, bool: number): void;
  41874. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  41875. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  41876. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  41877. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  41878. bindBuffers(vertexBuffers: {
  41879. [key: string]: VertexBuffer;
  41880. }, indexBuffer: WebGLBuffer, effect: Effect): void;
  41881. wipeCaches(bruteForce?: boolean): void;
  41882. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  41883. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  41884. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  41885. /** @hidden */
  41886. _createTexture(): WebGLTexture;
  41887. /** @hidden */
  41888. _releaseTexture(texture: InternalTexture): void;
  41889. 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;
  41890. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  41891. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  41892. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  41893. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  41894. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  41895. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  41896. areAllEffectsReady(): boolean;
  41897. /**
  41898. * @hidden
  41899. * Get the current error code of the webGL context
  41900. * @returns the error code
  41901. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  41902. */
  41903. getError(): number;
  41904. /** @hidden */
  41905. _getUnpackAlignement(): number;
  41906. /** @hidden */
  41907. _unpackFlipY(value: boolean): void;
  41908. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  41909. /**
  41910. * Updates a dynamic vertex buffer.
  41911. * @param vertexBuffer the vertex buffer to update
  41912. * @param data the data used to update the vertex buffer
  41913. * @param byteOffset the byte offset of the data (optional)
  41914. * @param byteLength the byte length of the data (optional)
  41915. */
  41916. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  41917. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  41918. /** @hidden */
  41919. _bindTexture(channel: number, texture: InternalTexture): void;
  41920. /** @hidden */
  41921. _releaseBuffer(buffer: WebGLBuffer): boolean;
  41922. releaseEffects(): void;
  41923. displayLoadingUI(): void;
  41924. hideLoadingUI(): void;
  41925. /** @hidden */
  41926. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  41927. /** @hidden */
  41928. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  41929. /** @hidden */
  41930. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  41931. /** @hidden */
  41932. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  41933. }
  41934. }
  41935. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  41936. import { Nullable, int } from "babylonjs/types";
  41937. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  41938. /** @hidden */
  41939. export class _OcclusionDataStorage {
  41940. /** @hidden */
  41941. occlusionInternalRetryCounter: number;
  41942. /** @hidden */
  41943. isOcclusionQueryInProgress: boolean;
  41944. /** @hidden */
  41945. isOccluded: boolean;
  41946. /** @hidden */
  41947. occlusionRetryCount: number;
  41948. /** @hidden */
  41949. occlusionType: number;
  41950. /** @hidden */
  41951. occlusionQueryAlgorithmType: number;
  41952. }
  41953. module "babylonjs/Engines/engine" {
  41954. interface Engine {
  41955. /**
  41956. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  41957. * @return the new query
  41958. */
  41959. createQuery(): WebGLQuery;
  41960. /**
  41961. * Delete and release a webGL query
  41962. * @param query defines the query to delete
  41963. * @return the current engine
  41964. */
  41965. deleteQuery(query: WebGLQuery): Engine;
  41966. /**
  41967. * Check if a given query has resolved and got its value
  41968. * @param query defines the query to check
  41969. * @returns true if the query got its value
  41970. */
  41971. isQueryResultAvailable(query: WebGLQuery): boolean;
  41972. /**
  41973. * Gets the value of a given query
  41974. * @param query defines the query to check
  41975. * @returns the value of the query
  41976. */
  41977. getQueryResult(query: WebGLQuery): number;
  41978. /**
  41979. * Initiates an occlusion query
  41980. * @param algorithmType defines the algorithm to use
  41981. * @param query defines the query to use
  41982. * @returns the current engine
  41983. * @see http://doc.babylonjs.com/features/occlusionquery
  41984. */
  41985. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  41986. /**
  41987. * Ends an occlusion query
  41988. * @see http://doc.babylonjs.com/features/occlusionquery
  41989. * @param algorithmType defines the algorithm to use
  41990. * @returns the current engine
  41991. */
  41992. endOcclusionQuery(algorithmType: number): Engine;
  41993. /**
  41994. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  41995. * Please note that only one query can be issued at a time
  41996. * @returns a time token used to track the time span
  41997. */
  41998. startTimeQuery(): Nullable<_TimeToken>;
  41999. /**
  42000. * Ends a time query
  42001. * @param token defines the token used to measure the time span
  42002. * @returns the time spent (in ns)
  42003. */
  42004. endTimeQuery(token: _TimeToken): int;
  42005. /** @hidden */
  42006. _currentNonTimestampToken: Nullable<_TimeToken>;
  42007. /** @hidden */
  42008. _createTimeQuery(): WebGLQuery;
  42009. /** @hidden */
  42010. _deleteTimeQuery(query: WebGLQuery): void;
  42011. /** @hidden */
  42012. _getGlAlgorithmType(algorithmType: number): number;
  42013. /** @hidden */
  42014. _getTimeQueryResult(query: WebGLQuery): any;
  42015. /** @hidden */
  42016. _getTimeQueryAvailability(query: WebGLQuery): any;
  42017. }
  42018. }
  42019. module "babylonjs/Meshes/abstractMesh" {
  42020. interface AbstractMesh {
  42021. /**
  42022. * Backing filed
  42023. * @hidden
  42024. */
  42025. __occlusionDataStorage: _OcclusionDataStorage;
  42026. /**
  42027. * Access property
  42028. * @hidden
  42029. */
  42030. _occlusionDataStorage: _OcclusionDataStorage;
  42031. /**
  42032. * 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.
  42033. * The default value is -1 which means don't break the query and wait till the result
  42034. * @see http://doc.babylonjs.com/features/occlusionquery
  42035. */
  42036. occlusionRetryCount: number;
  42037. /**
  42038. * 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:
  42039. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  42040. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  42041. * * 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.
  42042. * @see http://doc.babylonjs.com/features/occlusionquery
  42043. */
  42044. occlusionType: number;
  42045. /**
  42046. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  42047. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  42048. * * 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.
  42049. * @see http://doc.babylonjs.com/features/occlusionquery
  42050. */
  42051. occlusionQueryAlgorithmType: number;
  42052. /**
  42053. * 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
  42054. * @see http://doc.babylonjs.com/features/occlusionquery
  42055. */
  42056. isOccluded: boolean;
  42057. /**
  42058. * Flag to check the progress status of the query
  42059. * @see http://doc.babylonjs.com/features/occlusionquery
  42060. */
  42061. isOcclusionQueryInProgress: boolean;
  42062. }
  42063. }
  42064. }
  42065. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  42066. import { Nullable } from "babylonjs/types";
  42067. /** @hidden */
  42068. export var _forceTransformFeedbackToBundle: boolean;
  42069. module "babylonjs/Engines/engine" {
  42070. interface Engine {
  42071. /**
  42072. * Creates a webGL transform feedback object
  42073. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  42074. * @returns the webGL transform feedback object
  42075. */
  42076. createTransformFeedback(): WebGLTransformFeedback;
  42077. /**
  42078. * Delete a webGL transform feedback object
  42079. * @param value defines the webGL transform feedback object to delete
  42080. */
  42081. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  42082. /**
  42083. * Bind a webGL transform feedback object to the webgl context
  42084. * @param value defines the webGL transform feedback object to bind
  42085. */
  42086. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  42087. /**
  42088. * Begins a transform feedback operation
  42089. * @param usePoints defines if points or triangles must be used
  42090. */
  42091. beginTransformFeedback(usePoints: boolean): void;
  42092. /**
  42093. * Ends a transform feedback operation
  42094. */
  42095. endTransformFeedback(): void;
  42096. /**
  42097. * Specify the varyings to use with transform feedback
  42098. * @param program defines the associated webGL program
  42099. * @param value defines the list of strings representing the varying names
  42100. */
  42101. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  42102. /**
  42103. * Bind a webGL buffer for a transform feedback operation
  42104. * @param value defines the webGL buffer to bind
  42105. */
  42106. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  42107. }
  42108. }
  42109. }
  42110. declare module "babylonjs/Engines/Extensions/index" {
  42111. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  42112. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  42113. }
  42114. declare module "babylonjs/Engines/index" {
  42115. export * from "babylonjs/Engines/constants";
  42116. export * from "babylonjs/Engines/engine";
  42117. export * from "babylonjs/Engines/engineStore";
  42118. export * from "babylonjs/Engines/nullEngine";
  42119. export * from "babylonjs/Engines/Extensions/index";
  42120. }
  42121. declare module "babylonjs/Events/clipboardEvents" {
  42122. /**
  42123. * Gather the list of clipboard event types as constants.
  42124. */
  42125. export class ClipboardEventTypes {
  42126. /**
  42127. * The clipboard event is fired when a copy command is active (pressed).
  42128. */
  42129. static readonly COPY: number;
  42130. /**
  42131. * The clipboard event is fired when a cut command is active (pressed).
  42132. */
  42133. static readonly CUT: number;
  42134. /**
  42135. * The clipboard event is fired when a paste command is active (pressed).
  42136. */
  42137. static readonly PASTE: number;
  42138. }
  42139. /**
  42140. * This class is used to store clipboard related info for the onClipboardObservable event.
  42141. */
  42142. export class ClipboardInfo {
  42143. /**
  42144. * Defines the type of event (BABYLON.ClipboardEventTypes)
  42145. */
  42146. type: number;
  42147. /**
  42148. * Defines the related dom event
  42149. */
  42150. event: ClipboardEvent;
  42151. /**
  42152. *Creates an instance of ClipboardInfo.
  42153. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  42154. * @param event Defines the related dom event
  42155. */
  42156. constructor(
  42157. /**
  42158. * Defines the type of event (BABYLON.ClipboardEventTypes)
  42159. */
  42160. type: number,
  42161. /**
  42162. * Defines the related dom event
  42163. */
  42164. event: ClipboardEvent);
  42165. /**
  42166. * Get the clipboard event's type from the keycode.
  42167. * @param keyCode Defines the keyCode for the current keyboard event.
  42168. * @return {number}
  42169. */
  42170. static GetTypeFromCharacter(keyCode: number): number;
  42171. }
  42172. }
  42173. declare module "babylonjs/Events/index" {
  42174. export * from "babylonjs/Events/keyboardEvents";
  42175. export * from "babylonjs/Events/pointerEvents";
  42176. export * from "babylonjs/Events/clipboardEvents";
  42177. }
  42178. declare module "babylonjs/Loading/sceneLoader" {
  42179. import { Observable } from "babylonjs/Misc/observable";
  42180. import { Nullable } from "babylonjs/types";
  42181. import { Scene } from "babylonjs/scene";
  42182. import { Engine } from "babylonjs/Engines/engine";
  42183. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42184. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  42185. import { AssetContainer } from "babylonjs/assetContainer";
  42186. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  42187. import { Skeleton } from "babylonjs/Bones/skeleton";
  42188. /**
  42189. * Class used to represent data loading progression
  42190. */
  42191. export class SceneLoaderProgressEvent {
  42192. /** defines if data length to load can be evaluated */
  42193. readonly lengthComputable: boolean;
  42194. /** defines the loaded data length */
  42195. readonly loaded: number;
  42196. /** defines the data length to load */
  42197. readonly total: number;
  42198. /**
  42199. * Create a new progress event
  42200. * @param lengthComputable defines if data length to load can be evaluated
  42201. * @param loaded defines the loaded data length
  42202. * @param total defines the data length to load
  42203. */
  42204. constructor(
  42205. /** defines if data length to load can be evaluated */
  42206. lengthComputable: boolean,
  42207. /** defines the loaded data length */
  42208. loaded: number,
  42209. /** defines the data length to load */
  42210. total: number);
  42211. /**
  42212. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  42213. * @param event defines the source event
  42214. * @returns a new SceneLoaderProgressEvent
  42215. */
  42216. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  42217. }
  42218. /**
  42219. * Interface used by SceneLoader plugins to define supported file extensions
  42220. */
  42221. export interface ISceneLoaderPluginExtensions {
  42222. /**
  42223. * Defines the list of supported extensions
  42224. */
  42225. [extension: string]: {
  42226. isBinary: boolean;
  42227. };
  42228. }
  42229. /**
  42230. * Interface used by SceneLoader plugin factory
  42231. */
  42232. export interface ISceneLoaderPluginFactory {
  42233. /**
  42234. * Defines the name of the factory
  42235. */
  42236. name: string;
  42237. /**
  42238. * Function called to create a new plugin
  42239. * @return the new plugin
  42240. */
  42241. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  42242. /**
  42243. * Boolean indicating if the plugin can direct load specific data
  42244. */
  42245. canDirectLoad?: (data: string) => boolean;
  42246. }
  42247. /**
  42248. * Interface used to define a SceneLoader plugin
  42249. */
  42250. export interface ISceneLoaderPlugin {
  42251. /**
  42252. * The friendly name of this plugin.
  42253. */
  42254. name: string;
  42255. /**
  42256. * The file extensions supported by this plugin.
  42257. */
  42258. extensions: string | ISceneLoaderPluginExtensions;
  42259. /**
  42260. * Import meshes into a scene.
  42261. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42262. * @param scene The scene to import into
  42263. * @param data The data to import
  42264. * @param rootUrl The root url for scene and resources
  42265. * @param meshes The meshes array to import into
  42266. * @param particleSystems The particle systems array to import into
  42267. * @param skeletons The skeletons array to import into
  42268. * @param onError The callback when import fails
  42269. * @returns True if successful or false otherwise
  42270. */
  42271. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  42272. /**
  42273. * Load into a scene.
  42274. * @param scene The scene to load into
  42275. * @param data The data to import
  42276. * @param rootUrl The root url for scene and resources
  42277. * @param onError The callback when import fails
  42278. * @returns true if successful or false otherwise
  42279. */
  42280. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  42281. /**
  42282. * The callback that returns true if the data can be directly loaded.
  42283. */
  42284. canDirectLoad?: (data: string) => boolean;
  42285. /**
  42286. * The callback that allows custom handling of the root url based on the response url.
  42287. */
  42288. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  42289. /**
  42290. * Load into an asset container.
  42291. * @param scene The scene to load into
  42292. * @param data The data to import
  42293. * @param rootUrl The root url for scene and resources
  42294. * @param onError The callback when import fails
  42295. * @returns The loaded asset container
  42296. */
  42297. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  42298. }
  42299. /**
  42300. * Interface used to define an async SceneLoader plugin
  42301. */
  42302. export interface ISceneLoaderPluginAsync {
  42303. /**
  42304. * The friendly name of this plugin.
  42305. */
  42306. name: string;
  42307. /**
  42308. * The file extensions supported by this plugin.
  42309. */
  42310. extensions: string | ISceneLoaderPluginExtensions;
  42311. /**
  42312. * Import meshes into a scene.
  42313. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42314. * @param scene The scene to import into
  42315. * @param data The data to import
  42316. * @param rootUrl The root url for scene and resources
  42317. * @param onProgress The callback when the load progresses
  42318. * @param fileName Defines the name of the file to load
  42319. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  42320. */
  42321. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  42322. meshes: AbstractMesh[];
  42323. particleSystems: IParticleSystem[];
  42324. skeletons: Skeleton[];
  42325. animationGroups: AnimationGroup[];
  42326. }>;
  42327. /**
  42328. * Load into a scene.
  42329. * @param scene The scene to load into
  42330. * @param data The data to import
  42331. * @param rootUrl The root url for scene and resources
  42332. * @param onProgress The callback when the load progresses
  42333. * @param fileName Defines the name of the file to load
  42334. * @returns Nothing
  42335. */
  42336. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  42337. /**
  42338. * The callback that returns true if the data can be directly loaded.
  42339. */
  42340. canDirectLoad?: (data: string) => boolean;
  42341. /**
  42342. * The callback that allows custom handling of the root url based on the response url.
  42343. */
  42344. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  42345. /**
  42346. * Load into an asset container.
  42347. * @param scene The scene to load into
  42348. * @param data The data to import
  42349. * @param rootUrl The root url for scene and resources
  42350. * @param onProgress The callback when the load progresses
  42351. * @param fileName Defines the name of the file to load
  42352. * @returns The loaded asset container
  42353. */
  42354. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  42355. }
  42356. /**
  42357. * Class used to load scene from various file formats using registered plugins
  42358. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  42359. */
  42360. export class SceneLoader {
  42361. /**
  42362. * No logging while loading
  42363. */
  42364. static readonly NO_LOGGING: number;
  42365. /**
  42366. * Minimal logging while loading
  42367. */
  42368. static readonly MINIMAL_LOGGING: number;
  42369. /**
  42370. * Summary logging while loading
  42371. */
  42372. static readonly SUMMARY_LOGGING: number;
  42373. /**
  42374. * Detailled logging while loading
  42375. */
  42376. static readonly DETAILED_LOGGING: number;
  42377. /**
  42378. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  42379. */
  42380. static ForceFullSceneLoadingForIncremental: boolean;
  42381. /**
  42382. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  42383. */
  42384. static ShowLoadingScreen: boolean;
  42385. /**
  42386. * Defines the current logging level (while loading the scene)
  42387. * @ignorenaming
  42388. */
  42389. static loggingLevel: number;
  42390. /**
  42391. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  42392. */
  42393. static CleanBoneMatrixWeights: boolean;
  42394. /**
  42395. * Event raised when a plugin is used to load a scene
  42396. */
  42397. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  42398. private static _registeredPlugins;
  42399. private static _getDefaultPlugin;
  42400. private static _getPluginForExtension;
  42401. private static _getPluginForDirectLoad;
  42402. private static _getPluginForFilename;
  42403. private static _getDirectLoad;
  42404. private static _loadData;
  42405. private static _getFileInfo;
  42406. /**
  42407. * Gets a plugin that can load the given extension
  42408. * @param extension defines the extension to load
  42409. * @returns a plugin or null if none works
  42410. */
  42411. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  42412. /**
  42413. * Gets a boolean indicating that the given extension can be loaded
  42414. * @param extension defines the extension to load
  42415. * @returns true if the extension is supported
  42416. */
  42417. static IsPluginForExtensionAvailable(extension: string): boolean;
  42418. /**
  42419. * Adds a new plugin to the list of registered plugins
  42420. * @param plugin defines the plugin to add
  42421. */
  42422. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  42423. /**
  42424. * Import meshes into a scene
  42425. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42426. * @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)
  42427. * @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)
  42428. * @param scene the instance of BABYLON.Scene to append to
  42429. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  42430. * @param onProgress a callback with a progress event for each file being loaded
  42431. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42432. * @param pluginExtension the extension used to determine the plugin
  42433. * @returns The loaded plugin
  42434. */
  42435. 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>;
  42436. /**
  42437. * Import meshes into a scene
  42438. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42439. * @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)
  42440. * @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)
  42441. * @param scene the instance of BABYLON.Scene to append to
  42442. * @param onProgress a callback with a progress event for each file being loaded
  42443. * @param pluginExtension the extension used to determine the plugin
  42444. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  42445. */
  42446. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  42447. meshes: AbstractMesh[];
  42448. particleSystems: IParticleSystem[];
  42449. skeletons: Skeleton[];
  42450. animationGroups: AnimationGroup[];
  42451. }>;
  42452. /**
  42453. * Load a scene
  42454. * @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)
  42455. * @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)
  42456. * @param engine is the instance of BABYLON.Engine to use to create the scene
  42457. * @param onSuccess a callback with the scene when import succeeds
  42458. * @param onProgress a callback with a progress event for each file being loaded
  42459. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42460. * @param pluginExtension the extension used to determine the plugin
  42461. * @returns The loaded plugin
  42462. */
  42463. 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>;
  42464. /**
  42465. * Load a scene
  42466. * @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)
  42467. * @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)
  42468. * @param engine is the instance of BABYLON.Engine to use to create the scene
  42469. * @param onProgress a callback with a progress event for each file being loaded
  42470. * @param pluginExtension the extension used to determine the plugin
  42471. * @returns The loaded scene
  42472. */
  42473. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  42474. /**
  42475. * Append a scene
  42476. * @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)
  42477. * @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)
  42478. * @param scene is the instance of BABYLON.Scene to append to
  42479. * @param onSuccess a callback with the scene when import succeeds
  42480. * @param onProgress a callback with a progress event for each file being loaded
  42481. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42482. * @param pluginExtension the extension used to determine the plugin
  42483. * @returns The loaded plugin
  42484. */
  42485. 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>;
  42486. /**
  42487. * Append a scene
  42488. * @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)
  42489. * @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)
  42490. * @param scene is the instance of BABYLON.Scene to append to
  42491. * @param onProgress a callback with a progress event for each file being loaded
  42492. * @param pluginExtension the extension used to determine the plugin
  42493. * @returns The given scene
  42494. */
  42495. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  42496. /**
  42497. * Load a scene into an asset container
  42498. * @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)
  42499. * @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)
  42500. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  42501. * @param onSuccess a callback with the scene when import succeeds
  42502. * @param onProgress a callback with a progress event for each file being loaded
  42503. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42504. * @param pluginExtension the extension used to determine the plugin
  42505. * @returns The loaded plugin
  42506. */
  42507. 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>;
  42508. /**
  42509. * Load a scene into an asset container
  42510. * @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)
  42511. * @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)
  42512. * @param scene is the instance of Scene to append to
  42513. * @param onProgress a callback with a progress event for each file being loaded
  42514. * @param pluginExtension the extension used to determine the plugin
  42515. * @returns The loaded asset container
  42516. */
  42517. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  42518. }
  42519. }
  42520. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  42521. import { Scene } from "babylonjs/scene";
  42522. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42523. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  42524. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42525. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42526. /**
  42527. * Google Daydream controller
  42528. */
  42529. export class DaydreamController extends WebVRController {
  42530. /**
  42531. * Base Url for the controller model.
  42532. */
  42533. static MODEL_BASE_URL: string;
  42534. /**
  42535. * File name for the controller model.
  42536. */
  42537. static MODEL_FILENAME: string;
  42538. /**
  42539. * Gamepad Id prefix used to identify Daydream Controller.
  42540. */
  42541. static readonly GAMEPAD_ID_PREFIX: string;
  42542. /**
  42543. * Creates a new DaydreamController from a gamepad
  42544. * @param vrGamepad the gamepad that the controller should be created from
  42545. */
  42546. constructor(vrGamepad: any);
  42547. /**
  42548. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42549. * @param scene scene in which to add meshes
  42550. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42551. */
  42552. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42553. /**
  42554. * Called once for each button that changed state since the last frame
  42555. * @param buttonIdx Which button index changed
  42556. * @param state New state of the button
  42557. * @param changes Which properties on the state changed since last frame
  42558. */
  42559. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42560. }
  42561. }
  42562. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  42563. import { Scene } from "babylonjs/scene";
  42564. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42565. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  42566. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42567. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42568. /**
  42569. * Gear VR Controller
  42570. */
  42571. export class GearVRController extends WebVRController {
  42572. /**
  42573. * Base Url for the controller model.
  42574. */
  42575. static MODEL_BASE_URL: string;
  42576. /**
  42577. * File name for the controller model.
  42578. */
  42579. static MODEL_FILENAME: string;
  42580. /**
  42581. * Gamepad Id prefix used to identify this controller.
  42582. */
  42583. static readonly GAMEPAD_ID_PREFIX: string;
  42584. private readonly _buttonIndexToObservableNameMap;
  42585. /**
  42586. * Creates a new GearVRController from a gamepad
  42587. * @param vrGamepad the gamepad that the controller should be created from
  42588. */
  42589. constructor(vrGamepad: any);
  42590. /**
  42591. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42592. * @param scene scene in which to add meshes
  42593. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42594. */
  42595. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42596. /**
  42597. * Called once for each button that changed state since the last frame
  42598. * @param buttonIdx Which button index changed
  42599. * @param state New state of the button
  42600. * @param changes Which properties on the state changed since last frame
  42601. */
  42602. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42603. }
  42604. }
  42605. declare module "babylonjs/Gamepads/Controllers/genericController" {
  42606. import { Scene } from "babylonjs/scene";
  42607. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42608. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42609. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42610. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  42611. /**
  42612. * Generic Controller
  42613. */
  42614. export class GenericController extends WebVRController {
  42615. /**
  42616. * Base Url for the controller model.
  42617. */
  42618. static readonly MODEL_BASE_URL: string;
  42619. /**
  42620. * File name for the controller model.
  42621. */
  42622. static readonly MODEL_FILENAME: string;
  42623. /**
  42624. * Creates a new GenericController from a gamepad
  42625. * @param vrGamepad the gamepad that the controller should be created from
  42626. */
  42627. constructor(vrGamepad: any);
  42628. /**
  42629. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42630. * @param scene scene in which to add meshes
  42631. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42632. */
  42633. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42634. /**
  42635. * Called once for each button that changed state since the last frame
  42636. * @param buttonIdx Which button index changed
  42637. * @param state New state of the button
  42638. * @param changes Which properties on the state changed since last frame
  42639. */
  42640. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42641. }
  42642. }
  42643. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  42644. import { Observable } from "babylonjs/Misc/observable";
  42645. import { Scene } from "babylonjs/scene";
  42646. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42647. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42648. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42649. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  42650. /**
  42651. * Oculus Touch Controller
  42652. */
  42653. export class OculusTouchController extends WebVRController {
  42654. /**
  42655. * Base Url for the controller model.
  42656. */
  42657. static MODEL_BASE_URL: string;
  42658. /**
  42659. * File name for the left controller model.
  42660. */
  42661. static MODEL_LEFT_FILENAME: string;
  42662. /**
  42663. * File name for the right controller model.
  42664. */
  42665. static MODEL_RIGHT_FILENAME: string;
  42666. /**
  42667. * Fired when the secondary trigger on this controller is modified
  42668. */
  42669. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  42670. /**
  42671. * Fired when the thumb rest on this controller is modified
  42672. */
  42673. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  42674. /**
  42675. * Creates a new OculusTouchController from a gamepad
  42676. * @param vrGamepad the gamepad that the controller should be created from
  42677. */
  42678. constructor(vrGamepad: any);
  42679. /**
  42680. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42681. * @param scene scene in which to add meshes
  42682. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42683. */
  42684. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42685. /**
  42686. * Fired when the A button on this controller is modified
  42687. */
  42688. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42689. /**
  42690. * Fired when the B button on this controller is modified
  42691. */
  42692. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42693. /**
  42694. * Fired when the X button on this controller is modified
  42695. */
  42696. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42697. /**
  42698. * Fired when the Y button on this controller is modified
  42699. */
  42700. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42701. /**
  42702. * Called once for each button that changed state since the last frame
  42703. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  42704. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  42705. * 2) secondary trigger (same)
  42706. * 3) A (right) X (left), touch, pressed = value
  42707. * 4) B / Y
  42708. * 5) thumb rest
  42709. * @param buttonIdx Which button index changed
  42710. * @param state New state of the button
  42711. * @param changes Which properties on the state changed since last frame
  42712. */
  42713. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42714. }
  42715. }
  42716. declare module "babylonjs/Gamepads/Controllers/viveController" {
  42717. import { Scene } from "babylonjs/scene";
  42718. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42719. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42720. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42721. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  42722. import { Observable } from "babylonjs/Misc/observable";
  42723. /**
  42724. * Vive Controller
  42725. */
  42726. export class ViveController extends WebVRController {
  42727. /**
  42728. * Base Url for the controller model.
  42729. */
  42730. static MODEL_BASE_URL: string;
  42731. /**
  42732. * File name for the controller model.
  42733. */
  42734. static MODEL_FILENAME: string;
  42735. /**
  42736. * Creates a new ViveController from a gamepad
  42737. * @param vrGamepad the gamepad that the controller should be created from
  42738. */
  42739. constructor(vrGamepad: any);
  42740. /**
  42741. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42742. * @param scene scene in which to add meshes
  42743. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42744. */
  42745. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42746. /**
  42747. * Fired when the left button on this controller is modified
  42748. */
  42749. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42750. /**
  42751. * Fired when the right button on this controller is modified
  42752. */
  42753. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42754. /**
  42755. * Fired when the menu button on this controller is modified
  42756. */
  42757. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42758. /**
  42759. * Called once for each button that changed state since the last frame
  42760. * Vive mapping:
  42761. * 0: touchpad
  42762. * 1: trigger
  42763. * 2: left AND right buttons
  42764. * 3: menu button
  42765. * @param buttonIdx Which button index changed
  42766. * @param state New state of the button
  42767. * @param changes Which properties on the state changed since last frame
  42768. */
  42769. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42770. }
  42771. }
  42772. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  42773. import { Observable } from "babylonjs/Misc/observable";
  42774. import { Scene } from "babylonjs/scene";
  42775. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42776. import { Ray } from "babylonjs/Culling/ray";
  42777. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42778. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42779. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  42780. /**
  42781. * Defines the WindowsMotionController object that the state of the windows motion controller
  42782. */
  42783. export class WindowsMotionController extends WebVRController {
  42784. /**
  42785. * The base url used to load the left and right controller models
  42786. */
  42787. static MODEL_BASE_URL: string;
  42788. /**
  42789. * The name of the left controller model file
  42790. */
  42791. static MODEL_LEFT_FILENAME: string;
  42792. /**
  42793. * The name of the right controller model file
  42794. */
  42795. static MODEL_RIGHT_FILENAME: string;
  42796. /**
  42797. * The controller name prefix for this controller type
  42798. */
  42799. static readonly GAMEPAD_ID_PREFIX: string;
  42800. /**
  42801. * The controller id pattern for this controller type
  42802. */
  42803. private static readonly GAMEPAD_ID_PATTERN;
  42804. private _loadedMeshInfo;
  42805. private readonly _mapping;
  42806. /**
  42807. * Fired when the trackpad on this controller is clicked
  42808. */
  42809. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  42810. /**
  42811. * Fired when the trackpad on this controller is modified
  42812. */
  42813. onTrackpadValuesChangedObservable: Observable<StickValues>;
  42814. /**
  42815. * The current x and y values of this controller's trackpad
  42816. */
  42817. trackpad: StickValues;
  42818. /**
  42819. * Creates a new WindowsMotionController from a gamepad
  42820. * @param vrGamepad the gamepad that the controller should be created from
  42821. */
  42822. constructor(vrGamepad: any);
  42823. /**
  42824. * Fired when the trigger on this controller is modified
  42825. */
  42826. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42827. /**
  42828. * Fired when the menu button on this controller is modified
  42829. */
  42830. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42831. /**
  42832. * Fired when the grip button on this controller is modified
  42833. */
  42834. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42835. /**
  42836. * Fired when the thumbstick button on this controller is modified
  42837. */
  42838. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42839. /**
  42840. * Fired when the touchpad button on this controller is modified
  42841. */
  42842. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42843. /**
  42844. * Fired when the touchpad values on this controller are modified
  42845. */
  42846. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  42847. private _updateTrackpad;
  42848. /**
  42849. * Called once per frame by the engine.
  42850. */
  42851. update(): void;
  42852. /**
  42853. * Called once for each button that changed state since the last frame
  42854. * @param buttonIdx Which button index changed
  42855. * @param state New state of the button
  42856. * @param changes Which properties on the state changed since last frame
  42857. */
  42858. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42859. /**
  42860. * Moves the buttons on the controller mesh based on their current state
  42861. * @param buttonName the name of the button to move
  42862. * @param buttonValue the value of the button which determines the buttons new position
  42863. */
  42864. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  42865. /**
  42866. * Moves the axis on the controller mesh based on its current state
  42867. * @param axis the index of the axis
  42868. * @param axisValue the value of the axis which determines the meshes new position
  42869. * @hidden
  42870. */
  42871. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  42872. /**
  42873. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42874. * @param scene scene in which to add meshes
  42875. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42876. */
  42877. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  42878. /**
  42879. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  42880. * can be transformed by button presses and axes values, based on this._mapping.
  42881. *
  42882. * @param scene scene in which the meshes exist
  42883. * @param meshes list of meshes that make up the controller model to process
  42884. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  42885. */
  42886. private processModel;
  42887. private createMeshInfo;
  42888. /**
  42889. * Gets the ray of the controller in the direction the controller is pointing
  42890. * @param length the length the resulting ray should be
  42891. * @returns a ray in the direction the controller is pointing
  42892. */
  42893. getForwardRay(length?: number): Ray;
  42894. /**
  42895. * Disposes of the controller
  42896. */
  42897. dispose(): void;
  42898. }
  42899. }
  42900. declare module "babylonjs/Gamepads/Controllers/index" {
  42901. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  42902. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  42903. export * from "babylonjs/Gamepads/Controllers/genericController";
  42904. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  42905. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42906. export * from "babylonjs/Gamepads/Controllers/viveController";
  42907. export * from "babylonjs/Gamepads/Controllers/webVRController";
  42908. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  42909. }
  42910. declare module "babylonjs/Gamepads/index" {
  42911. export * from "babylonjs/Gamepads/Controllers/index";
  42912. export * from "babylonjs/Gamepads/gamepad";
  42913. export * from "babylonjs/Gamepads/gamepadManager";
  42914. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  42915. export * from "babylonjs/Gamepads/xboxGamepad";
  42916. }
  42917. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  42918. import { Observable } from "babylonjs/Misc/observable";
  42919. import { Nullable } from "babylonjs/types";
  42920. import { Vector3, Color3 } from "babylonjs/Maths/math";
  42921. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42922. import { Mesh } from "babylonjs/Meshes/mesh";
  42923. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  42924. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  42925. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  42926. /**
  42927. * Single axis scale gizmo
  42928. */
  42929. export class AxisScaleGizmo extends Gizmo {
  42930. private _coloredMaterial;
  42931. /**
  42932. * Drag behavior responsible for the gizmos dragging interactions
  42933. */
  42934. dragBehavior: PointerDragBehavior;
  42935. private _pointerObserver;
  42936. /**
  42937. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42938. */
  42939. snapDistance: number;
  42940. /**
  42941. * Event that fires each time the gizmo snaps to a new location.
  42942. * * snapDistance is the the change in distance
  42943. */
  42944. onSnapObservable: Observable<{
  42945. snapDistance: number;
  42946. }>;
  42947. /**
  42948. * If the scaling operation should be done on all axis (default: false)
  42949. */
  42950. uniformScaling: boolean;
  42951. /**
  42952. * Creates an AxisScaleGizmo
  42953. * @param gizmoLayer The utility layer the gizmo will be added to
  42954. * @param dragAxis The axis which the gizmo will be able to scale on
  42955. * @param color The color of the gizmo
  42956. */
  42957. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  42958. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42959. /**
  42960. * Disposes of the gizmo
  42961. */
  42962. dispose(): void;
  42963. /**
  42964. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  42965. * @param mesh The mesh to replace the default mesh of the gizmo
  42966. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  42967. */
  42968. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  42969. }
  42970. }
  42971. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  42972. import { Observable } from "babylonjs/Misc/observable";
  42973. import { Nullable } from "babylonjs/types";
  42974. import { Vector3, Color3 } from "babylonjs/Maths/math";
  42975. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42976. import { Mesh } from "babylonjs/Meshes/mesh";
  42977. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  42978. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  42979. import "babylonjs/Meshes/Builders/boxBuilder";
  42980. /**
  42981. * Bounding box gizmo
  42982. */
  42983. export class BoundingBoxGizmo extends Gizmo {
  42984. private _lineBoundingBox;
  42985. private _rotateSpheresParent;
  42986. private _scaleBoxesParent;
  42987. private _boundingDimensions;
  42988. private _renderObserver;
  42989. private _pointerObserver;
  42990. private _scaleDragSpeed;
  42991. private _tmpQuaternion;
  42992. private _tmpVector;
  42993. private _tmpRotationMatrix;
  42994. /**
  42995. * 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)
  42996. */
  42997. ignoreChildren: boolean;
  42998. /**
  42999. * 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)
  43000. */
  43001. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  43002. /**
  43003. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  43004. */
  43005. rotationSphereSize: number;
  43006. /**
  43007. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  43008. */
  43009. scaleBoxSize: number;
  43010. /**
  43011. * 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)
  43012. */
  43013. fixedDragMeshScreenSize: boolean;
  43014. /**
  43015. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  43016. */
  43017. fixedDragMeshScreenSizeDistanceFactor: number;
  43018. /**
  43019. * Fired when a rotation sphere or scale box is dragged
  43020. */
  43021. onDragStartObservable: Observable<{}>;
  43022. /**
  43023. * Fired when a scale box is dragged
  43024. */
  43025. onScaleBoxDragObservable: Observable<{}>;
  43026. /**
  43027. * Fired when a scale box drag is ended
  43028. */
  43029. onScaleBoxDragEndObservable: Observable<{}>;
  43030. /**
  43031. * Fired when a rotation sphere is dragged
  43032. */
  43033. onRotationSphereDragObservable: Observable<{}>;
  43034. /**
  43035. * Fired when a rotation sphere drag is ended
  43036. */
  43037. onRotationSphereDragEndObservable: Observable<{}>;
  43038. /**
  43039. * 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)
  43040. */
  43041. scalePivot: Nullable<Vector3>;
  43042. private _anchorMesh;
  43043. private _existingMeshScale;
  43044. private _dragMesh;
  43045. private pointerDragBehavior;
  43046. private coloredMaterial;
  43047. private hoverColoredMaterial;
  43048. /**
  43049. * Sets the color of the bounding box gizmo
  43050. * @param color the color to set
  43051. */
  43052. setColor(color: Color3): void;
  43053. /**
  43054. * Creates an BoundingBoxGizmo
  43055. * @param gizmoLayer The utility layer the gizmo will be added to
  43056. * @param color The color of the gizmo
  43057. */
  43058. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  43059. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43060. private _selectNode;
  43061. /**
  43062. * Updates the bounding box information for the Gizmo
  43063. */
  43064. updateBoundingBox(): void;
  43065. private _updateRotationSpheres;
  43066. private _updateScaleBoxes;
  43067. /**
  43068. * Enables rotation on the specified axis and disables rotation on the others
  43069. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  43070. */
  43071. setEnabledRotationAxis(axis: string): void;
  43072. /**
  43073. * Enables/disables scaling
  43074. * @param enable if scaling should be enabled
  43075. */
  43076. setEnabledScaling(enable: boolean): void;
  43077. private _updateDummy;
  43078. /**
  43079. * Enables a pointer drag behavior on the bounding box of the gizmo
  43080. */
  43081. enableDragBehavior(): void;
  43082. /**
  43083. * Disposes of the gizmo
  43084. */
  43085. dispose(): void;
  43086. /**
  43087. * 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)
  43088. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  43089. * @returns the bounding box mesh with the passed in mesh as a child
  43090. */
  43091. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  43092. /**
  43093. * CustomMeshes are not supported by this gizmo
  43094. * @param mesh The mesh to replace the default mesh of the gizmo
  43095. */
  43096. setCustomMesh(mesh: Mesh): void;
  43097. }
  43098. }
  43099. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  43100. import { Observable } from "babylonjs/Misc/observable";
  43101. import { Nullable } from "babylonjs/types";
  43102. import { Vector3, Color3 } from "babylonjs/Maths/math";
  43103. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43104. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  43105. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43106. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43107. import "babylonjs/Meshes/Builders/linesBuilder";
  43108. /**
  43109. * Single plane rotation gizmo
  43110. */
  43111. export class PlaneRotationGizmo extends Gizmo {
  43112. /**
  43113. * Drag behavior responsible for the gizmos dragging interactions
  43114. */
  43115. dragBehavior: PointerDragBehavior;
  43116. private _pointerObserver;
  43117. /**
  43118. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  43119. */
  43120. snapDistance: number;
  43121. /**
  43122. * Event that fires each time the gizmo snaps to a new location.
  43123. * * snapDistance is the the change in distance
  43124. */
  43125. onSnapObservable: Observable<{
  43126. snapDistance: number;
  43127. }>;
  43128. /**
  43129. * Creates a PlaneRotationGizmo
  43130. * @param gizmoLayer The utility layer the gizmo will be added to
  43131. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  43132. * @param color The color of the gizmo
  43133. * @param tessellation Amount of tessellation to be used when creating rotation circles
  43134. */
  43135. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  43136. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43137. /**
  43138. * Disposes of the gizmo
  43139. */
  43140. dispose(): void;
  43141. }
  43142. }
  43143. declare module "babylonjs/Gizmos/rotationGizmo" {
  43144. import { Observable } from "babylonjs/Misc/observable";
  43145. import { Nullable } from "babylonjs/types";
  43146. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43147. import { Mesh } from "babylonjs/Meshes/mesh";
  43148. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43149. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  43150. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43151. /**
  43152. * Gizmo that enables rotating a mesh along 3 axis
  43153. */
  43154. export class RotationGizmo extends Gizmo {
  43155. /**
  43156. * Internal gizmo used for interactions on the x axis
  43157. */
  43158. xGizmo: PlaneRotationGizmo;
  43159. /**
  43160. * Internal gizmo used for interactions on the y axis
  43161. */
  43162. yGizmo: PlaneRotationGizmo;
  43163. /**
  43164. * Internal gizmo used for interactions on the z axis
  43165. */
  43166. zGizmo: PlaneRotationGizmo;
  43167. /** Fires an event when any of it's sub gizmos are dragged */
  43168. onDragStartObservable: Observable<{}>;
  43169. /** Fires an event when any of it's sub gizmos are released from dragging */
  43170. onDragEndObservable: Observable<{}>;
  43171. attachedMesh: Nullable<AbstractMesh>;
  43172. /**
  43173. * Creates a RotationGizmo
  43174. * @param gizmoLayer The utility layer the gizmo will be added to
  43175. * @param tessellation Amount of tessellation to be used when creating rotation circles
  43176. */
  43177. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  43178. updateGizmoRotationToMatchAttachedMesh: boolean;
  43179. /**
  43180. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43181. */
  43182. snapDistance: number;
  43183. /**
  43184. * Ratio for the scale of the gizmo (Default: 1)
  43185. */
  43186. scaleRatio: number;
  43187. /**
  43188. * Disposes of the gizmo
  43189. */
  43190. dispose(): void;
  43191. /**
  43192. * CustomMeshes are not supported by this gizmo
  43193. * @param mesh The mesh to replace the default mesh of the gizmo
  43194. */
  43195. setCustomMesh(mesh: Mesh): void;
  43196. }
  43197. }
  43198. declare module "babylonjs/Gizmos/positionGizmo" {
  43199. import { Observable } from "babylonjs/Misc/observable";
  43200. import { Nullable } from "babylonjs/types";
  43201. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43202. import { Mesh } from "babylonjs/Meshes/mesh";
  43203. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43204. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  43205. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43206. /**
  43207. * Gizmo that enables dragging a mesh along 3 axis
  43208. */
  43209. export class PositionGizmo extends Gizmo {
  43210. /**
  43211. * Internal gizmo used for interactions on the x axis
  43212. */
  43213. xGizmo: AxisDragGizmo;
  43214. /**
  43215. * Internal gizmo used for interactions on the y axis
  43216. */
  43217. yGizmo: AxisDragGizmo;
  43218. /**
  43219. * Internal gizmo used for interactions on the z axis
  43220. */
  43221. zGizmo: AxisDragGizmo;
  43222. /** Fires an event when any of it's sub gizmos are dragged */
  43223. onDragStartObservable: Observable<{}>;
  43224. /** Fires an event when any of it's sub gizmos are released from dragging */
  43225. onDragEndObservable: Observable<{}>;
  43226. attachedMesh: Nullable<AbstractMesh>;
  43227. /**
  43228. * Creates a PositionGizmo
  43229. * @param gizmoLayer The utility layer the gizmo will be added to
  43230. */
  43231. constructor(gizmoLayer?: UtilityLayerRenderer);
  43232. updateGizmoRotationToMatchAttachedMesh: boolean;
  43233. /**
  43234. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43235. */
  43236. snapDistance: number;
  43237. /**
  43238. * Ratio for the scale of the gizmo (Default: 1)
  43239. */
  43240. scaleRatio: number;
  43241. /**
  43242. * Disposes of the gizmo
  43243. */
  43244. dispose(): void;
  43245. /**
  43246. * CustomMeshes are not supported by this gizmo
  43247. * @param mesh The mesh to replace the default mesh of the gizmo
  43248. */
  43249. setCustomMesh(mesh: Mesh): void;
  43250. }
  43251. }
  43252. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  43253. import { Scene } from "babylonjs/scene";
  43254. import { Color4, Vector4 } from "babylonjs/Maths/math";
  43255. import { Mesh } from "babylonjs/Meshes/mesh";
  43256. /**
  43257. * Class containing static functions to help procedurally build meshes
  43258. */
  43259. export class PolyhedronBuilder {
  43260. /**
  43261. * Creates a polyhedron mesh
  43262. * * 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
  43263. * * The parameter `size` (positive float, default 1) sets the polygon size
  43264. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  43265. * * 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`
  43266. * * 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
  43267. * * 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)`)
  43268. * * 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
  43269. * * 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
  43270. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43271. * * If you create a double-sided mesh, you can choose what parts of 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
  43272. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43273. * @param name defines the name of the mesh
  43274. * @param options defines the options used to create the mesh
  43275. * @param scene defines the hosting scene
  43276. * @returns the polyhedron mesh
  43277. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  43278. */
  43279. static CreatePolyhedron(name: string, options: {
  43280. type?: number;
  43281. size?: number;
  43282. sizeX?: number;
  43283. sizeY?: number;
  43284. sizeZ?: number;
  43285. custom?: any;
  43286. faceUV?: Vector4[];
  43287. faceColors?: Color4[];
  43288. flat?: boolean;
  43289. updatable?: boolean;
  43290. sideOrientation?: number;
  43291. frontUVs?: Vector4;
  43292. backUVs?: Vector4;
  43293. }, scene: Scene): Mesh;
  43294. }
  43295. }
  43296. declare module "babylonjs/Gizmos/scaleGizmo" {
  43297. import { Observable } from "babylonjs/Misc/observable";
  43298. import { Nullable } from "babylonjs/types";
  43299. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43300. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43301. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  43302. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43303. /**
  43304. * Gizmo that enables scaling a mesh along 3 axis
  43305. */
  43306. export class ScaleGizmo extends Gizmo {
  43307. /**
  43308. * Internal gizmo used for interactions on the x axis
  43309. */
  43310. xGizmo: AxisScaleGizmo;
  43311. /**
  43312. * Internal gizmo used for interactions on the y axis
  43313. */
  43314. yGizmo: AxisScaleGizmo;
  43315. /**
  43316. * Internal gizmo used for interactions on the z axis
  43317. */
  43318. zGizmo: AxisScaleGizmo;
  43319. /**
  43320. * Internal gizmo used to scale all axis equally
  43321. */
  43322. uniformScaleGizmo: AxisScaleGizmo;
  43323. /** Fires an event when any of it's sub gizmos are dragged */
  43324. onDragStartObservable: Observable<{}>;
  43325. /** Fires an event when any of it's sub gizmos are released from dragging */
  43326. onDragEndObservable: Observable<{}>;
  43327. attachedMesh: Nullable<AbstractMesh>;
  43328. /**
  43329. * Creates a ScaleGizmo
  43330. * @param gizmoLayer The utility layer the gizmo will be added to
  43331. */
  43332. constructor(gizmoLayer?: UtilityLayerRenderer);
  43333. updateGizmoRotationToMatchAttachedMesh: boolean;
  43334. /**
  43335. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43336. */
  43337. snapDistance: number;
  43338. /**
  43339. * Ratio for the scale of the gizmo (Default: 1)
  43340. */
  43341. scaleRatio: number;
  43342. /**
  43343. * Disposes of the gizmo
  43344. */
  43345. dispose(): void;
  43346. }
  43347. }
  43348. declare module "babylonjs/Gizmos/gizmoManager" {
  43349. import { Observable } from "babylonjs/Misc/observable";
  43350. import { Nullable } from "babylonjs/types";
  43351. import { Scene, IDisposable } from "babylonjs/scene";
  43352. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43353. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  43354. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  43355. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  43356. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  43357. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  43358. /**
  43359. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  43360. */
  43361. export class GizmoManager implements IDisposable {
  43362. private scene;
  43363. /**
  43364. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  43365. */
  43366. gizmos: {
  43367. positionGizmo: Nullable<PositionGizmo>;
  43368. rotationGizmo: Nullable<RotationGizmo>;
  43369. scaleGizmo: Nullable<ScaleGizmo>;
  43370. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  43371. };
  43372. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  43373. clearGizmoOnEmptyPointerEvent: boolean;
  43374. /** Fires an event when the manager is attached to a mesh */
  43375. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  43376. private _gizmosEnabled;
  43377. private _pointerObserver;
  43378. private _attachedMesh;
  43379. private _boundingBoxColor;
  43380. private _defaultUtilityLayer;
  43381. private _defaultKeepDepthUtilityLayer;
  43382. /**
  43383. * When bounding box gizmo is enabled, this can be used to track drag/end events
  43384. */
  43385. boundingBoxDragBehavior: SixDofDragBehavior;
  43386. /**
  43387. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  43388. */
  43389. attachableMeshes: Nullable<Array<AbstractMesh>>;
  43390. /**
  43391. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  43392. */
  43393. usePointerToAttachGizmos: boolean;
  43394. /**
  43395. * Instatiates a gizmo manager
  43396. * @param scene the scene to overlay the gizmos on top of
  43397. */
  43398. constructor(scene: Scene);
  43399. /**
  43400. * Attaches a set of gizmos to the specified mesh
  43401. * @param mesh The mesh the gizmo's should be attached to
  43402. */
  43403. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  43404. /**
  43405. * If the position gizmo is enabled
  43406. */
  43407. positionGizmoEnabled: boolean;
  43408. /**
  43409. * If the rotation gizmo is enabled
  43410. */
  43411. rotationGizmoEnabled: boolean;
  43412. /**
  43413. * If the scale gizmo is enabled
  43414. */
  43415. scaleGizmoEnabled: boolean;
  43416. /**
  43417. * If the boundingBox gizmo is enabled
  43418. */
  43419. boundingBoxGizmoEnabled: boolean;
  43420. /**
  43421. * Disposes of the gizmo manager
  43422. */
  43423. dispose(): void;
  43424. }
  43425. }
  43426. declare module "babylonjs/Gizmos/lightGizmo" {
  43427. import { Nullable } from "babylonjs/types";
  43428. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43429. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43430. import { Light } from "babylonjs/Lights/light";
  43431. /**
  43432. * Gizmo that enables viewing a light
  43433. */
  43434. export class LightGizmo extends Gizmo {
  43435. private _box;
  43436. /**
  43437. * Creates a LightGizmo
  43438. * @param gizmoLayer The utility layer the gizmo will be added to
  43439. */
  43440. constructor(gizmoLayer?: UtilityLayerRenderer);
  43441. private _light;
  43442. /**
  43443. * The light that the gizmo is attached to
  43444. */
  43445. light: Nullable<Light>;
  43446. /**
  43447. * @hidden
  43448. * Updates the gizmo to match the attached mesh's position/rotation
  43449. */
  43450. protected _update(): void;
  43451. }
  43452. }
  43453. declare module "babylonjs/Gizmos/index" {
  43454. export * from "babylonjs/Gizmos/axisDragGizmo";
  43455. export * from "babylonjs/Gizmos/axisScaleGizmo";
  43456. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  43457. export * from "babylonjs/Gizmos/gizmo";
  43458. export * from "babylonjs/Gizmos/gizmoManager";
  43459. export * from "babylonjs/Gizmos/planeRotationGizmo";
  43460. export * from "babylonjs/Gizmos/positionGizmo";
  43461. export * from "babylonjs/Gizmos/rotationGizmo";
  43462. export * from "babylonjs/Gizmos/scaleGizmo";
  43463. export * from "babylonjs/Gizmos/lightGizmo";
  43464. }
  43465. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  43466. /** @hidden */
  43467. export var backgroundFragmentDeclaration: {
  43468. name: string;
  43469. shader: string;
  43470. };
  43471. }
  43472. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  43473. /** @hidden */
  43474. export var backgroundUboDeclaration: {
  43475. name: string;
  43476. shader: string;
  43477. };
  43478. }
  43479. declare module "babylonjs/Shaders/background.fragment" {
  43480. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  43481. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  43482. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  43483. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  43484. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  43485. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  43486. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  43487. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  43488. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  43489. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  43490. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  43491. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  43492. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  43493. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  43494. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  43495. /** @hidden */
  43496. export var backgroundPixelShader: {
  43497. name: string;
  43498. shader: string;
  43499. };
  43500. }
  43501. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  43502. /** @hidden */
  43503. export var backgroundVertexDeclaration: {
  43504. name: string;
  43505. shader: string;
  43506. };
  43507. }
  43508. declare module "babylonjs/Shaders/background.vertex" {
  43509. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  43510. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  43511. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  43512. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  43513. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  43514. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  43515. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  43516. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  43517. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  43518. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  43519. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  43520. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  43521. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  43522. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  43523. /** @hidden */
  43524. export var backgroundVertexShader: {
  43525. name: string;
  43526. shader: string;
  43527. };
  43528. }
  43529. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  43530. import { Nullable, int, float } from "babylonjs/types";
  43531. import { Scene } from "babylonjs/scene";
  43532. import { Matrix, Vector3, Color3 } from "babylonjs/Maths/math";
  43533. import { SubMesh } from "babylonjs/Meshes/subMesh";
  43534. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43535. import { Mesh } from "babylonjs/Meshes/mesh";
  43536. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  43537. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  43538. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  43539. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  43540. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  43541. import "babylonjs/Shaders/background.fragment";
  43542. import "babylonjs/Shaders/background.vertex";
  43543. /**
  43544. * Background material used to create an efficient environement around your scene.
  43545. */
  43546. export class BackgroundMaterial extends PushMaterial {
  43547. /**
  43548. * Standard reflectance value at parallel view angle.
  43549. */
  43550. static StandardReflectance0: number;
  43551. /**
  43552. * Standard reflectance value at grazing angle.
  43553. */
  43554. static StandardReflectance90: number;
  43555. protected _primaryColor: Color3;
  43556. /**
  43557. * Key light Color (multiply against the environement texture)
  43558. */
  43559. primaryColor: Color3;
  43560. protected __perceptualColor: Nullable<Color3>;
  43561. /**
  43562. * Experimental Internal Use Only.
  43563. *
  43564. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  43565. * This acts as a helper to set the primary color to a more "human friendly" value.
  43566. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  43567. * output color as close as possible from the chosen value.
  43568. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  43569. * part of lighting setup.)
  43570. */
  43571. _perceptualColor: Nullable<Color3>;
  43572. protected _primaryColorShadowLevel: float;
  43573. /**
  43574. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  43575. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  43576. */
  43577. primaryColorShadowLevel: float;
  43578. protected _primaryColorHighlightLevel: float;
  43579. /**
  43580. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  43581. * The primary color is used at the level chosen to define what the white area would look.
  43582. */
  43583. primaryColorHighlightLevel: float;
  43584. protected _reflectionTexture: Nullable<BaseTexture>;
  43585. /**
  43586. * Reflection Texture used in the material.
  43587. * Should be author in a specific way for the best result (refer to the documentation).
  43588. */
  43589. reflectionTexture: Nullable<BaseTexture>;
  43590. protected _reflectionBlur: float;
  43591. /**
  43592. * Reflection Texture level of blur.
  43593. *
  43594. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  43595. * texture twice.
  43596. */
  43597. reflectionBlur: float;
  43598. protected _diffuseTexture: Nullable<BaseTexture>;
  43599. /**
  43600. * Diffuse Texture used in the material.
  43601. * Should be author in a specific way for the best result (refer to the documentation).
  43602. */
  43603. diffuseTexture: Nullable<BaseTexture>;
  43604. protected _shadowLights: Nullable<IShadowLight[]>;
  43605. /**
  43606. * Specify the list of lights casting shadow on the material.
  43607. * All scene shadow lights will be included if null.
  43608. */
  43609. shadowLights: Nullable<IShadowLight[]>;
  43610. protected _shadowLevel: float;
  43611. /**
  43612. * Helps adjusting the shadow to a softer level if required.
  43613. * 0 means black shadows and 1 means no shadows.
  43614. */
  43615. shadowLevel: float;
  43616. protected _sceneCenter: Vector3;
  43617. /**
  43618. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  43619. * It is usually zero but might be interesting to modify according to your setup.
  43620. */
  43621. sceneCenter: Vector3;
  43622. protected _opacityFresnel: boolean;
  43623. /**
  43624. * This helps specifying that the material is falling off to the sky box at grazing angle.
  43625. * This helps ensuring a nice transition when the camera goes under the ground.
  43626. */
  43627. opacityFresnel: boolean;
  43628. protected _reflectionFresnel: boolean;
  43629. /**
  43630. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  43631. * This helps adding a mirror texture on the ground.
  43632. */
  43633. reflectionFresnel: boolean;
  43634. protected _reflectionFalloffDistance: number;
  43635. /**
  43636. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  43637. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  43638. */
  43639. reflectionFalloffDistance: number;
  43640. protected _reflectionAmount: number;
  43641. /**
  43642. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  43643. */
  43644. reflectionAmount: number;
  43645. protected _reflectionReflectance0: number;
  43646. /**
  43647. * This specifies the weight of the reflection at grazing angle.
  43648. */
  43649. reflectionReflectance0: number;
  43650. protected _reflectionReflectance90: number;
  43651. /**
  43652. * This specifies the weight of the reflection at a perpendicular point of view.
  43653. */
  43654. reflectionReflectance90: number;
  43655. /**
  43656. * Sets the reflection reflectance fresnel values according to the default standard
  43657. * empirically know to work well :-)
  43658. */
  43659. reflectionStandardFresnelWeight: number;
  43660. protected _useRGBColor: boolean;
  43661. /**
  43662. * Helps to directly use the maps channels instead of their level.
  43663. */
  43664. useRGBColor: boolean;
  43665. protected _enableNoise: boolean;
  43666. /**
  43667. * This helps reducing the banding effect that could occur on the background.
  43668. */
  43669. enableNoise: boolean;
  43670. /**
  43671. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  43672. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  43673. * Recommended to be keep at 1.0 except for special cases.
  43674. */
  43675. fovMultiplier: number;
  43676. private _fovMultiplier;
  43677. /**
  43678. * Enable the FOV adjustment feature controlled by fovMultiplier.
  43679. */
  43680. useEquirectangularFOV: boolean;
  43681. private _maxSimultaneousLights;
  43682. /**
  43683. * Number of Simultaneous lights allowed on the material.
  43684. */
  43685. maxSimultaneousLights: int;
  43686. /**
  43687. * Default configuration related to image processing available in the Background Material.
  43688. */
  43689. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  43690. /**
  43691. * Keep track of the image processing observer to allow dispose and replace.
  43692. */
  43693. private _imageProcessingObserver;
  43694. /**
  43695. * Attaches a new image processing configuration to the PBR Material.
  43696. * @param configuration (if null the scene configuration will be use)
  43697. */
  43698. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  43699. /**
  43700. * Gets the image processing configuration used either in this material.
  43701. */
  43702. /**
  43703. * Sets the Default image processing configuration used either in the this material.
  43704. *
  43705. * If sets to null, the scene one is in use.
  43706. */
  43707. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  43708. /**
  43709. * Gets wether the color curves effect is enabled.
  43710. */
  43711. /**
  43712. * Sets wether the color curves effect is enabled.
  43713. */
  43714. cameraColorCurvesEnabled: boolean;
  43715. /**
  43716. * Gets wether the color grading effect is enabled.
  43717. */
  43718. /**
  43719. * Gets wether the color grading effect is enabled.
  43720. */
  43721. cameraColorGradingEnabled: boolean;
  43722. /**
  43723. * Gets wether tonemapping is enabled or not.
  43724. */
  43725. /**
  43726. * Sets wether tonemapping is enabled or not
  43727. */
  43728. cameraToneMappingEnabled: boolean;
  43729. /**
  43730. * The camera exposure used on this material.
  43731. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  43732. * This corresponds to a photographic exposure.
  43733. */
  43734. /**
  43735. * The camera exposure used on this material.
  43736. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  43737. * This corresponds to a photographic exposure.
  43738. */
  43739. cameraExposure: float;
  43740. /**
  43741. * Gets The camera contrast used on this material.
  43742. */
  43743. /**
  43744. * Sets The camera contrast used on this material.
  43745. */
  43746. cameraContrast: float;
  43747. /**
  43748. * Gets the Color Grading 2D Lookup Texture.
  43749. */
  43750. /**
  43751. * Sets the Color Grading 2D Lookup Texture.
  43752. */
  43753. cameraColorGradingTexture: Nullable<BaseTexture>;
  43754. /**
  43755. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  43756. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  43757. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  43758. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  43759. */
  43760. /**
  43761. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  43762. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  43763. * 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;
  43764. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  43765. */
  43766. cameraColorCurves: Nullable<ColorCurves>;
  43767. /**
  43768. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  43769. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  43770. */
  43771. switchToBGR: boolean;
  43772. private _renderTargets;
  43773. private _reflectionControls;
  43774. private _white;
  43775. private _primaryShadowColor;
  43776. private _primaryHighlightColor;
  43777. /**
  43778. * Instantiates a Background Material in the given scene
  43779. * @param name The friendly name of the material
  43780. * @param scene The scene to add the material to
  43781. */
  43782. constructor(name: string, scene: Scene);
  43783. /**
  43784. * Gets a boolean indicating that current material needs to register RTT
  43785. */
  43786. readonly hasRenderTargetTextures: boolean;
  43787. /**
  43788. * The entire material has been created in order to prevent overdraw.
  43789. * @returns false
  43790. */
  43791. needAlphaTesting(): boolean;
  43792. /**
  43793. * The entire material has been created in order to prevent overdraw.
  43794. * @returns true if blending is enable
  43795. */
  43796. needAlphaBlending(): boolean;
  43797. /**
  43798. * Checks wether the material is ready to be rendered for a given mesh.
  43799. * @param mesh The mesh to render
  43800. * @param subMesh The submesh to check against
  43801. * @param useInstances Specify wether or not the material is used with instances
  43802. * @returns true if all the dependencies are ready (Textures, Effects...)
  43803. */
  43804. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  43805. /**
  43806. * Compute the primary color according to the chosen perceptual color.
  43807. */
  43808. private _computePrimaryColorFromPerceptualColor;
  43809. /**
  43810. * Compute the highlights and shadow colors according to their chosen levels.
  43811. */
  43812. private _computePrimaryColors;
  43813. /**
  43814. * Build the uniform buffer used in the material.
  43815. */
  43816. buildUniformLayout(): void;
  43817. /**
  43818. * Unbind the material.
  43819. */
  43820. unbind(): void;
  43821. /**
  43822. * Bind only the world matrix to the material.
  43823. * @param world The world matrix to bind.
  43824. */
  43825. bindOnlyWorldMatrix(world: Matrix): void;
  43826. /**
  43827. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  43828. * @param world The world matrix to bind.
  43829. * @param subMesh The submesh to bind for.
  43830. */
  43831. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  43832. /**
  43833. * Dispose the material.
  43834. * @param forceDisposeEffect Force disposal of the associated effect.
  43835. * @param forceDisposeTextures Force disposal of the associated textures.
  43836. */
  43837. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  43838. /**
  43839. * Clones the material.
  43840. * @param name The cloned name.
  43841. * @returns The cloned material.
  43842. */
  43843. clone(name: string): BackgroundMaterial;
  43844. /**
  43845. * Serializes the current material to its JSON representation.
  43846. * @returns The JSON representation.
  43847. */
  43848. serialize(): any;
  43849. /**
  43850. * Gets the class name of the material
  43851. * @returns "BackgroundMaterial"
  43852. */
  43853. getClassName(): string;
  43854. /**
  43855. * Parse a JSON input to create back a background material.
  43856. * @param source The JSON data to parse
  43857. * @param scene The scene to create the parsed material in
  43858. * @param rootUrl The root url of the assets the material depends upon
  43859. * @returns the instantiated BackgroundMaterial.
  43860. */
  43861. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  43862. }
  43863. }
  43864. declare module "babylonjs/Helpers/environmentHelper" {
  43865. import { Observable } from "babylonjs/Misc/observable";
  43866. import { Nullable } from "babylonjs/types";
  43867. import { Scene } from "babylonjs/scene";
  43868. import { Vector3, Color3 } from "babylonjs/Maths/math";
  43869. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43870. import { Mesh } from "babylonjs/Meshes/mesh";
  43871. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  43872. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  43873. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  43874. import "babylonjs/Meshes/Builders/planeBuilder";
  43875. import "babylonjs/Meshes/Builders/boxBuilder";
  43876. /**
  43877. * Represents the different options available during the creation of
  43878. * a Environment helper.
  43879. *
  43880. * This can control the default ground, skybox and image processing setup of your scene.
  43881. */
  43882. export interface IEnvironmentHelperOptions {
  43883. /**
  43884. * Specifies wether or not to create a ground.
  43885. * True by default.
  43886. */
  43887. createGround: boolean;
  43888. /**
  43889. * Specifies the ground size.
  43890. * 15 by default.
  43891. */
  43892. groundSize: number;
  43893. /**
  43894. * The texture used on the ground for the main color.
  43895. * Comes from the BabylonJS CDN by default.
  43896. *
  43897. * Remarks: Can be either a texture or a url.
  43898. */
  43899. groundTexture: string | BaseTexture;
  43900. /**
  43901. * The color mixed in the ground texture by default.
  43902. * BabylonJS clearColor by default.
  43903. */
  43904. groundColor: Color3;
  43905. /**
  43906. * Specifies the ground opacity.
  43907. * 1 by default.
  43908. */
  43909. groundOpacity: number;
  43910. /**
  43911. * Enables the ground to receive shadows.
  43912. * True by default.
  43913. */
  43914. enableGroundShadow: boolean;
  43915. /**
  43916. * Helps preventing the shadow to be fully black on the ground.
  43917. * 0.5 by default.
  43918. */
  43919. groundShadowLevel: number;
  43920. /**
  43921. * Creates a mirror texture attach to the ground.
  43922. * false by default.
  43923. */
  43924. enableGroundMirror: boolean;
  43925. /**
  43926. * Specifies the ground mirror size ratio.
  43927. * 0.3 by default as the default kernel is 64.
  43928. */
  43929. groundMirrorSizeRatio: number;
  43930. /**
  43931. * Specifies the ground mirror blur kernel size.
  43932. * 64 by default.
  43933. */
  43934. groundMirrorBlurKernel: number;
  43935. /**
  43936. * Specifies the ground mirror visibility amount.
  43937. * 1 by default
  43938. */
  43939. groundMirrorAmount: number;
  43940. /**
  43941. * Specifies the ground mirror reflectance weight.
  43942. * This uses the standard weight of the background material to setup the fresnel effect
  43943. * of the mirror.
  43944. * 1 by default.
  43945. */
  43946. groundMirrorFresnelWeight: number;
  43947. /**
  43948. * Specifies the ground mirror Falloff distance.
  43949. * This can helps reducing the size of the reflection.
  43950. * 0 by Default.
  43951. */
  43952. groundMirrorFallOffDistance: number;
  43953. /**
  43954. * Specifies the ground mirror texture type.
  43955. * Unsigned Int by Default.
  43956. */
  43957. groundMirrorTextureType: number;
  43958. /**
  43959. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  43960. * the shown objects.
  43961. */
  43962. groundYBias: number;
  43963. /**
  43964. * Specifies wether or not to create a skybox.
  43965. * True by default.
  43966. */
  43967. createSkybox: boolean;
  43968. /**
  43969. * Specifies the skybox size.
  43970. * 20 by default.
  43971. */
  43972. skyboxSize: number;
  43973. /**
  43974. * The texture used on the skybox for the main color.
  43975. * Comes from the BabylonJS CDN by default.
  43976. *
  43977. * Remarks: Can be either a texture or a url.
  43978. */
  43979. skyboxTexture: string | BaseTexture;
  43980. /**
  43981. * The color mixed in the skybox texture by default.
  43982. * BabylonJS clearColor by default.
  43983. */
  43984. skyboxColor: Color3;
  43985. /**
  43986. * The background rotation around the Y axis of the scene.
  43987. * This helps aligning the key lights of your scene with the background.
  43988. * 0 by default.
  43989. */
  43990. backgroundYRotation: number;
  43991. /**
  43992. * Compute automatically the size of the elements to best fit with the scene.
  43993. */
  43994. sizeAuto: boolean;
  43995. /**
  43996. * Default position of the rootMesh if autoSize is not true.
  43997. */
  43998. rootPosition: Vector3;
  43999. /**
  44000. * Sets up the image processing in the scene.
  44001. * true by default.
  44002. */
  44003. setupImageProcessing: boolean;
  44004. /**
  44005. * The texture used as your environment texture in the scene.
  44006. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  44007. *
  44008. * Remarks: Can be either a texture or a url.
  44009. */
  44010. environmentTexture: string | BaseTexture;
  44011. /**
  44012. * The value of the exposure to apply to the scene.
  44013. * 0.6 by default if setupImageProcessing is true.
  44014. */
  44015. cameraExposure: number;
  44016. /**
  44017. * The value of the contrast to apply to the scene.
  44018. * 1.6 by default if setupImageProcessing is true.
  44019. */
  44020. cameraContrast: number;
  44021. /**
  44022. * Specifies wether or not tonemapping should be enabled in the scene.
  44023. * true by default if setupImageProcessing is true.
  44024. */
  44025. toneMappingEnabled: boolean;
  44026. }
  44027. /**
  44028. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  44029. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  44030. * It also helps with the default setup of your imageProcessing configuration.
  44031. */
  44032. export class EnvironmentHelper {
  44033. /**
  44034. * Default ground texture URL.
  44035. */
  44036. private static _groundTextureCDNUrl;
  44037. /**
  44038. * Default skybox texture URL.
  44039. */
  44040. private static _skyboxTextureCDNUrl;
  44041. /**
  44042. * Default environment texture URL.
  44043. */
  44044. private static _environmentTextureCDNUrl;
  44045. /**
  44046. * Creates the default options for the helper.
  44047. */
  44048. private static _getDefaultOptions;
  44049. private _rootMesh;
  44050. /**
  44051. * Gets the root mesh created by the helper.
  44052. */
  44053. readonly rootMesh: Mesh;
  44054. private _skybox;
  44055. /**
  44056. * Gets the skybox created by the helper.
  44057. */
  44058. readonly skybox: Nullable<Mesh>;
  44059. private _skyboxTexture;
  44060. /**
  44061. * Gets the skybox texture created by the helper.
  44062. */
  44063. readonly skyboxTexture: Nullable<BaseTexture>;
  44064. private _skyboxMaterial;
  44065. /**
  44066. * Gets the skybox material created by the helper.
  44067. */
  44068. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  44069. private _ground;
  44070. /**
  44071. * Gets the ground mesh created by the helper.
  44072. */
  44073. readonly ground: Nullable<Mesh>;
  44074. private _groundTexture;
  44075. /**
  44076. * Gets the ground texture created by the helper.
  44077. */
  44078. readonly groundTexture: Nullable<BaseTexture>;
  44079. private _groundMirror;
  44080. /**
  44081. * Gets the ground mirror created by the helper.
  44082. */
  44083. readonly groundMirror: Nullable<MirrorTexture>;
  44084. /**
  44085. * Gets the ground mirror render list to helps pushing the meshes
  44086. * you wish in the ground reflection.
  44087. */
  44088. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  44089. private _groundMaterial;
  44090. /**
  44091. * Gets the ground material created by the helper.
  44092. */
  44093. readonly groundMaterial: Nullable<BackgroundMaterial>;
  44094. /**
  44095. * Stores the creation options.
  44096. */
  44097. private readonly _scene;
  44098. private _options;
  44099. /**
  44100. * This observable will be notified with any error during the creation of the environment,
  44101. * mainly texture creation errors.
  44102. */
  44103. onErrorObservable: Observable<{
  44104. message?: string;
  44105. exception?: any;
  44106. }>;
  44107. /**
  44108. * constructor
  44109. * @param options Defines the options we want to customize the helper
  44110. * @param scene The scene to add the material to
  44111. */
  44112. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  44113. /**
  44114. * Updates the background according to the new options
  44115. * @param options
  44116. */
  44117. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  44118. /**
  44119. * Sets the primary color of all the available elements.
  44120. * @param color the main color to affect to the ground and the background
  44121. */
  44122. setMainColor(color: Color3): void;
  44123. /**
  44124. * Setup the image processing according to the specified options.
  44125. */
  44126. private _setupImageProcessing;
  44127. /**
  44128. * Setup the environment texture according to the specified options.
  44129. */
  44130. private _setupEnvironmentTexture;
  44131. /**
  44132. * Setup the background according to the specified options.
  44133. */
  44134. private _setupBackground;
  44135. /**
  44136. * Get the scene sizes according to the setup.
  44137. */
  44138. private _getSceneSize;
  44139. /**
  44140. * Setup the ground according to the specified options.
  44141. */
  44142. private _setupGround;
  44143. /**
  44144. * Setup the ground material according to the specified options.
  44145. */
  44146. private _setupGroundMaterial;
  44147. /**
  44148. * Setup the ground diffuse texture according to the specified options.
  44149. */
  44150. private _setupGroundDiffuseTexture;
  44151. /**
  44152. * Setup the ground mirror texture according to the specified options.
  44153. */
  44154. private _setupGroundMirrorTexture;
  44155. /**
  44156. * Setup the ground to receive the mirror texture.
  44157. */
  44158. private _setupMirrorInGroundMaterial;
  44159. /**
  44160. * Setup the skybox according to the specified options.
  44161. */
  44162. private _setupSkybox;
  44163. /**
  44164. * Setup the skybox material according to the specified options.
  44165. */
  44166. private _setupSkyboxMaterial;
  44167. /**
  44168. * Setup the skybox reflection texture according to the specified options.
  44169. */
  44170. private _setupSkyboxReflectionTexture;
  44171. private _errorHandler;
  44172. /**
  44173. * Dispose all the elements created by the Helper.
  44174. */
  44175. dispose(): void;
  44176. }
  44177. }
  44178. declare module "babylonjs/Helpers/photoDome" {
  44179. import { Observable } from "babylonjs/Misc/observable";
  44180. import { Nullable } from "babylonjs/types";
  44181. import { Scene } from "babylonjs/scene";
  44182. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44183. import { Mesh } from "babylonjs/Meshes/mesh";
  44184. import { Texture } from "babylonjs/Materials/Textures/texture";
  44185. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  44186. import "babylonjs/Meshes/Builders/sphereBuilder";
  44187. /**
  44188. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  44189. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  44190. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  44191. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  44192. */
  44193. export class PhotoDome extends TransformNode {
  44194. private _useDirectMapping;
  44195. /**
  44196. * The texture being displayed on the sphere
  44197. */
  44198. protected _photoTexture: Texture;
  44199. /**
  44200. * Gets or sets the texture being displayed on the sphere
  44201. */
  44202. photoTexture: Texture;
  44203. /**
  44204. * Observable raised when an error occured while loading the 360 image
  44205. */
  44206. onLoadErrorObservable: Observable<string>;
  44207. /**
  44208. * The skybox material
  44209. */
  44210. protected _material: BackgroundMaterial;
  44211. /**
  44212. * The surface used for the skybox
  44213. */
  44214. protected _mesh: Mesh;
  44215. /**
  44216. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  44217. * Also see the options.resolution property.
  44218. */
  44219. fovMultiplier: number;
  44220. /**
  44221. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  44222. * @param name Element's name, child elements will append suffixes for their own names.
  44223. * @param urlsOfPhoto defines the url of the photo to display
  44224. * @param options defines an object containing optional or exposed sub element properties
  44225. * @param onError defines a callback called when an error occured while loading the texture
  44226. */
  44227. constructor(name: string, urlOfPhoto: string, options: {
  44228. resolution?: number;
  44229. size?: number;
  44230. useDirectMapping?: boolean;
  44231. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  44232. /**
  44233. * Releases resources associated with this node.
  44234. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  44235. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  44236. */
  44237. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  44238. }
  44239. }
  44240. declare module "babylonjs/Misc/textureTools" {
  44241. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44242. import { Texture } from "babylonjs/Materials/Textures/texture";
  44243. import { Scene } from "babylonjs/scene";
  44244. /**
  44245. * Class used to host texture specific utilities
  44246. */
  44247. export class TextureTools {
  44248. /**
  44249. * Uses the GPU to create a copy texture rescaled at a given size
  44250. * @param texture Texture to copy from
  44251. * @param width defines the desired width
  44252. * @param height defines the desired height
  44253. * @param useBilinearMode defines if bilinear mode has to be used
  44254. * @return the generated texture
  44255. */
  44256. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  44257. /**
  44258. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  44259. * @param scene defines the hosting scene
  44260. * @returns the environment BRDF texture
  44261. */
  44262. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  44263. private static _environmentBRDFBase64Texture;
  44264. }
  44265. }
  44266. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  44267. import { Nullable } from "babylonjs/types";
  44268. import { IAnimatable } from "babylonjs/Misc/tools";
  44269. import { Color3 } from "babylonjs/Maths/math";
  44270. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44271. import { EffectFallbacks } from "babylonjs/Materials/effect";
  44272. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  44273. import { Engine } from "babylonjs/Engines/engine";
  44274. import { Scene } from "babylonjs/scene";
  44275. /**
  44276. * @hidden
  44277. */
  44278. export interface IMaterialClearCoatDefines {
  44279. CLEARCOAT: boolean;
  44280. CLEARCOAT_DEFAULTIOR: boolean;
  44281. CLEARCOAT_TEXTURE: boolean;
  44282. CLEARCOAT_TEXTUREDIRECTUV: number;
  44283. CLEARCOAT_BUMP: boolean;
  44284. CLEARCOAT_BUMPDIRECTUV: number;
  44285. CLEARCOAT_TINT: boolean;
  44286. CLEARCOAT_TINT_TEXTURE: boolean;
  44287. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  44288. /** @hidden */
  44289. _areTexturesDirty: boolean;
  44290. }
  44291. /**
  44292. * Define the code related to the clear coat parameters of the pbr material.
  44293. */
  44294. export class PBRClearCoatConfiguration {
  44295. /**
  44296. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  44297. * The default fits with a polyurethane material.
  44298. */
  44299. private static readonly _DefaultIndiceOfRefraction;
  44300. private _isEnabled;
  44301. /**
  44302. * Defines if the clear coat is enabled in the material.
  44303. */
  44304. isEnabled: boolean;
  44305. /**
  44306. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  44307. */
  44308. intensity: number;
  44309. /**
  44310. * Defines the clear coat layer roughness.
  44311. */
  44312. roughness: number;
  44313. private _indiceOfRefraction;
  44314. /**
  44315. * Defines the indice of refraction of the clear coat.
  44316. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  44317. * The default fits with a polyurethane material.
  44318. * Changing the default value is more performance intensive.
  44319. */
  44320. indiceOfRefraction: number;
  44321. private _texture;
  44322. /**
  44323. * Stores the clear coat values in a texture.
  44324. */
  44325. texture: Nullable<BaseTexture>;
  44326. private _bumpTexture;
  44327. /**
  44328. * Define the clear coat specific bump texture.
  44329. */
  44330. bumpTexture: Nullable<BaseTexture>;
  44331. private _isTintEnabled;
  44332. /**
  44333. * Defines if the clear coat tint is enabled in the material.
  44334. */
  44335. isTintEnabled: boolean;
  44336. /**
  44337. * Defines if the clear coat tint is enabled in the material.
  44338. * This is only use if tint is enabled
  44339. */
  44340. tintColor: Color3;
  44341. /**
  44342. * Defines if the distance at which the tint color should be found in the
  44343. * clear coat media.
  44344. * This is only use if tint is enabled
  44345. */
  44346. tintColorAtDistance: number;
  44347. /**
  44348. * Defines the clear coat layer thickness.
  44349. * This is only use if tint is enabled
  44350. */
  44351. tintThickness: number;
  44352. private _tintTexture;
  44353. /**
  44354. * Stores the clear tint values in a texture.
  44355. * rgb is tint
  44356. * a is a thickness factor
  44357. */
  44358. tintTexture: Nullable<BaseTexture>;
  44359. /** @hidden */
  44360. private _internalMarkAllSubMeshesAsTexturesDirty;
  44361. /** @hidden */
  44362. _markAllSubMeshesAsTexturesDirty(): void;
  44363. /**
  44364. * Instantiate a new istance of clear coat configuration.
  44365. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  44366. */
  44367. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  44368. /**
  44369. * Specifies that the submesh is ready to be used.
  44370. * @param defines the list of "defines" to update.
  44371. * @param scene defines the scene the material belongs to.
  44372. * @param engine defines the engine the material belongs to.
  44373. * @param disableBumpMap defines wether the material disables bump or not.
  44374. * @returns - boolean indicating that the submesh is ready or not.
  44375. */
  44376. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  44377. /**
  44378. * Checks to see if a texture is used in the material.
  44379. * @param defines the list of "defines" to update.
  44380. * @param scene defines the scene to the material belongs to.
  44381. */
  44382. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  44383. /**
  44384. * Binds the material data.
  44385. * @param uniformBuffer defines the Uniform buffer to fill in.
  44386. * @param scene defines the scene the material belongs to.
  44387. * @param engine defines the engine the material belongs to.
  44388. * @param disableBumpMap defines wether the material disables bump or not.
  44389. * @param isFrozen defines wether the material is frozen or not.
  44390. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  44391. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  44392. */
  44393. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  44394. /**
  44395. * Checks to see if a texture is used in the material.
  44396. * @param texture - Base texture to use.
  44397. * @returns - Boolean specifying if a texture is used in the material.
  44398. */
  44399. hasTexture(texture: BaseTexture): boolean;
  44400. /**
  44401. * Returns an array of the actively used textures.
  44402. * @param activeTextures Array of BaseTextures
  44403. */
  44404. getActiveTextures(activeTextures: BaseTexture[]): void;
  44405. /**
  44406. * Returns the animatable textures.
  44407. * @param animatables Array of animatable textures.
  44408. */
  44409. getAnimatables(animatables: IAnimatable[]): void;
  44410. /**
  44411. * Disposes the resources of the material.
  44412. * @param forceDisposeTextures - Forces the disposal of all textures.
  44413. */
  44414. dispose(forceDisposeTextures?: boolean): void;
  44415. /**
  44416. * Get the current class name of the texture useful for serialization or dynamic coding.
  44417. * @returns "PBRClearCoatConfiguration"
  44418. */
  44419. getClassName(): string;
  44420. /**
  44421. * Makes a duplicate of the current configuration into another one.
  44422. * @param clearCoatConfiguration define the config where to copy the info
  44423. */
  44424. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  44425. /**
  44426. * Serializes this clear coat configuration.
  44427. * @returns - An object with the serialized config.
  44428. */
  44429. serialize(): any;
  44430. /**
  44431. * Parses a Clear Coat Configuration from a serialized object.
  44432. * @param source - Serialized object.
  44433. */
  44434. parse(source: any): void;
  44435. /**
  44436. * Add fallbacks to the effect fallbacks list.
  44437. * @param defines defines the Base texture to use.
  44438. * @param fallbacks defines the current fallback list.
  44439. * @param currentRank defines the current fallback rank.
  44440. * @returns the new fallback rank.
  44441. */
  44442. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  44443. /**
  44444. * Add the required uniforms to the current list.
  44445. * @param uniforms defines the current uniform list.
  44446. */
  44447. static AddUniforms(uniforms: string[]): void;
  44448. /**
  44449. * Add the required samplers to the current list.
  44450. * @param samplers defines the current sampler list.
  44451. */
  44452. static AddSamplers(samplers: string[]): void;
  44453. /**
  44454. * Add the required uniforms to the current buffer.
  44455. * @param uniformBuffer defines the current uniform buffer.
  44456. */
  44457. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  44458. }
  44459. }
  44460. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  44461. import { EffectFallbacks } from "babylonjs/Materials/effect";
  44462. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  44463. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44464. /**
  44465. * @hidden
  44466. */
  44467. export interface IMaterialAnisotropicDefines {
  44468. ANISOTROPIC: boolean;
  44469. MAINUV1: boolean;
  44470. _areMiscDirty: boolean;
  44471. _needUVs: boolean;
  44472. }
  44473. /**
  44474. * Define the code related to the anisotropic parameters of the pbr material.
  44475. */
  44476. export class PBRAnisotropicConfiguration {
  44477. private _isEnabled;
  44478. /**
  44479. * Defines if the anisotropy is enabled in the material.
  44480. */
  44481. isEnabled: boolean;
  44482. /**
  44483. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  44484. */
  44485. intensity: number;
  44486. /**
  44487. * Defines if the effect is along the tangents or bitangents.
  44488. * By default, the effect is "strectching" the highlights along the tangents.
  44489. */
  44490. followTangents: boolean;
  44491. /** @hidden */
  44492. private _internalMarkAllSubMeshesAsMiscDirty;
  44493. /** @hidden */
  44494. _markAllSubMeshesAsMiscDirty(): void;
  44495. /**
  44496. * Instantiate a new istance of clear coat configuration.
  44497. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  44498. */
  44499. constructor(markAllSubMeshesAsMiscDirty: () => void);
  44500. /**
  44501. * Checks to see if a texture is used in the material.
  44502. * @param defines the list of "defines" to update.
  44503. * @param mesh the mesh we are preparing the defines for.
  44504. */
  44505. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh): void;
  44506. /**
  44507. * Binds the material data.
  44508. * @param uniformBuffer defines the Uniform buffer to fill in.
  44509. * @param isFrozen defines wether the material is frozen or not.
  44510. */
  44511. bindForSubMesh(uniformBuffer: UniformBuffer, isFrozen: boolean): void;
  44512. /**
  44513. * Get the current class name of the texture useful for serialization or dynamic coding.
  44514. * @returns "PBRAnisotropicConfiguration"
  44515. */
  44516. getClassName(): string;
  44517. /**
  44518. * Makes a duplicate of the current configuration into another one.
  44519. * @param anisotropicConfiguration define the config where to copy the info
  44520. */
  44521. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  44522. /**
  44523. * Serializes this clear coat configuration.
  44524. * @returns - An object with the serialized config.
  44525. */
  44526. serialize(): any;
  44527. /**
  44528. * Parses a Clear Coat Configuration from a serialized object.
  44529. * @param source - Serialized object.
  44530. */
  44531. parse(source: any): void;
  44532. /**
  44533. * Add fallbacks to the effect fallbacks list.
  44534. * @param defines defines the Base texture to use.
  44535. * @param fallbacks defines the current fallback list.
  44536. * @param currentRank defines the current fallback rank.
  44537. * @returns the new fallback rank.
  44538. */
  44539. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  44540. /**
  44541. * Add the required uniforms to the current list.
  44542. * @param uniforms defines the current uniform list.
  44543. */
  44544. static AddUniforms(uniforms: string[]): void;
  44545. /**
  44546. * Add the required uniforms to the current buffer.
  44547. * @param uniformBuffer defines the current uniform buffer.
  44548. */
  44549. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  44550. }
  44551. }
  44552. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  44553. /**
  44554. * @hidden
  44555. */
  44556. export interface IMaterialBRDFDefines {
  44557. BRDF_V_HEIGHT_CORRELATED: boolean;
  44558. MS_BRDF_ENERGY_CONSERVATION: boolean;
  44559. /** @hidden */
  44560. _areMiscDirty: boolean;
  44561. }
  44562. /**
  44563. * Define the code related to the BRDF parameters of the pbr material.
  44564. */
  44565. export class PBRBRDFConfiguration {
  44566. private _useEnergyConservation;
  44567. /**
  44568. * Defines if the material uses energy conservation.
  44569. */
  44570. useEnergyConservation: boolean;
  44571. private _useSmithVisibilityHeightCorrelated;
  44572. /**
  44573. * LEGACY Mode set to false
  44574. * Defines if the material uses height smith correlated visibility term.
  44575. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  44576. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  44577. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  44578. * Not relying on height correlated will also disable energy conservation.
  44579. */
  44580. useSmithVisibilityHeightCorrelated: boolean;
  44581. /** @hidden */
  44582. private _internalMarkAllSubMeshesAsMiscDirty;
  44583. /** @hidden */
  44584. _markAllSubMeshesAsMiscDirty(): void;
  44585. /**
  44586. * Instantiate a new istance of clear coat configuration.
  44587. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  44588. */
  44589. constructor(markAllSubMeshesAsMiscDirty: () => void);
  44590. /**
  44591. * Checks to see if a texture is used in the material.
  44592. * @param defines the list of "defines" to update.
  44593. */
  44594. prepareDefines(defines: IMaterialBRDFDefines): void;
  44595. /**
  44596. * Get the current class name of the texture useful for serialization or dynamic coding.
  44597. * @returns "PBRClearCoatConfiguration"
  44598. */
  44599. getClassName(): string;
  44600. /**
  44601. * Makes a duplicate of the current configuration into another one.
  44602. * @param brdfConfiguration define the config where to copy the info
  44603. */
  44604. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  44605. /**
  44606. * Serializes this BRDF configuration.
  44607. * @returns - An object with the serialized config.
  44608. */
  44609. serialize(): any;
  44610. /**
  44611. * Parses a BRDF Configuration from a serialized object.
  44612. * @param source - Serialized object.
  44613. */
  44614. parse(source: any): void;
  44615. }
  44616. }
  44617. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  44618. /** @hidden */
  44619. export var pbrFragmentDeclaration: {
  44620. name: string;
  44621. shader: string;
  44622. };
  44623. }
  44624. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  44625. /** @hidden */
  44626. export var pbrUboDeclaration: {
  44627. name: string;
  44628. shader: string;
  44629. };
  44630. }
  44631. declare module "babylonjs/Shaders/ShadersInclude/pbrFunctions" {
  44632. /** @hidden */
  44633. export var pbrFunctions: {
  44634. name: string;
  44635. shader: string;
  44636. };
  44637. }
  44638. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  44639. /** @hidden */
  44640. export var harmonicsFunctions: {
  44641. name: string;
  44642. shader: string;
  44643. };
  44644. }
  44645. declare module "babylonjs/Shaders/ShadersInclude/pbrPreLightingFunctions" {
  44646. /** @hidden */
  44647. export var pbrPreLightingFunctions: {
  44648. name: string;
  44649. shader: string;
  44650. };
  44651. }
  44652. declare module "babylonjs/Shaders/ShadersInclude/pbrFalloffLightingFunctions" {
  44653. /** @hidden */
  44654. export var pbrFalloffLightingFunctions: {
  44655. name: string;
  44656. shader: string;
  44657. };
  44658. }
  44659. declare module "babylonjs/Shaders/ShadersInclude/pbrLightingFunctions" {
  44660. /** @hidden */
  44661. export var pbrLightingFunctions: {
  44662. name: string;
  44663. shader: string;
  44664. };
  44665. }
  44666. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  44667. /** @hidden */
  44668. export var pbrDebug: {
  44669. name: string;
  44670. shader: string;
  44671. };
  44672. }
  44673. declare module "babylonjs/Shaders/pbr.fragment" {
  44674. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  44675. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  44676. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  44677. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  44678. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  44679. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  44680. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  44681. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  44682. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  44683. import "babylonjs/Shaders/ShadersInclude/pbrFunctions";
  44684. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  44685. import "babylonjs/Shaders/ShadersInclude/pbrPreLightingFunctions";
  44686. import "babylonjs/Shaders/ShadersInclude/pbrFalloffLightingFunctions";
  44687. import "babylonjs/Shaders/ShadersInclude/pbrLightingFunctions";
  44688. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  44689. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  44690. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  44691. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  44692. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  44693. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  44694. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  44695. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  44696. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  44697. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  44698. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  44699. /** @hidden */
  44700. export var pbrPixelShader: {
  44701. name: string;
  44702. shader: string;
  44703. };
  44704. }
  44705. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  44706. /** @hidden */
  44707. export var pbrVertexDeclaration: {
  44708. name: string;
  44709. shader: string;
  44710. };
  44711. }
  44712. declare module "babylonjs/Shaders/pbr.vertex" {
  44713. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  44714. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  44715. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  44716. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  44717. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  44718. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  44719. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  44720. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  44721. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  44722. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  44723. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  44724. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  44725. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  44726. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  44727. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  44728. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  44729. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  44730. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  44731. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  44732. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  44733. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  44734. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  44735. /** @hidden */
  44736. export var pbrVertexShader: {
  44737. name: string;
  44738. shader: string;
  44739. };
  44740. }
  44741. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  44742. import { IAnimatable } from "babylonjs/Misc/tools";
  44743. import { Nullable } from "babylonjs/types";
  44744. import { Scene } from "babylonjs/scene";
  44745. import { Matrix, Color3 } from "babylonjs/Maths/math";
  44746. import { SubMesh } from "babylonjs/Meshes/subMesh";
  44747. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44748. import { Mesh } from "babylonjs/Meshes/mesh";
  44749. import { PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  44750. import { PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  44751. import { PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  44752. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  44753. import { Material } from "babylonjs/Materials/material";
  44754. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  44755. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44756. import "babylonjs/Shaders/pbr.fragment";
  44757. import "babylonjs/Shaders/pbr.vertex";
  44758. /**
  44759. * The Physically based material base class of BJS.
  44760. *
  44761. * This offers the main features of a standard PBR material.
  44762. * For more information, please refer to the documentation :
  44763. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  44764. */
  44765. export abstract class PBRBaseMaterial extends PushMaterial {
  44766. /**
  44767. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  44768. */
  44769. static readonly PBRMATERIAL_OPAQUE: number;
  44770. /**
  44771. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  44772. */
  44773. static readonly PBRMATERIAL_ALPHATEST: number;
  44774. /**
  44775. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  44776. */
  44777. static readonly PBRMATERIAL_ALPHABLEND: number;
  44778. /**
  44779. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  44780. * They are also discarded below the alpha cutoff threshold to improve performances.
  44781. */
  44782. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  44783. /**
  44784. * Defines the default value of how much AO map is occluding the analytical lights
  44785. * (point spot...).
  44786. */
  44787. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  44788. /**
  44789. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  44790. */
  44791. static readonly LIGHTFALLOFF_PHYSICAL: number;
  44792. /**
  44793. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  44794. * to enhance interoperability with other engines.
  44795. */
  44796. static readonly LIGHTFALLOFF_GLTF: number;
  44797. /**
  44798. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  44799. * to enhance interoperability with other materials.
  44800. */
  44801. static readonly LIGHTFALLOFF_STANDARD: number;
  44802. /**
  44803. * Intensity of the direct lights e.g. the four lights available in your scene.
  44804. * This impacts both the direct diffuse and specular highlights.
  44805. */
  44806. protected _directIntensity: number;
  44807. /**
  44808. * Intensity of the emissive part of the material.
  44809. * This helps controlling the emissive effect without modifying the emissive color.
  44810. */
  44811. protected _emissiveIntensity: number;
  44812. /**
  44813. * Intensity of the environment e.g. how much the environment will light the object
  44814. * either through harmonics for rough material or through the refelction for shiny ones.
  44815. */
  44816. protected _environmentIntensity: number;
  44817. /**
  44818. * This is a special control allowing the reduction of the specular highlights coming from the
  44819. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  44820. */
  44821. protected _specularIntensity: number;
  44822. /**
  44823. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  44824. */
  44825. private _lightingInfos;
  44826. /**
  44827. * Debug Control allowing disabling the bump map on this material.
  44828. */
  44829. protected _disableBumpMap: boolean;
  44830. /**
  44831. * AKA Diffuse Texture in standard nomenclature.
  44832. */
  44833. protected _albedoTexture: BaseTexture;
  44834. /**
  44835. * AKA Occlusion Texture in other nomenclature.
  44836. */
  44837. protected _ambientTexture: BaseTexture;
  44838. /**
  44839. * AKA Occlusion Texture Intensity in other nomenclature.
  44840. */
  44841. protected _ambientTextureStrength: number;
  44842. /**
  44843. * Defines how much the AO map is occluding the analytical lights (point spot...).
  44844. * 1 means it completely occludes it
  44845. * 0 mean it has no impact
  44846. */
  44847. protected _ambientTextureImpactOnAnalyticalLights: number;
  44848. /**
  44849. * Stores the alpha values in a texture.
  44850. */
  44851. protected _opacityTexture: BaseTexture;
  44852. /**
  44853. * Stores the reflection values in a texture.
  44854. */
  44855. protected _reflectionTexture: BaseTexture;
  44856. /**
  44857. * Stores the refraction values in a texture.
  44858. */
  44859. protected _refractionTexture: BaseTexture;
  44860. /**
  44861. * Stores the emissive values in a texture.
  44862. */
  44863. protected _emissiveTexture: BaseTexture;
  44864. /**
  44865. * AKA Specular texture in other nomenclature.
  44866. */
  44867. protected _reflectivityTexture: BaseTexture;
  44868. /**
  44869. * Used to switch from specular/glossiness to metallic/roughness workflow.
  44870. */
  44871. protected _metallicTexture: BaseTexture;
  44872. /**
  44873. * Specifies the metallic scalar of the metallic/roughness workflow.
  44874. * Can also be used to scale the metalness values of the metallic texture.
  44875. */
  44876. protected _metallic: Nullable<number>;
  44877. /**
  44878. * Specifies the roughness scalar of the metallic/roughness workflow.
  44879. * Can also be used to scale the roughness values of the metallic texture.
  44880. */
  44881. protected _roughness: Nullable<number>;
  44882. /**
  44883. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  44884. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  44885. */
  44886. protected _microSurfaceTexture: BaseTexture;
  44887. /**
  44888. * Stores surface normal data used to displace a mesh in a texture.
  44889. */
  44890. protected _bumpTexture: BaseTexture;
  44891. /**
  44892. * Stores the pre-calculated light information of a mesh in a texture.
  44893. */
  44894. protected _lightmapTexture: BaseTexture;
  44895. /**
  44896. * The color of a material in ambient lighting.
  44897. */
  44898. protected _ambientColor: Color3;
  44899. /**
  44900. * AKA Diffuse Color in other nomenclature.
  44901. */
  44902. protected _albedoColor: Color3;
  44903. /**
  44904. * AKA Specular Color in other nomenclature.
  44905. */
  44906. protected _reflectivityColor: Color3;
  44907. /**
  44908. * The color applied when light is reflected from a material.
  44909. */
  44910. protected _reflectionColor: Color3;
  44911. /**
  44912. * The color applied when light is emitted from a material.
  44913. */
  44914. protected _emissiveColor: Color3;
  44915. /**
  44916. * AKA Glossiness in other nomenclature.
  44917. */
  44918. protected _microSurface: number;
  44919. /**
  44920. * source material index of refraction (IOR)' / 'destination material IOR.
  44921. */
  44922. protected _indexOfRefraction: number;
  44923. /**
  44924. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  44925. */
  44926. protected _invertRefractionY: boolean;
  44927. /**
  44928. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  44929. * Materials half opaque for instance using refraction could benefit from this control.
  44930. */
  44931. protected _linkRefractionWithTransparency: boolean;
  44932. /**
  44933. * Specifies that the material will use the light map as a show map.
  44934. */
  44935. protected _useLightmapAsShadowmap: boolean;
  44936. /**
  44937. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  44938. * makes the reflect vector face the model (under horizon).
  44939. */
  44940. protected _useHorizonOcclusion: boolean;
  44941. /**
  44942. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  44943. * too much the area relying on ambient texture to define their ambient occlusion.
  44944. */
  44945. protected _useRadianceOcclusion: boolean;
  44946. /**
  44947. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  44948. */
  44949. protected _useAlphaFromAlbedoTexture: boolean;
  44950. /**
  44951. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  44952. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  44953. */
  44954. protected _useSpecularOverAlpha: boolean;
  44955. /**
  44956. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  44957. */
  44958. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  44959. /**
  44960. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  44961. */
  44962. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  44963. /**
  44964. * Specifies if the metallic texture contains the roughness information in its green channel.
  44965. */
  44966. protected _useRoughnessFromMetallicTextureGreen: boolean;
  44967. /**
  44968. * Specifies if the metallic texture contains the metallness information in its blue channel.
  44969. */
  44970. protected _useMetallnessFromMetallicTextureBlue: boolean;
  44971. /**
  44972. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  44973. */
  44974. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  44975. /**
  44976. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  44977. */
  44978. protected _useAmbientInGrayScale: boolean;
  44979. /**
  44980. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  44981. * The material will try to infer what glossiness each pixel should be.
  44982. */
  44983. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  44984. /**
  44985. * Defines the falloff type used in this material.
  44986. * It by default is Physical.
  44987. */
  44988. protected _lightFalloff: number;
  44989. /**
  44990. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  44991. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  44992. */
  44993. protected _useRadianceOverAlpha: boolean;
  44994. /**
  44995. * Allows using an object space normal map (instead of tangent space).
  44996. */
  44997. protected _useObjectSpaceNormalMap: boolean;
  44998. /**
  44999. * Allows using the bump map in parallax mode.
  45000. */
  45001. protected _useParallax: boolean;
  45002. /**
  45003. * Allows using the bump map in parallax occlusion mode.
  45004. */
  45005. protected _useParallaxOcclusion: boolean;
  45006. /**
  45007. * Controls the scale bias of the parallax mode.
  45008. */
  45009. protected _parallaxScaleBias: number;
  45010. /**
  45011. * If sets to true, disables all the lights affecting the material.
  45012. */
  45013. protected _disableLighting: boolean;
  45014. /**
  45015. * Number of Simultaneous lights allowed on the material.
  45016. */
  45017. protected _maxSimultaneousLights: number;
  45018. /**
  45019. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  45020. */
  45021. protected _invertNormalMapX: boolean;
  45022. /**
  45023. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  45024. */
  45025. protected _invertNormalMapY: boolean;
  45026. /**
  45027. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  45028. */
  45029. protected _twoSidedLighting: boolean;
  45030. /**
  45031. * Defines the alpha limits in alpha test mode.
  45032. */
  45033. protected _alphaCutOff: number;
  45034. /**
  45035. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  45036. */
  45037. protected _forceAlphaTest: boolean;
  45038. /**
  45039. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45040. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  45041. */
  45042. protected _useAlphaFresnel: boolean;
  45043. /**
  45044. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45045. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  45046. */
  45047. protected _useLinearAlphaFresnel: boolean;
  45048. /**
  45049. * The transparency mode of the material.
  45050. */
  45051. protected _transparencyMode: Nullable<number>;
  45052. /**
  45053. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  45054. * from cos thetav and roughness:
  45055. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  45056. */
  45057. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  45058. /**
  45059. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  45060. */
  45061. protected _forceIrradianceInFragment: boolean;
  45062. /**
  45063. * Force normal to face away from face.
  45064. */
  45065. protected _forceNormalForward: boolean;
  45066. /**
  45067. * Enables specular anti aliasing in the PBR shader.
  45068. * It will both interacts on the Geometry for analytical and IBL lighting.
  45069. * It also prefilter the roughness map based on the bump values.
  45070. */
  45071. protected _enableSpecularAntiAliasing: boolean;
  45072. /**
  45073. * Default configuration related to image processing available in the PBR Material.
  45074. */
  45075. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  45076. /**
  45077. * Keep track of the image processing observer to allow dispose and replace.
  45078. */
  45079. private _imageProcessingObserver;
  45080. /**
  45081. * Attaches a new image processing configuration to the PBR Material.
  45082. * @param configuration
  45083. */
  45084. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  45085. /**
  45086. * Stores the available render targets.
  45087. */
  45088. private _renderTargets;
  45089. /**
  45090. * Sets the global ambient color for the material used in lighting calculations.
  45091. */
  45092. private _globalAmbientColor;
  45093. /**
  45094. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  45095. */
  45096. private _useLogarithmicDepth;
  45097. /**
  45098. * If set to true, no lighting calculations will be applied.
  45099. */
  45100. private _unlit;
  45101. private _debugMode;
  45102. /**
  45103. * @hidden
  45104. * This is reserved for the inspector.
  45105. * Defines the material debug mode.
  45106. * It helps seeing only some components of the material while troubleshooting.
  45107. */
  45108. debugMode: number;
  45109. /**
  45110. * @hidden
  45111. * This is reserved for the inspector.
  45112. * Specify from where on screen the debug mode should start.
  45113. * The value goes from -1 (full screen) to 1 (not visible)
  45114. * It helps with side by side comparison against the final render
  45115. * This defaults to -1
  45116. */
  45117. private debugLimit;
  45118. /**
  45119. * @hidden
  45120. * This is reserved for the inspector.
  45121. * As the default viewing range might not be enough (if the ambient is really small for instance)
  45122. * You can use the factor to better multiply the final value.
  45123. */
  45124. private debugFactor;
  45125. /**
  45126. * Defines the clear coat layer parameters for the material.
  45127. */
  45128. readonly clearCoat: PBRClearCoatConfiguration;
  45129. /**
  45130. * Defines the anisotropic parameters for the material.
  45131. */
  45132. readonly anisotropy: PBRAnisotropicConfiguration;
  45133. /**
  45134. * Defines the BRDF parameters for the material.
  45135. */
  45136. readonly brdf: PBRBRDFConfiguration;
  45137. /**
  45138. * Instantiates a new PBRMaterial instance.
  45139. *
  45140. * @param name The material name
  45141. * @param scene The scene the material will be use in.
  45142. */
  45143. constructor(name: string, scene: Scene);
  45144. /**
  45145. * Gets a boolean indicating that current material needs to register RTT
  45146. */
  45147. readonly hasRenderTargetTextures: boolean;
  45148. /**
  45149. * Gets the name of the material class.
  45150. */
  45151. getClassName(): string;
  45152. /**
  45153. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  45154. */
  45155. /**
  45156. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  45157. */
  45158. useLogarithmicDepth: boolean;
  45159. /**
  45160. * Gets the current transparency mode.
  45161. */
  45162. /**
  45163. * Sets the transparency mode of the material.
  45164. *
  45165. * | Value | Type | Description |
  45166. * | ----- | ----------------------------------- | ----------- |
  45167. * | 0 | OPAQUE | |
  45168. * | 1 | ALPHATEST | |
  45169. * | 2 | ALPHABLEND | |
  45170. * | 3 | ALPHATESTANDBLEND | |
  45171. *
  45172. */
  45173. transparencyMode: Nullable<number>;
  45174. /**
  45175. * Returns true if alpha blending should be disabled.
  45176. */
  45177. private readonly _disableAlphaBlending;
  45178. /**
  45179. * Specifies whether or not this material should be rendered in alpha blend mode.
  45180. */
  45181. needAlphaBlending(): boolean;
  45182. /**
  45183. * Specifies if the mesh will require alpha blending.
  45184. * @param mesh - BJS mesh.
  45185. */
  45186. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  45187. /**
  45188. * Specifies whether or not this material should be rendered in alpha test mode.
  45189. */
  45190. needAlphaTesting(): boolean;
  45191. /**
  45192. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  45193. */
  45194. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  45195. /**
  45196. * Gets the texture used for the alpha test.
  45197. */
  45198. getAlphaTestTexture(): BaseTexture;
  45199. /**
  45200. * Specifies that the submesh is ready to be used.
  45201. * @param mesh - BJS mesh.
  45202. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  45203. * @param useInstances - Specifies that instances should be used.
  45204. * @returns - boolean indicating that the submesh is ready or not.
  45205. */
  45206. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  45207. /**
  45208. * Specifies if the material uses metallic roughness workflow.
  45209. * @returns boolean specifiying if the material uses metallic roughness workflow.
  45210. */
  45211. isMetallicWorkflow(): boolean;
  45212. private _prepareEffect;
  45213. private _prepareDefines;
  45214. /**
  45215. * Force shader compilation
  45216. */
  45217. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  45218. clipPlane: boolean;
  45219. }>): void;
  45220. /**
  45221. * Initializes the uniform buffer layout for the shader.
  45222. */
  45223. buildUniformLayout(): void;
  45224. /**
  45225. * Unbinds the textures.
  45226. */
  45227. unbind(): void;
  45228. /**
  45229. * Binds the submesh data.
  45230. * @param world - The world matrix.
  45231. * @param mesh - The BJS mesh.
  45232. * @param subMesh - A submesh of the BJS mesh.
  45233. */
  45234. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  45235. /**
  45236. * Returns the animatable textures.
  45237. * @returns - Array of animatable textures.
  45238. */
  45239. getAnimatables(): IAnimatable[];
  45240. /**
  45241. * Returns the texture used for reflections.
  45242. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  45243. */
  45244. private _getReflectionTexture;
  45245. /**
  45246. * Returns the texture used for refraction or null if none is used.
  45247. * @returns - Refection texture if present. If no refraction texture and refraction
  45248. * is linked with transparency, returns environment texture. Otherwise, returns null.
  45249. */
  45250. private _getRefractionTexture;
  45251. /**
  45252. * Returns an array of the actively used textures.
  45253. * @returns - Array of BaseTextures
  45254. */
  45255. getActiveTextures(): BaseTexture[];
  45256. /**
  45257. * Checks to see if a texture is used in the material.
  45258. * @param texture - Base texture to use.
  45259. * @returns - Boolean specifying if a texture is used in the material.
  45260. */
  45261. hasTexture(texture: BaseTexture): boolean;
  45262. /**
  45263. * Disposes the resources of the material.
  45264. * @param forceDisposeEffect - Forces the disposal of effects.
  45265. * @param forceDisposeTextures - Forces the disposal of all textures.
  45266. */
  45267. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  45268. }
  45269. }
  45270. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  45271. import { Nullable } from "babylonjs/types";
  45272. import { Scene } from "babylonjs/scene";
  45273. import { Color3 } from "babylonjs/Maths/math";
  45274. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  45275. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  45276. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45277. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  45278. /**
  45279. * The Physically based material of BJS.
  45280. *
  45281. * This offers the main features of a standard PBR material.
  45282. * For more information, please refer to the documentation :
  45283. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  45284. */
  45285. export class PBRMaterial extends PBRBaseMaterial {
  45286. /**
  45287. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  45288. */
  45289. static readonly PBRMATERIAL_OPAQUE: number;
  45290. /**
  45291. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  45292. */
  45293. static readonly PBRMATERIAL_ALPHATEST: number;
  45294. /**
  45295. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45296. */
  45297. static readonly PBRMATERIAL_ALPHABLEND: number;
  45298. /**
  45299. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45300. * They are also discarded below the alpha cutoff threshold to improve performances.
  45301. */
  45302. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  45303. /**
  45304. * Defines the default value of how much AO map is occluding the analytical lights
  45305. * (point spot...).
  45306. */
  45307. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  45308. /**
  45309. * Intensity of the direct lights e.g. the four lights available in your scene.
  45310. * This impacts both the direct diffuse and specular highlights.
  45311. */
  45312. directIntensity: number;
  45313. /**
  45314. * Intensity of the emissive part of the material.
  45315. * This helps controlling the emissive effect without modifying the emissive color.
  45316. */
  45317. emissiveIntensity: number;
  45318. /**
  45319. * Intensity of the environment e.g. how much the environment will light the object
  45320. * either through harmonics for rough material or through the refelction for shiny ones.
  45321. */
  45322. environmentIntensity: number;
  45323. /**
  45324. * This is a special control allowing the reduction of the specular highlights coming from the
  45325. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  45326. */
  45327. specularIntensity: number;
  45328. /**
  45329. * Debug Control allowing disabling the bump map on this material.
  45330. */
  45331. disableBumpMap: boolean;
  45332. /**
  45333. * AKA Diffuse Texture in standard nomenclature.
  45334. */
  45335. albedoTexture: BaseTexture;
  45336. /**
  45337. * AKA Occlusion Texture in other nomenclature.
  45338. */
  45339. ambientTexture: BaseTexture;
  45340. /**
  45341. * AKA Occlusion Texture Intensity in other nomenclature.
  45342. */
  45343. ambientTextureStrength: number;
  45344. /**
  45345. * Defines how much the AO map is occluding the analytical lights (point spot...).
  45346. * 1 means it completely occludes it
  45347. * 0 mean it has no impact
  45348. */
  45349. ambientTextureImpactOnAnalyticalLights: number;
  45350. /**
  45351. * Stores the alpha values in a texture.
  45352. */
  45353. opacityTexture: BaseTexture;
  45354. /**
  45355. * Stores the reflection values in a texture.
  45356. */
  45357. reflectionTexture: Nullable<BaseTexture>;
  45358. /**
  45359. * Stores the emissive values in a texture.
  45360. */
  45361. emissiveTexture: BaseTexture;
  45362. /**
  45363. * AKA Specular texture in other nomenclature.
  45364. */
  45365. reflectivityTexture: BaseTexture;
  45366. /**
  45367. * Used to switch from specular/glossiness to metallic/roughness workflow.
  45368. */
  45369. metallicTexture: BaseTexture;
  45370. /**
  45371. * Specifies the metallic scalar of the metallic/roughness workflow.
  45372. * Can also be used to scale the metalness values of the metallic texture.
  45373. */
  45374. metallic: Nullable<number>;
  45375. /**
  45376. * Specifies the roughness scalar of the metallic/roughness workflow.
  45377. * Can also be used to scale the roughness values of the metallic texture.
  45378. */
  45379. roughness: Nullable<number>;
  45380. /**
  45381. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  45382. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  45383. */
  45384. microSurfaceTexture: BaseTexture;
  45385. /**
  45386. * Stores surface normal data used to displace a mesh in a texture.
  45387. */
  45388. bumpTexture: BaseTexture;
  45389. /**
  45390. * Stores the pre-calculated light information of a mesh in a texture.
  45391. */
  45392. lightmapTexture: BaseTexture;
  45393. /**
  45394. * Stores the refracted light information in a texture.
  45395. */
  45396. refractionTexture: BaseTexture;
  45397. /**
  45398. * The color of a material in ambient lighting.
  45399. */
  45400. ambientColor: Color3;
  45401. /**
  45402. * AKA Diffuse Color in other nomenclature.
  45403. */
  45404. albedoColor: Color3;
  45405. /**
  45406. * AKA Specular Color in other nomenclature.
  45407. */
  45408. reflectivityColor: Color3;
  45409. /**
  45410. * The color reflected from the material.
  45411. */
  45412. reflectionColor: Color3;
  45413. /**
  45414. * The color emitted from the material.
  45415. */
  45416. emissiveColor: Color3;
  45417. /**
  45418. * AKA Glossiness in other nomenclature.
  45419. */
  45420. microSurface: number;
  45421. /**
  45422. * source material index of refraction (IOR)' / 'destination material IOR.
  45423. */
  45424. indexOfRefraction: number;
  45425. /**
  45426. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  45427. */
  45428. invertRefractionY: boolean;
  45429. /**
  45430. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  45431. * Materials half opaque for instance using refraction could benefit from this control.
  45432. */
  45433. linkRefractionWithTransparency: boolean;
  45434. /**
  45435. * If true, the light map contains occlusion information instead of lighting info.
  45436. */
  45437. useLightmapAsShadowmap: boolean;
  45438. /**
  45439. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  45440. */
  45441. useAlphaFromAlbedoTexture: boolean;
  45442. /**
  45443. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  45444. */
  45445. forceAlphaTest: boolean;
  45446. /**
  45447. * Defines the alpha limits in alpha test mode.
  45448. */
  45449. alphaCutOff: number;
  45450. /**
  45451. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  45452. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  45453. */
  45454. useSpecularOverAlpha: boolean;
  45455. /**
  45456. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  45457. */
  45458. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  45459. /**
  45460. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  45461. */
  45462. useRoughnessFromMetallicTextureAlpha: boolean;
  45463. /**
  45464. * Specifies if the metallic texture contains the roughness information in its green channel.
  45465. */
  45466. useRoughnessFromMetallicTextureGreen: boolean;
  45467. /**
  45468. * Specifies if the metallic texture contains the metallness information in its blue channel.
  45469. */
  45470. useMetallnessFromMetallicTextureBlue: boolean;
  45471. /**
  45472. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  45473. */
  45474. useAmbientOcclusionFromMetallicTextureRed: boolean;
  45475. /**
  45476. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  45477. */
  45478. useAmbientInGrayScale: boolean;
  45479. /**
  45480. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  45481. * The material will try to infer what glossiness each pixel should be.
  45482. */
  45483. useAutoMicroSurfaceFromReflectivityMap: boolean;
  45484. /**
  45485. * BJS is using an harcoded light falloff based on a manually sets up range.
  45486. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  45487. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  45488. */
  45489. /**
  45490. * BJS is using an harcoded light falloff based on a manually sets up range.
  45491. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  45492. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  45493. */
  45494. usePhysicalLightFalloff: boolean;
  45495. /**
  45496. * In order to support the falloff compatibility with gltf, a special mode has been added
  45497. * to reproduce the gltf light falloff.
  45498. */
  45499. /**
  45500. * In order to support the falloff compatibility with gltf, a special mode has been added
  45501. * to reproduce the gltf light falloff.
  45502. */
  45503. useGLTFLightFalloff: boolean;
  45504. /**
  45505. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  45506. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  45507. */
  45508. useRadianceOverAlpha: boolean;
  45509. /**
  45510. * Allows using an object space normal map (instead of tangent space).
  45511. */
  45512. useObjectSpaceNormalMap: boolean;
  45513. /**
  45514. * Allows using the bump map in parallax mode.
  45515. */
  45516. useParallax: boolean;
  45517. /**
  45518. * Allows using the bump map in parallax occlusion mode.
  45519. */
  45520. useParallaxOcclusion: boolean;
  45521. /**
  45522. * Controls the scale bias of the parallax mode.
  45523. */
  45524. parallaxScaleBias: number;
  45525. /**
  45526. * If sets to true, disables all the lights affecting the material.
  45527. */
  45528. disableLighting: boolean;
  45529. /**
  45530. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  45531. */
  45532. forceIrradianceInFragment: boolean;
  45533. /**
  45534. * Number of Simultaneous lights allowed on the material.
  45535. */
  45536. maxSimultaneousLights: number;
  45537. /**
  45538. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  45539. */
  45540. invertNormalMapX: boolean;
  45541. /**
  45542. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  45543. */
  45544. invertNormalMapY: boolean;
  45545. /**
  45546. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  45547. */
  45548. twoSidedLighting: boolean;
  45549. /**
  45550. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45551. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  45552. */
  45553. useAlphaFresnel: boolean;
  45554. /**
  45555. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45556. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  45557. */
  45558. useLinearAlphaFresnel: boolean;
  45559. /**
  45560. * Let user defines the brdf lookup texture used for IBL.
  45561. * A default 8bit version is embedded but you could point at :
  45562. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.png
  45563. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  45564. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  45565. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  45566. */
  45567. environmentBRDFTexture: Nullable<BaseTexture>;
  45568. /**
  45569. * Force normal to face away from face.
  45570. */
  45571. forceNormalForward: boolean;
  45572. /**
  45573. * Enables specular anti aliasing in the PBR shader.
  45574. * It will both interacts on the Geometry for analytical and IBL lighting.
  45575. * It also prefilter the roughness map based on the bump values.
  45576. */
  45577. enableSpecularAntiAliasing: boolean;
  45578. /**
  45579. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  45580. * makes the reflect vector face the model (under horizon).
  45581. */
  45582. useHorizonOcclusion: boolean;
  45583. /**
  45584. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  45585. * too much the area relying on ambient texture to define their ambient occlusion.
  45586. */
  45587. useRadianceOcclusion: boolean;
  45588. /**
  45589. * If set to true, no lighting calculations will be applied.
  45590. */
  45591. unlit: boolean;
  45592. /**
  45593. * Gets the image processing configuration used either in this material.
  45594. */
  45595. /**
  45596. * Sets the Default image processing configuration used either in the this material.
  45597. *
  45598. * If sets to null, the scene one is in use.
  45599. */
  45600. imageProcessingConfiguration: ImageProcessingConfiguration;
  45601. /**
  45602. * Gets wether the color curves effect is enabled.
  45603. */
  45604. /**
  45605. * Sets wether the color curves effect is enabled.
  45606. */
  45607. cameraColorCurvesEnabled: boolean;
  45608. /**
  45609. * Gets wether the color grading effect is enabled.
  45610. */
  45611. /**
  45612. * Gets wether the color grading effect is enabled.
  45613. */
  45614. cameraColorGradingEnabled: boolean;
  45615. /**
  45616. * Gets wether tonemapping is enabled or not.
  45617. */
  45618. /**
  45619. * Sets wether tonemapping is enabled or not
  45620. */
  45621. cameraToneMappingEnabled: boolean;
  45622. /**
  45623. * The camera exposure used on this material.
  45624. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45625. * This corresponds to a photographic exposure.
  45626. */
  45627. /**
  45628. * The camera exposure used on this material.
  45629. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45630. * This corresponds to a photographic exposure.
  45631. */
  45632. cameraExposure: number;
  45633. /**
  45634. * Gets The camera contrast used on this material.
  45635. */
  45636. /**
  45637. * Sets The camera contrast used on this material.
  45638. */
  45639. cameraContrast: number;
  45640. /**
  45641. * Gets the Color Grading 2D Lookup Texture.
  45642. */
  45643. /**
  45644. * Sets the Color Grading 2D Lookup Texture.
  45645. */
  45646. cameraColorGradingTexture: Nullable<BaseTexture>;
  45647. /**
  45648. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45649. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45650. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  45651. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45652. */
  45653. /**
  45654. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45655. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45656. * 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;
  45657. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45658. */
  45659. cameraColorCurves: Nullable<ColorCurves>;
  45660. /**
  45661. * Instantiates a new PBRMaterial instance.
  45662. *
  45663. * @param name The material name
  45664. * @param scene The scene the material will be use in.
  45665. */
  45666. constructor(name: string, scene: Scene);
  45667. /**
  45668. * Returns the name of this material class.
  45669. */
  45670. getClassName(): string;
  45671. /**
  45672. * Makes a duplicate of the current material.
  45673. * @param name - name to use for the new material.
  45674. */
  45675. clone(name: string): PBRMaterial;
  45676. /**
  45677. * Serializes this PBR Material.
  45678. * @returns - An object with the serialized material.
  45679. */
  45680. serialize(): any;
  45681. /**
  45682. * Parses a PBR Material from a serialized object.
  45683. * @param source - Serialized object.
  45684. * @param scene - BJS scene instance.
  45685. * @param rootUrl - url for the scene object
  45686. * @returns - PBRMaterial
  45687. */
  45688. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  45689. }
  45690. }
  45691. declare module "babylonjs/Helpers/sceneHelpers" {
  45692. import { Nullable } from "babylonjs/types";
  45693. import { Mesh } from "babylonjs/Meshes/mesh";
  45694. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45695. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  45696. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  45697. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  45698. import "babylonjs/Meshes/Builders/boxBuilder";
  45699. /** @hidden */
  45700. export var _forceSceneHelpersToBundle: boolean;
  45701. module "babylonjs/scene" {
  45702. interface Scene {
  45703. /**
  45704. * Creates a default light for the scene.
  45705. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  45706. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  45707. */
  45708. createDefaultLight(replace?: boolean): void;
  45709. /**
  45710. * Creates a default camera for the scene.
  45711. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  45712. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  45713. * @param replace has default false, when true replaces the active camera in the scene
  45714. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  45715. */
  45716. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  45717. /**
  45718. * Creates a default camera and a default light.
  45719. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  45720. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  45721. * @param replace has the default false, when true replaces the active camera/light in the scene
  45722. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  45723. */
  45724. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  45725. /**
  45726. * Creates a new sky box
  45727. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  45728. * @param environmentTexture defines the texture to use as environment texture
  45729. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  45730. * @param scale defines the overall scale of the skybox
  45731. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  45732. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  45733. * @returns a new mesh holding the sky box
  45734. */
  45735. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  45736. /**
  45737. * Creates a new environment
  45738. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  45739. * @param options defines the options you can use to configure the environment
  45740. * @returns the new EnvironmentHelper
  45741. */
  45742. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  45743. /**
  45744. * Creates a new VREXperienceHelper
  45745. * @see http://doc.babylonjs.com/how_to/webvr_helper
  45746. * @param webVROptions defines the options used to create the new VREXperienceHelper
  45747. * @returns a new VREXperienceHelper
  45748. */
  45749. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  45750. /**
  45751. * Creates a new XREXperienceHelper
  45752. * @see http://doc.babylonjs.com/how_to/webxr
  45753. * @returns a promise for a new XREXperienceHelper
  45754. */
  45755. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  45756. }
  45757. }
  45758. }
  45759. declare module "babylonjs/Helpers/videoDome" {
  45760. import { Scene } from "babylonjs/scene";
  45761. import { TransformNode } from "babylonjs/Meshes/transformNode";
  45762. import { Mesh } from "babylonjs/Meshes/mesh";
  45763. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  45764. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  45765. import "babylonjs/Meshes/Builders/sphereBuilder";
  45766. /**
  45767. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  45768. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  45769. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  45770. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  45771. */
  45772. export class VideoDome extends TransformNode {
  45773. /**
  45774. * Define the video source as a Monoscopic panoramic 360 video.
  45775. */
  45776. static readonly MODE_MONOSCOPIC: number;
  45777. /**
  45778. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  45779. */
  45780. static readonly MODE_TOPBOTTOM: number;
  45781. /**
  45782. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  45783. */
  45784. static readonly MODE_SIDEBYSIDE: number;
  45785. private _useDirectMapping;
  45786. /**
  45787. * The video texture being displayed on the sphere
  45788. */
  45789. protected _videoTexture: VideoTexture;
  45790. /**
  45791. * Gets the video texture being displayed on the sphere
  45792. */
  45793. readonly videoTexture: VideoTexture;
  45794. /**
  45795. * The skybox material
  45796. */
  45797. protected _material: BackgroundMaterial;
  45798. /**
  45799. * The surface used for the skybox
  45800. */
  45801. protected _mesh: Mesh;
  45802. /**
  45803. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  45804. * Also see the options.resolution property.
  45805. */
  45806. fovMultiplier: number;
  45807. private _videoMode;
  45808. /**
  45809. * Gets or set the current video mode for the video. It can be:
  45810. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  45811. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  45812. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  45813. */
  45814. videoMode: number;
  45815. /**
  45816. * Oberserver used in Stereoscopic VR Mode.
  45817. */
  45818. private _onBeforeCameraRenderObserver;
  45819. /**
  45820. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  45821. * @param name Element's name, child elements will append suffixes for their own names.
  45822. * @param urlsOrVideo defines the url(s) or the video element to use
  45823. * @param options An object containing optional or exposed sub element properties
  45824. */
  45825. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  45826. resolution?: number;
  45827. clickToPlay?: boolean;
  45828. autoPlay?: boolean;
  45829. loop?: boolean;
  45830. size?: number;
  45831. poster?: string;
  45832. useDirectMapping?: boolean;
  45833. }, scene: Scene);
  45834. private _changeVideoMode;
  45835. /**
  45836. * Releases resources associated with this node.
  45837. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  45838. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  45839. */
  45840. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  45841. }
  45842. }
  45843. declare module "babylonjs/Helpers/index" {
  45844. export * from "babylonjs/Helpers/environmentHelper";
  45845. export * from "babylonjs/Helpers/photoDome";
  45846. export * from "babylonjs/Helpers/sceneHelpers";
  45847. export * from "babylonjs/Helpers/videoDome";
  45848. }
  45849. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  45850. import { PerfCounter } from "babylonjs/Misc/tools";
  45851. import { IDisposable } from "babylonjs/scene";
  45852. import { Engine } from "babylonjs/Engines/engine";
  45853. /**
  45854. * This class can be used to get instrumentation data from a Babylon engine
  45855. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  45856. */
  45857. export class EngineInstrumentation implements IDisposable {
  45858. /**
  45859. * Define the instrumented engine.
  45860. */
  45861. engine: Engine;
  45862. private _captureGPUFrameTime;
  45863. private _gpuFrameTimeToken;
  45864. private _gpuFrameTime;
  45865. private _captureShaderCompilationTime;
  45866. private _shaderCompilationTime;
  45867. private _onBeginFrameObserver;
  45868. private _onEndFrameObserver;
  45869. private _onBeforeShaderCompilationObserver;
  45870. private _onAfterShaderCompilationObserver;
  45871. /**
  45872. * Gets the perf counter used for GPU frame time
  45873. */
  45874. readonly gpuFrameTimeCounter: PerfCounter;
  45875. /**
  45876. * Gets the GPU frame time capture status
  45877. */
  45878. /**
  45879. * Enable or disable the GPU frame time capture
  45880. */
  45881. captureGPUFrameTime: boolean;
  45882. /**
  45883. * Gets the perf counter used for shader compilation time
  45884. */
  45885. readonly shaderCompilationTimeCounter: PerfCounter;
  45886. /**
  45887. * Gets the shader compilation time capture status
  45888. */
  45889. /**
  45890. * Enable or disable the shader compilation time capture
  45891. */
  45892. captureShaderCompilationTime: boolean;
  45893. /**
  45894. * Instantiates a new engine instrumentation.
  45895. * This class can be used to get instrumentation data from a Babylon engine
  45896. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  45897. * @param engine Defines the engine to instrument
  45898. */
  45899. constructor(
  45900. /**
  45901. * Define the instrumented engine.
  45902. */
  45903. engine: Engine);
  45904. /**
  45905. * Dispose and release associated resources.
  45906. */
  45907. dispose(): void;
  45908. }
  45909. }
  45910. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  45911. import { PerfCounter } from "babylonjs/Misc/tools";
  45912. import { Scene, IDisposable } from "babylonjs/scene";
  45913. /**
  45914. * This class can be used to get instrumentation data from a Babylon engine
  45915. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  45916. */
  45917. export class SceneInstrumentation implements IDisposable {
  45918. /**
  45919. * Defines the scene to instrument
  45920. */
  45921. scene: Scene;
  45922. private _captureActiveMeshesEvaluationTime;
  45923. private _activeMeshesEvaluationTime;
  45924. private _captureRenderTargetsRenderTime;
  45925. private _renderTargetsRenderTime;
  45926. private _captureFrameTime;
  45927. private _frameTime;
  45928. private _captureRenderTime;
  45929. private _renderTime;
  45930. private _captureInterFrameTime;
  45931. private _interFrameTime;
  45932. private _captureParticlesRenderTime;
  45933. private _particlesRenderTime;
  45934. private _captureSpritesRenderTime;
  45935. private _spritesRenderTime;
  45936. private _capturePhysicsTime;
  45937. private _physicsTime;
  45938. private _captureAnimationsTime;
  45939. private _animationsTime;
  45940. private _captureCameraRenderTime;
  45941. private _cameraRenderTime;
  45942. private _onBeforeActiveMeshesEvaluationObserver;
  45943. private _onAfterActiveMeshesEvaluationObserver;
  45944. private _onBeforeRenderTargetsRenderObserver;
  45945. private _onAfterRenderTargetsRenderObserver;
  45946. private _onAfterRenderObserver;
  45947. private _onBeforeDrawPhaseObserver;
  45948. private _onAfterDrawPhaseObserver;
  45949. private _onBeforeAnimationsObserver;
  45950. private _onBeforeParticlesRenderingObserver;
  45951. private _onAfterParticlesRenderingObserver;
  45952. private _onBeforeSpritesRenderingObserver;
  45953. private _onAfterSpritesRenderingObserver;
  45954. private _onBeforePhysicsObserver;
  45955. private _onAfterPhysicsObserver;
  45956. private _onAfterAnimationsObserver;
  45957. private _onBeforeCameraRenderObserver;
  45958. private _onAfterCameraRenderObserver;
  45959. /**
  45960. * Gets the perf counter used for active meshes evaluation time
  45961. */
  45962. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  45963. /**
  45964. * Gets the active meshes evaluation time capture status
  45965. */
  45966. /**
  45967. * Enable or disable the active meshes evaluation time capture
  45968. */
  45969. captureActiveMeshesEvaluationTime: boolean;
  45970. /**
  45971. * Gets the perf counter used for render targets render time
  45972. */
  45973. readonly renderTargetsRenderTimeCounter: PerfCounter;
  45974. /**
  45975. * Gets the render targets render time capture status
  45976. */
  45977. /**
  45978. * Enable or disable the render targets render time capture
  45979. */
  45980. captureRenderTargetsRenderTime: boolean;
  45981. /**
  45982. * Gets the perf counter used for particles render time
  45983. */
  45984. readonly particlesRenderTimeCounter: PerfCounter;
  45985. /**
  45986. * Gets the particles render time capture status
  45987. */
  45988. /**
  45989. * Enable or disable the particles render time capture
  45990. */
  45991. captureParticlesRenderTime: boolean;
  45992. /**
  45993. * Gets the perf counter used for sprites render time
  45994. */
  45995. readonly spritesRenderTimeCounter: PerfCounter;
  45996. /**
  45997. * Gets the sprites render time capture status
  45998. */
  45999. /**
  46000. * Enable or disable the sprites render time capture
  46001. */
  46002. captureSpritesRenderTime: boolean;
  46003. /**
  46004. * Gets the perf counter used for physics time
  46005. */
  46006. readonly physicsTimeCounter: PerfCounter;
  46007. /**
  46008. * Gets the physics time capture status
  46009. */
  46010. /**
  46011. * Enable or disable the physics time capture
  46012. */
  46013. capturePhysicsTime: boolean;
  46014. /**
  46015. * Gets the perf counter used for animations time
  46016. */
  46017. readonly animationsTimeCounter: PerfCounter;
  46018. /**
  46019. * Gets the animations time capture status
  46020. */
  46021. /**
  46022. * Enable or disable the animations time capture
  46023. */
  46024. captureAnimationsTime: boolean;
  46025. /**
  46026. * Gets the perf counter used for frame time capture
  46027. */
  46028. readonly frameTimeCounter: PerfCounter;
  46029. /**
  46030. * Gets the frame time capture status
  46031. */
  46032. /**
  46033. * Enable or disable the frame time capture
  46034. */
  46035. captureFrameTime: boolean;
  46036. /**
  46037. * Gets the perf counter used for inter-frames time capture
  46038. */
  46039. readonly interFrameTimeCounter: PerfCounter;
  46040. /**
  46041. * Gets the inter-frames time capture status
  46042. */
  46043. /**
  46044. * Enable or disable the inter-frames time capture
  46045. */
  46046. captureInterFrameTime: boolean;
  46047. /**
  46048. * Gets the perf counter used for render time capture
  46049. */
  46050. readonly renderTimeCounter: PerfCounter;
  46051. /**
  46052. * Gets the render time capture status
  46053. */
  46054. /**
  46055. * Enable or disable the render time capture
  46056. */
  46057. captureRenderTime: boolean;
  46058. /**
  46059. * Gets the perf counter used for camera render time capture
  46060. */
  46061. readonly cameraRenderTimeCounter: PerfCounter;
  46062. /**
  46063. * Gets the camera render time capture status
  46064. */
  46065. /**
  46066. * Enable or disable the camera render time capture
  46067. */
  46068. captureCameraRenderTime: boolean;
  46069. /**
  46070. * Gets the perf counter used for draw calls
  46071. */
  46072. readonly drawCallsCounter: PerfCounter;
  46073. /**
  46074. * Gets the perf counter used for texture collisions
  46075. */
  46076. readonly textureCollisionsCounter: PerfCounter;
  46077. /**
  46078. * Instantiates a new scene instrumentation.
  46079. * This class can be used to get instrumentation data from a Babylon engine
  46080. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  46081. * @param scene Defines the scene to instrument
  46082. */
  46083. constructor(
  46084. /**
  46085. * Defines the scene to instrument
  46086. */
  46087. scene: Scene);
  46088. /**
  46089. * Dispose and release associated resources.
  46090. */
  46091. dispose(): void;
  46092. }
  46093. }
  46094. declare module "babylonjs/Instrumentation/index" {
  46095. export * from "babylonjs/Instrumentation/engineInstrumentation";
  46096. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  46097. export * from "babylonjs/Instrumentation/timeToken";
  46098. }
  46099. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  46100. /** @hidden */
  46101. export var glowMapGenerationPixelShader: {
  46102. name: string;
  46103. shader: string;
  46104. };
  46105. }
  46106. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  46107. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  46108. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  46109. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  46110. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  46111. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  46112. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  46113. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  46114. /** @hidden */
  46115. export var glowMapGenerationVertexShader: {
  46116. name: string;
  46117. shader: string;
  46118. };
  46119. }
  46120. declare module "babylonjs/Layers/effectLayer" {
  46121. import { Observable } from "babylonjs/Misc/observable";
  46122. import { Nullable } from "babylonjs/types";
  46123. import { Camera } from "babylonjs/Cameras/camera";
  46124. import { Scene } from "babylonjs/scene";
  46125. import { Color4, ISize } from "babylonjs/Maths/math";
  46126. import { Engine } from "babylonjs/Engines/engine";
  46127. import { SubMesh } from "babylonjs/Meshes/subMesh";
  46128. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46129. import { Mesh } from "babylonjs/Meshes/mesh";
  46130. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  46131. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46132. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  46133. import { Effect } from "babylonjs/Materials/effect";
  46134. import { Material } from "babylonjs/Materials/material";
  46135. import "babylonjs/Shaders/glowMapGeneration.fragment";
  46136. import "babylonjs/Shaders/glowMapGeneration.vertex";
  46137. /**
  46138. * Effect layer options. This helps customizing the behaviour
  46139. * of the effect layer.
  46140. */
  46141. export interface IEffectLayerOptions {
  46142. /**
  46143. * Multiplication factor apply to the canvas size to compute the render target size
  46144. * used to generated the objects (the smaller the faster).
  46145. */
  46146. mainTextureRatio: number;
  46147. /**
  46148. * Enforces a fixed size texture to ensure effect stability across devices.
  46149. */
  46150. mainTextureFixedSize?: number;
  46151. /**
  46152. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  46153. */
  46154. alphaBlendingMode: number;
  46155. /**
  46156. * The camera attached to the layer.
  46157. */
  46158. camera: Nullable<Camera>;
  46159. /**
  46160. * The rendering group to draw the layer in.
  46161. */
  46162. renderingGroupId: number;
  46163. }
  46164. /**
  46165. * The effect layer Helps adding post process effect blended with the main pass.
  46166. *
  46167. * This can be for instance use to generate glow or higlight effects on the scene.
  46168. *
  46169. * The effect layer class can not be used directly and is intented to inherited from to be
  46170. * customized per effects.
  46171. */
  46172. export abstract class EffectLayer {
  46173. private _vertexBuffers;
  46174. private _indexBuffer;
  46175. private _cachedDefines;
  46176. private _effectLayerMapGenerationEffect;
  46177. private _effectLayerOptions;
  46178. private _mergeEffect;
  46179. protected _scene: Scene;
  46180. protected _engine: Engine;
  46181. protected _maxSize: number;
  46182. protected _mainTextureDesiredSize: ISize;
  46183. protected _mainTexture: RenderTargetTexture;
  46184. protected _shouldRender: boolean;
  46185. protected _postProcesses: PostProcess[];
  46186. protected _textures: BaseTexture[];
  46187. protected _emissiveTextureAndColor: {
  46188. texture: Nullable<BaseTexture>;
  46189. color: Color4;
  46190. };
  46191. /**
  46192. * The name of the layer
  46193. */
  46194. name: string;
  46195. /**
  46196. * The clear color of the texture used to generate the glow map.
  46197. */
  46198. neutralColor: Color4;
  46199. /**
  46200. * Specifies wether the highlight layer is enabled or not.
  46201. */
  46202. isEnabled: boolean;
  46203. /**
  46204. * Gets the camera attached to the layer.
  46205. */
  46206. readonly camera: Nullable<Camera>;
  46207. /**
  46208. * Gets the rendering group id the layer should render in.
  46209. */
  46210. readonly renderingGroupId: number;
  46211. /**
  46212. * An event triggered when the effect layer has been disposed.
  46213. */
  46214. onDisposeObservable: Observable<EffectLayer>;
  46215. /**
  46216. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  46217. */
  46218. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  46219. /**
  46220. * An event triggered when the generated texture is being merged in the scene.
  46221. */
  46222. onBeforeComposeObservable: Observable<EffectLayer>;
  46223. /**
  46224. * An event triggered when the generated texture has been merged in the scene.
  46225. */
  46226. onAfterComposeObservable: Observable<EffectLayer>;
  46227. /**
  46228. * An event triggered when the efffect layer changes its size.
  46229. */
  46230. onSizeChangedObservable: Observable<EffectLayer>;
  46231. /** @hidden */
  46232. static _SceneComponentInitialization: (scene: Scene) => void;
  46233. /**
  46234. * Instantiates a new effect Layer and references it in the scene.
  46235. * @param name The name of the layer
  46236. * @param scene The scene to use the layer in
  46237. */
  46238. constructor(
  46239. /** The Friendly of the effect in the scene */
  46240. name: string, scene: Scene);
  46241. /**
  46242. * Get the effect name of the layer.
  46243. * @return The effect name
  46244. */
  46245. abstract getEffectName(): string;
  46246. /**
  46247. * Checks for the readiness of the element composing the layer.
  46248. * @param subMesh the mesh to check for
  46249. * @param useInstances specify wether or not to use instances to render the mesh
  46250. * @return true if ready otherwise, false
  46251. */
  46252. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  46253. /**
  46254. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  46255. * @returns true if the effect requires stencil during the main canvas render pass.
  46256. */
  46257. abstract needStencil(): boolean;
  46258. /**
  46259. * Create the merge effect. This is the shader use to blit the information back
  46260. * to the main canvas at the end of the scene rendering.
  46261. * @returns The effect containing the shader used to merge the effect on the main canvas
  46262. */
  46263. protected abstract _createMergeEffect(): Effect;
  46264. /**
  46265. * Creates the render target textures and post processes used in the effect layer.
  46266. */
  46267. protected abstract _createTextureAndPostProcesses(): void;
  46268. /**
  46269. * Implementation specific of rendering the generating effect on the main canvas.
  46270. * @param effect The effect used to render through
  46271. */
  46272. protected abstract _internalRender(effect: Effect): void;
  46273. /**
  46274. * Sets the required values for both the emissive texture and and the main color.
  46275. */
  46276. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  46277. /**
  46278. * Free any resources and references associated to a mesh.
  46279. * Internal use
  46280. * @param mesh The mesh to free.
  46281. */
  46282. abstract _disposeMesh(mesh: Mesh): void;
  46283. /**
  46284. * Serializes this layer (Glow or Highlight for example)
  46285. * @returns a serialized layer object
  46286. */
  46287. abstract serialize?(): any;
  46288. /**
  46289. * Initializes the effect layer with the required options.
  46290. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  46291. */
  46292. protected _init(options: Partial<IEffectLayerOptions>): void;
  46293. /**
  46294. * Generates the index buffer of the full screen quad blending to the main canvas.
  46295. */
  46296. private _generateIndexBuffer;
  46297. /**
  46298. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  46299. */
  46300. private _genrateVertexBuffer;
  46301. /**
  46302. * Sets the main texture desired size which is the closest power of two
  46303. * of the engine canvas size.
  46304. */
  46305. private _setMainTextureSize;
  46306. /**
  46307. * Creates the main texture for the effect layer.
  46308. */
  46309. protected _createMainTexture(): void;
  46310. /**
  46311. * Adds specific effects defines.
  46312. * @param defines The defines to add specifics to.
  46313. */
  46314. protected _addCustomEffectDefines(defines: string[]): void;
  46315. /**
  46316. * Checks for the readiness of the element composing the layer.
  46317. * @param subMesh the mesh to check for
  46318. * @param useInstances specify wether or not to use instances to render the mesh
  46319. * @param emissiveTexture the associated emissive texture used to generate the glow
  46320. * @return true if ready otherwise, false
  46321. */
  46322. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  46323. /**
  46324. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  46325. */
  46326. render(): void;
  46327. /**
  46328. * Determine if a given mesh will be used in the current effect.
  46329. * @param mesh mesh to test
  46330. * @returns true if the mesh will be used
  46331. */
  46332. hasMesh(mesh: AbstractMesh): boolean;
  46333. /**
  46334. * Returns true if the layer contains information to display, otherwise false.
  46335. * @returns true if the glow layer should be rendered
  46336. */
  46337. shouldRender(): boolean;
  46338. /**
  46339. * Returns true if the mesh should render, otherwise false.
  46340. * @param mesh The mesh to render
  46341. * @returns true if it should render otherwise false
  46342. */
  46343. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  46344. /**
  46345. * Returns true if the mesh can be rendered, otherwise false.
  46346. * @param mesh The mesh to render
  46347. * @param material The material used on the mesh
  46348. * @returns true if it can be rendered otherwise false
  46349. */
  46350. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  46351. /**
  46352. * Returns true if the mesh should render, otherwise false.
  46353. * @param mesh The mesh to render
  46354. * @returns true if it should render otherwise false
  46355. */
  46356. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  46357. /**
  46358. * Renders the submesh passed in parameter to the generation map.
  46359. */
  46360. protected _renderSubMesh(subMesh: SubMesh): void;
  46361. /**
  46362. * Rebuild the required buffers.
  46363. * @hidden Internal use only.
  46364. */
  46365. _rebuild(): void;
  46366. /**
  46367. * Dispose only the render target textures and post process.
  46368. */
  46369. private _disposeTextureAndPostProcesses;
  46370. /**
  46371. * Dispose the highlight layer and free resources.
  46372. */
  46373. dispose(): void;
  46374. /**
  46375. * Gets the class name of the effect layer
  46376. * @returns the string with the class name of the effect layer
  46377. */
  46378. getClassName(): string;
  46379. /**
  46380. * Creates an effect layer from parsed effect layer data
  46381. * @param parsedEffectLayer defines effect layer data
  46382. * @param scene defines the current scene
  46383. * @param rootUrl defines the root URL containing the effect layer information
  46384. * @returns a parsed effect Layer
  46385. */
  46386. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  46387. }
  46388. }
  46389. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  46390. import { Scene } from "babylonjs/scene";
  46391. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  46392. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  46393. import { AbstractScene } from "babylonjs/abstractScene";
  46394. module "babylonjs/abstractScene" {
  46395. interface AbstractScene {
  46396. /**
  46397. * The list of effect layers (highlights/glow) added to the scene
  46398. * @see http://doc.babylonjs.com/how_to/highlight_layer
  46399. * @see http://doc.babylonjs.com/how_to/glow_layer
  46400. */
  46401. effectLayers: Array<EffectLayer>;
  46402. /**
  46403. * Removes the given effect layer from this scene.
  46404. * @param toRemove defines the effect layer to remove
  46405. * @returns the index of the removed effect layer
  46406. */
  46407. removeEffectLayer(toRemove: EffectLayer): number;
  46408. /**
  46409. * Adds the given effect layer to this scene
  46410. * @param newEffectLayer defines the effect layer to add
  46411. */
  46412. addEffectLayer(newEffectLayer: EffectLayer): void;
  46413. }
  46414. }
  46415. /**
  46416. * Defines the layer scene component responsible to manage any effect layers
  46417. * in a given scene.
  46418. */
  46419. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  46420. /**
  46421. * The component name helpfull to identify the component in the list of scene components.
  46422. */
  46423. readonly name: string;
  46424. /**
  46425. * The scene the component belongs to.
  46426. */
  46427. scene: Scene;
  46428. private _engine;
  46429. private _renderEffects;
  46430. private _needStencil;
  46431. private _previousStencilState;
  46432. /**
  46433. * Creates a new instance of the component for the given scene
  46434. * @param scene Defines the scene to register the component in
  46435. */
  46436. constructor(scene: Scene);
  46437. /**
  46438. * Registers the component in a given scene
  46439. */
  46440. register(): void;
  46441. /**
  46442. * Rebuilds the elements related to this component in case of
  46443. * context lost for instance.
  46444. */
  46445. rebuild(): void;
  46446. /**
  46447. * Serializes the component data to the specified json object
  46448. * @param serializationObject The object to serialize to
  46449. */
  46450. serialize(serializationObject: any): void;
  46451. /**
  46452. * Adds all the element from the container to the scene
  46453. * @param container the container holding the elements
  46454. */
  46455. addFromContainer(container: AbstractScene): void;
  46456. /**
  46457. * Removes all the elements in the container from the scene
  46458. * @param container contains the elements to remove
  46459. */
  46460. removeFromContainer(container: AbstractScene): void;
  46461. /**
  46462. * Disposes the component and the associated ressources.
  46463. */
  46464. dispose(): void;
  46465. private _isReadyForMesh;
  46466. private _renderMainTexture;
  46467. private _setStencil;
  46468. private _setStencilBack;
  46469. private _draw;
  46470. private _drawCamera;
  46471. private _drawRenderingGroup;
  46472. }
  46473. }
  46474. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  46475. /** @hidden */
  46476. export var glowMapMergePixelShader: {
  46477. name: string;
  46478. shader: string;
  46479. };
  46480. }
  46481. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  46482. /** @hidden */
  46483. export var glowMapMergeVertexShader: {
  46484. name: string;
  46485. shader: string;
  46486. };
  46487. }
  46488. declare module "babylonjs/Layers/glowLayer" {
  46489. import { Nullable } from "babylonjs/types";
  46490. import { Camera } from "babylonjs/Cameras/camera";
  46491. import { Scene } from "babylonjs/scene";
  46492. import { Color4 } from "babylonjs/Maths/math";
  46493. import { SubMesh } from "babylonjs/Meshes/subMesh";
  46494. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46495. import { Mesh } from "babylonjs/Meshes/mesh";
  46496. import { Texture } from "babylonjs/Materials/Textures/texture";
  46497. import { Effect } from "babylonjs/Materials/effect";
  46498. import { Material } from "babylonjs/Materials/material";
  46499. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  46500. import "babylonjs/Shaders/glowMapMerge.fragment";
  46501. import "babylonjs/Shaders/glowMapMerge.vertex";
  46502. module "babylonjs/abstractScene" {
  46503. interface AbstractScene {
  46504. /**
  46505. * Return a the first highlight layer of the scene with a given name.
  46506. * @param name The name of the highlight layer to look for.
  46507. * @return The highlight layer if found otherwise null.
  46508. */
  46509. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  46510. }
  46511. }
  46512. /**
  46513. * Glow layer options. This helps customizing the behaviour
  46514. * of the glow layer.
  46515. */
  46516. export interface IGlowLayerOptions {
  46517. /**
  46518. * Multiplication factor apply to the canvas size to compute the render target size
  46519. * used to generated the glowing objects (the smaller the faster).
  46520. */
  46521. mainTextureRatio: number;
  46522. /**
  46523. * Enforces a fixed size texture to ensure resize independant blur.
  46524. */
  46525. mainTextureFixedSize?: number;
  46526. /**
  46527. * How big is the kernel of the blur texture.
  46528. */
  46529. blurKernelSize: number;
  46530. /**
  46531. * The camera attached to the layer.
  46532. */
  46533. camera: Nullable<Camera>;
  46534. /**
  46535. * Enable MSAA by chosing the number of samples.
  46536. */
  46537. mainTextureSamples?: number;
  46538. /**
  46539. * The rendering group to draw the layer in.
  46540. */
  46541. renderingGroupId: number;
  46542. }
  46543. /**
  46544. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  46545. *
  46546. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  46547. * glowy meshes to your scene.
  46548. *
  46549. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  46550. */
  46551. export class GlowLayer extends EffectLayer {
  46552. /**
  46553. * Effect Name of the layer.
  46554. */
  46555. static readonly EffectName: string;
  46556. /**
  46557. * The default blur kernel size used for the glow.
  46558. */
  46559. static DefaultBlurKernelSize: number;
  46560. /**
  46561. * The default texture size ratio used for the glow.
  46562. */
  46563. static DefaultTextureRatio: number;
  46564. /**
  46565. * Sets the kernel size of the blur.
  46566. */
  46567. /**
  46568. * Gets the kernel size of the blur.
  46569. */
  46570. blurKernelSize: number;
  46571. /**
  46572. * Sets the glow intensity.
  46573. */
  46574. /**
  46575. * Gets the glow intensity.
  46576. */
  46577. intensity: number;
  46578. private _options;
  46579. private _intensity;
  46580. private _horizontalBlurPostprocess1;
  46581. private _verticalBlurPostprocess1;
  46582. private _horizontalBlurPostprocess2;
  46583. private _verticalBlurPostprocess2;
  46584. private _blurTexture1;
  46585. private _blurTexture2;
  46586. private _postProcesses1;
  46587. private _postProcesses2;
  46588. private _includedOnlyMeshes;
  46589. private _excludedMeshes;
  46590. /**
  46591. * Callback used to let the user override the color selection on a per mesh basis
  46592. */
  46593. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  46594. /**
  46595. * Callback used to let the user override the texture selection on a per mesh basis
  46596. */
  46597. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  46598. /**
  46599. * Instantiates a new glow Layer and references it to the scene.
  46600. * @param name The name of the layer
  46601. * @param scene The scene to use the layer in
  46602. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  46603. */
  46604. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  46605. /**
  46606. * Get the effect name of the layer.
  46607. * @return The effect name
  46608. */
  46609. getEffectName(): string;
  46610. /**
  46611. * Create the merge effect. This is the shader use to blit the information back
  46612. * to the main canvas at the end of the scene rendering.
  46613. */
  46614. protected _createMergeEffect(): Effect;
  46615. /**
  46616. * Creates the render target textures and post processes used in the glow layer.
  46617. */
  46618. protected _createTextureAndPostProcesses(): void;
  46619. /**
  46620. * Checks for the readiness of the element composing the layer.
  46621. * @param subMesh the mesh to check for
  46622. * @param useInstances specify wether or not to use instances to render the mesh
  46623. * @param emissiveTexture the associated emissive texture used to generate the glow
  46624. * @return true if ready otherwise, false
  46625. */
  46626. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  46627. /**
  46628. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  46629. */
  46630. needStencil(): boolean;
  46631. /**
  46632. * Returns true if the mesh can be rendered, otherwise false.
  46633. * @param mesh The mesh to render
  46634. * @param material The material used on the mesh
  46635. * @returns true if it can be rendered otherwise false
  46636. */
  46637. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  46638. /**
  46639. * Implementation specific of rendering the generating effect on the main canvas.
  46640. * @param effect The effect used to render through
  46641. */
  46642. protected _internalRender(effect: Effect): void;
  46643. /**
  46644. * Sets the required values for both the emissive texture and and the main color.
  46645. */
  46646. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  46647. /**
  46648. * Returns true if the mesh should render, otherwise false.
  46649. * @param mesh The mesh to render
  46650. * @returns true if it should render otherwise false
  46651. */
  46652. protected _shouldRenderMesh(mesh: Mesh): boolean;
  46653. /**
  46654. * Adds specific effects defines.
  46655. * @param defines The defines to add specifics to.
  46656. */
  46657. protected _addCustomEffectDefines(defines: string[]): void;
  46658. /**
  46659. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  46660. * @param mesh The mesh to exclude from the glow layer
  46661. */
  46662. addExcludedMesh(mesh: Mesh): void;
  46663. /**
  46664. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  46665. * @param mesh The mesh to remove
  46666. */
  46667. removeExcludedMesh(mesh: Mesh): void;
  46668. /**
  46669. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  46670. * @param mesh The mesh to include in the glow layer
  46671. */
  46672. addIncludedOnlyMesh(mesh: Mesh): void;
  46673. /**
  46674. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  46675. * @param mesh The mesh to remove
  46676. */
  46677. removeIncludedOnlyMesh(mesh: Mesh): void;
  46678. /**
  46679. * Determine if a given mesh will be used in the glow layer
  46680. * @param mesh The mesh to test
  46681. * @returns true if the mesh will be highlighted by the current glow layer
  46682. */
  46683. hasMesh(mesh: AbstractMesh): boolean;
  46684. /**
  46685. * Free any resources and references associated to a mesh.
  46686. * Internal use
  46687. * @param mesh The mesh to free.
  46688. * @hidden
  46689. */
  46690. _disposeMesh(mesh: Mesh): void;
  46691. /**
  46692. * Gets the class name of the effect layer
  46693. * @returns the string with the class name of the effect layer
  46694. */
  46695. getClassName(): string;
  46696. /**
  46697. * Serializes this glow layer
  46698. * @returns a serialized glow layer object
  46699. */
  46700. serialize(): any;
  46701. /**
  46702. * Creates a Glow Layer from parsed glow layer data
  46703. * @param parsedGlowLayer defines glow layer data
  46704. * @param scene defines the current scene
  46705. * @param rootUrl defines the root URL containing the glow layer information
  46706. * @returns a parsed Glow Layer
  46707. */
  46708. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  46709. }
  46710. }
  46711. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  46712. /** @hidden */
  46713. export var glowBlurPostProcessPixelShader: {
  46714. name: string;
  46715. shader: string;
  46716. };
  46717. }
  46718. declare module "babylonjs/Layers/highlightLayer" {
  46719. import { Observable } from "babylonjs/Misc/observable";
  46720. import { Nullable } from "babylonjs/types";
  46721. import { Camera } from "babylonjs/Cameras/camera";
  46722. import { Scene } from "babylonjs/scene";
  46723. import { Color3, Color4 } from "babylonjs/Maths/math";
  46724. import { SubMesh } from "babylonjs/Meshes/subMesh";
  46725. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46726. import { Mesh } from "babylonjs/Meshes/mesh";
  46727. import { Effect } from "babylonjs/Materials/effect";
  46728. import { Material } from "babylonjs/Materials/material";
  46729. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  46730. import "babylonjs/Shaders/glowMapMerge.fragment";
  46731. import "babylonjs/Shaders/glowMapMerge.vertex";
  46732. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  46733. module "babylonjs/abstractScene" {
  46734. interface AbstractScene {
  46735. /**
  46736. * Return a the first highlight layer of the scene with a given name.
  46737. * @param name The name of the highlight layer to look for.
  46738. * @return The highlight layer if found otherwise null.
  46739. */
  46740. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  46741. }
  46742. }
  46743. /**
  46744. * Highlight layer options. This helps customizing the behaviour
  46745. * of the highlight layer.
  46746. */
  46747. export interface IHighlightLayerOptions {
  46748. /**
  46749. * Multiplication factor apply to the canvas size to compute the render target size
  46750. * used to generated the glowing objects (the smaller the faster).
  46751. */
  46752. mainTextureRatio: number;
  46753. /**
  46754. * Enforces a fixed size texture to ensure resize independant blur.
  46755. */
  46756. mainTextureFixedSize?: number;
  46757. /**
  46758. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  46759. * of the picture to blur (the smaller the faster).
  46760. */
  46761. blurTextureSizeRatio: number;
  46762. /**
  46763. * How big in texel of the blur texture is the vertical blur.
  46764. */
  46765. blurVerticalSize: number;
  46766. /**
  46767. * How big in texel of the blur texture is the horizontal blur.
  46768. */
  46769. blurHorizontalSize: number;
  46770. /**
  46771. * Alpha blending mode used to apply the blur. Default is combine.
  46772. */
  46773. alphaBlendingMode: number;
  46774. /**
  46775. * The camera attached to the layer.
  46776. */
  46777. camera: Nullable<Camera>;
  46778. /**
  46779. * Should we display highlight as a solid stroke?
  46780. */
  46781. isStroke?: boolean;
  46782. /**
  46783. * The rendering group to draw the layer in.
  46784. */
  46785. renderingGroupId: number;
  46786. }
  46787. /**
  46788. * The highlight layer Helps adding a glow effect around a mesh.
  46789. *
  46790. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  46791. * glowy meshes to your scene.
  46792. *
  46793. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  46794. */
  46795. export class HighlightLayer extends EffectLayer {
  46796. name: string;
  46797. /**
  46798. * Effect Name of the highlight layer.
  46799. */
  46800. static readonly EffectName: string;
  46801. /**
  46802. * The neutral color used during the preparation of the glow effect.
  46803. * This is black by default as the blend operation is a blend operation.
  46804. */
  46805. static NeutralColor: Color4;
  46806. /**
  46807. * Stencil value used for glowing meshes.
  46808. */
  46809. static GlowingMeshStencilReference: number;
  46810. /**
  46811. * Stencil value used for the other meshes in the scene.
  46812. */
  46813. static NormalMeshStencilReference: number;
  46814. /**
  46815. * Specifies whether or not the inner glow is ACTIVE in the layer.
  46816. */
  46817. innerGlow: boolean;
  46818. /**
  46819. * Specifies whether or not the outer glow is ACTIVE in the layer.
  46820. */
  46821. outerGlow: boolean;
  46822. /**
  46823. * Specifies the horizontal size of the blur.
  46824. */
  46825. /**
  46826. * Gets the horizontal size of the blur.
  46827. */
  46828. blurHorizontalSize: number;
  46829. /**
  46830. * Specifies the vertical size of the blur.
  46831. */
  46832. /**
  46833. * Gets the vertical size of the blur.
  46834. */
  46835. blurVerticalSize: number;
  46836. /**
  46837. * An event triggered when the highlight layer is being blurred.
  46838. */
  46839. onBeforeBlurObservable: Observable<HighlightLayer>;
  46840. /**
  46841. * An event triggered when the highlight layer has been blurred.
  46842. */
  46843. onAfterBlurObservable: Observable<HighlightLayer>;
  46844. private _instanceGlowingMeshStencilReference;
  46845. private _options;
  46846. private _downSamplePostprocess;
  46847. private _horizontalBlurPostprocess;
  46848. private _verticalBlurPostprocess;
  46849. private _blurTexture;
  46850. private _meshes;
  46851. private _excludedMeshes;
  46852. /**
  46853. * Instantiates a new highlight Layer and references it to the scene..
  46854. * @param name The name of the layer
  46855. * @param scene The scene to use the layer in
  46856. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  46857. */
  46858. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  46859. /**
  46860. * Get the effect name of the layer.
  46861. * @return The effect name
  46862. */
  46863. getEffectName(): string;
  46864. /**
  46865. * Create the merge effect. This is the shader use to blit the information back
  46866. * to the main canvas at the end of the scene rendering.
  46867. */
  46868. protected _createMergeEffect(): Effect;
  46869. /**
  46870. * Creates the render target textures and post processes used in the highlight layer.
  46871. */
  46872. protected _createTextureAndPostProcesses(): void;
  46873. /**
  46874. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  46875. */
  46876. needStencil(): boolean;
  46877. /**
  46878. * Checks for the readiness of the element composing the layer.
  46879. * @param subMesh the mesh to check for
  46880. * @param useInstances specify wether or not to use instances to render the mesh
  46881. * @param emissiveTexture the associated emissive texture used to generate the glow
  46882. * @return true if ready otherwise, false
  46883. */
  46884. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  46885. /**
  46886. * Implementation specific of rendering the generating effect on the main canvas.
  46887. * @param effect The effect used to render through
  46888. */
  46889. protected _internalRender(effect: Effect): void;
  46890. /**
  46891. * Returns true if the layer contains information to display, otherwise false.
  46892. */
  46893. shouldRender(): boolean;
  46894. /**
  46895. * Returns true if the mesh should render, otherwise false.
  46896. * @param mesh The mesh to render
  46897. * @returns true if it should render otherwise false
  46898. */
  46899. protected _shouldRenderMesh(mesh: Mesh): boolean;
  46900. /**
  46901. * Sets the required values for both the emissive texture and and the main color.
  46902. */
  46903. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  46904. /**
  46905. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  46906. * @param mesh The mesh to exclude from the highlight layer
  46907. */
  46908. addExcludedMesh(mesh: Mesh): void;
  46909. /**
  46910. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  46911. * @param mesh The mesh to highlight
  46912. */
  46913. removeExcludedMesh(mesh: Mesh): void;
  46914. /**
  46915. * Determine if a given mesh will be highlighted by the current HighlightLayer
  46916. * @param mesh mesh to test
  46917. * @returns true if the mesh will be highlighted by the current HighlightLayer
  46918. */
  46919. hasMesh(mesh: AbstractMesh): boolean;
  46920. /**
  46921. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  46922. * @param mesh The mesh to highlight
  46923. * @param color The color of the highlight
  46924. * @param glowEmissiveOnly Extract the glow from the emissive texture
  46925. */
  46926. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  46927. /**
  46928. * Remove a mesh from the highlight layer in order to make it stop glowing.
  46929. * @param mesh The mesh to highlight
  46930. */
  46931. removeMesh(mesh: Mesh): void;
  46932. /**
  46933. * Force the stencil to the normal expected value for none glowing parts
  46934. */
  46935. private _defaultStencilReference;
  46936. /**
  46937. * Free any resources and references associated to a mesh.
  46938. * Internal use
  46939. * @param mesh The mesh to free.
  46940. * @hidden
  46941. */
  46942. _disposeMesh(mesh: Mesh): void;
  46943. /**
  46944. * Dispose the highlight layer and free resources.
  46945. */
  46946. dispose(): void;
  46947. /**
  46948. * Gets the class name of the effect layer
  46949. * @returns the string with the class name of the effect layer
  46950. */
  46951. getClassName(): string;
  46952. /**
  46953. * Serializes this Highlight layer
  46954. * @returns a serialized Highlight layer object
  46955. */
  46956. serialize(): any;
  46957. /**
  46958. * Creates a Highlight layer from parsed Highlight layer data
  46959. * @param parsedHightlightLayer defines the Highlight layer data
  46960. * @param scene defines the current scene
  46961. * @param rootUrl defines the root URL containing the Highlight layer information
  46962. * @returns a parsed Highlight layer
  46963. */
  46964. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  46965. }
  46966. }
  46967. declare module "babylonjs/Layers/index" {
  46968. export * from "babylonjs/Layers/effectLayer";
  46969. export * from "babylonjs/Layers/effectLayerSceneComponent";
  46970. export * from "babylonjs/Layers/glowLayer";
  46971. export * from "babylonjs/Layers/highlightLayer";
  46972. export * from "babylonjs/Layers/layer";
  46973. export * from "babylonjs/Layers/layerSceneComponent";
  46974. }
  46975. declare module "babylonjs/Shaders/lensFlare.fragment" {
  46976. /** @hidden */
  46977. export var lensFlarePixelShader: {
  46978. name: string;
  46979. shader: string;
  46980. };
  46981. }
  46982. declare module "babylonjs/Shaders/lensFlare.vertex" {
  46983. /** @hidden */
  46984. export var lensFlareVertexShader: {
  46985. name: string;
  46986. shader: string;
  46987. };
  46988. }
  46989. declare module "babylonjs/LensFlares/lensFlareSystem" {
  46990. import { Scene } from "babylonjs/scene";
  46991. import { Vector3, Viewport } from "babylonjs/Maths/math";
  46992. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46993. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  46994. import "babylonjs/Shaders/lensFlare.fragment";
  46995. import "babylonjs/Shaders/lensFlare.vertex";
  46996. /**
  46997. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  46998. * It is usually composed of several `lensFlare`.
  46999. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47000. */
  47001. export class LensFlareSystem {
  47002. /**
  47003. * Define the name of the lens flare system
  47004. */
  47005. name: string;
  47006. /**
  47007. * List of lens flares used in this system.
  47008. */
  47009. lensFlares: LensFlare[];
  47010. /**
  47011. * Define a limit from the border the lens flare can be visible.
  47012. */
  47013. borderLimit: number;
  47014. /**
  47015. * Define a viewport border we do not want to see the lens flare in.
  47016. */
  47017. viewportBorder: number;
  47018. /**
  47019. * Define a predicate which could limit the list of meshes able to occlude the effect.
  47020. */
  47021. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  47022. /**
  47023. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  47024. */
  47025. layerMask: number;
  47026. /**
  47027. * Define the id of the lens flare system in the scene.
  47028. * (equal to name by default)
  47029. */
  47030. id: string;
  47031. private _scene;
  47032. private _emitter;
  47033. private _vertexBuffers;
  47034. private _indexBuffer;
  47035. private _effect;
  47036. private _positionX;
  47037. private _positionY;
  47038. private _isEnabled;
  47039. /** @hidden */
  47040. static _SceneComponentInitialization: (scene: Scene) => void;
  47041. /**
  47042. * Instantiates a lens flare system.
  47043. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  47044. * It is usually composed of several `lensFlare`.
  47045. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47046. * @param name Define the name of the lens flare system in the scene
  47047. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  47048. * @param scene Define the scene the lens flare system belongs to
  47049. */
  47050. constructor(
  47051. /**
  47052. * Define the name of the lens flare system
  47053. */
  47054. name: string, emitter: any, scene: Scene);
  47055. /**
  47056. * Define if the lens flare system is enabled.
  47057. */
  47058. isEnabled: boolean;
  47059. /**
  47060. * Get the scene the effects belongs to.
  47061. * @returns the scene holding the lens flare system
  47062. */
  47063. getScene(): Scene;
  47064. /**
  47065. * Get the emitter of the lens flare system.
  47066. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  47067. * @returns the emitter of the lens flare system
  47068. */
  47069. getEmitter(): any;
  47070. /**
  47071. * Set the emitter of the lens flare system.
  47072. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  47073. * @param newEmitter Define the new emitter of the system
  47074. */
  47075. setEmitter(newEmitter: any): void;
  47076. /**
  47077. * Get the lens flare system emitter position.
  47078. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  47079. * @returns the position
  47080. */
  47081. getEmitterPosition(): Vector3;
  47082. /**
  47083. * @hidden
  47084. */
  47085. computeEffectivePosition(globalViewport: Viewport): boolean;
  47086. /** @hidden */
  47087. _isVisible(): boolean;
  47088. /**
  47089. * @hidden
  47090. */
  47091. render(): boolean;
  47092. /**
  47093. * Dispose and release the lens flare with its associated resources.
  47094. */
  47095. dispose(): void;
  47096. /**
  47097. * Parse a lens flare system from a JSON repressentation
  47098. * @param parsedLensFlareSystem Define the JSON to parse
  47099. * @param scene Define the scene the parsed system should be instantiated in
  47100. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  47101. * @returns the parsed system
  47102. */
  47103. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  47104. /**
  47105. * Serialize the current Lens Flare System into a JSON representation.
  47106. * @returns the serialized JSON
  47107. */
  47108. serialize(): any;
  47109. }
  47110. }
  47111. declare module "babylonjs/LensFlares/lensFlare" {
  47112. import { Nullable } from "babylonjs/types";
  47113. import { Color3 } from "babylonjs/Maths/math";
  47114. import { Texture } from "babylonjs/Materials/Textures/texture";
  47115. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  47116. /**
  47117. * This represents one of the lens effect in a `lensFlareSystem`.
  47118. * It controls one of the indiviual texture used in the effect.
  47119. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47120. */
  47121. export class LensFlare {
  47122. /**
  47123. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  47124. */
  47125. size: number;
  47126. /**
  47127. * 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.
  47128. */
  47129. position: number;
  47130. /**
  47131. * Define the lens color.
  47132. */
  47133. color: Color3;
  47134. /**
  47135. * Define the lens texture.
  47136. */
  47137. texture: Nullable<Texture>;
  47138. /**
  47139. * Define the alpha mode to render this particular lens.
  47140. */
  47141. alphaMode: number;
  47142. private _system;
  47143. /**
  47144. * Creates a new Lens Flare.
  47145. * This represents one of the lens effect in a `lensFlareSystem`.
  47146. * It controls one of the indiviual texture used in the effect.
  47147. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47148. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  47149. * @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.
  47150. * @param color Define the lens color
  47151. * @param imgUrl Define the lens texture url
  47152. * @param system Define the `lensFlareSystem` this flare is part of
  47153. * @returns The newly created Lens Flare
  47154. */
  47155. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  47156. /**
  47157. * Instantiates a new Lens Flare.
  47158. * This represents one of the lens effect in a `lensFlareSystem`.
  47159. * It controls one of the indiviual texture used in the effect.
  47160. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47161. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  47162. * @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.
  47163. * @param color Define the lens color
  47164. * @param imgUrl Define the lens texture url
  47165. * @param system Define the `lensFlareSystem` this flare is part of
  47166. */
  47167. constructor(
  47168. /**
  47169. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  47170. */
  47171. size: number,
  47172. /**
  47173. * 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.
  47174. */
  47175. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  47176. /**
  47177. * Dispose and release the lens flare with its associated resources.
  47178. */
  47179. dispose(): void;
  47180. }
  47181. }
  47182. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  47183. import { Nullable } from "babylonjs/types";
  47184. import { Scene } from "babylonjs/scene";
  47185. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  47186. import { AbstractScene } from "babylonjs/abstractScene";
  47187. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  47188. module "babylonjs/abstractScene" {
  47189. interface AbstractScene {
  47190. /**
  47191. * The list of lens flare system added to the scene
  47192. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47193. */
  47194. lensFlareSystems: Array<LensFlareSystem>;
  47195. /**
  47196. * Removes the given lens flare system from this scene.
  47197. * @param toRemove The lens flare system to remove
  47198. * @returns The index of the removed lens flare system
  47199. */
  47200. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  47201. /**
  47202. * Adds the given lens flare system to this scene
  47203. * @param newLensFlareSystem The lens flare system to add
  47204. */
  47205. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  47206. /**
  47207. * Gets a lens flare system using its name
  47208. * @param name defines the name to look for
  47209. * @returns the lens flare system or null if not found
  47210. */
  47211. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  47212. /**
  47213. * Gets a lens flare system using its id
  47214. * @param id defines the id to look for
  47215. * @returns the lens flare system or null if not found
  47216. */
  47217. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  47218. }
  47219. }
  47220. /**
  47221. * Defines the lens flare scene component responsible to manage any lens flares
  47222. * in a given scene.
  47223. */
  47224. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  47225. /**
  47226. * The component name helpfull to identify the component in the list of scene components.
  47227. */
  47228. readonly name: string;
  47229. /**
  47230. * The scene the component belongs to.
  47231. */
  47232. scene: Scene;
  47233. /**
  47234. * Creates a new instance of the component for the given scene
  47235. * @param scene Defines the scene to register the component in
  47236. */
  47237. constructor(scene: Scene);
  47238. /**
  47239. * Registers the component in a given scene
  47240. */
  47241. register(): void;
  47242. /**
  47243. * Rebuilds the elements related to this component in case of
  47244. * context lost for instance.
  47245. */
  47246. rebuild(): void;
  47247. /**
  47248. * Adds all the element from the container to the scene
  47249. * @param container the container holding the elements
  47250. */
  47251. addFromContainer(container: AbstractScene): void;
  47252. /**
  47253. * Removes all the elements in the container from the scene
  47254. * @param container contains the elements to remove
  47255. */
  47256. removeFromContainer(container: AbstractScene): void;
  47257. /**
  47258. * Serializes the component data to the specified json object
  47259. * @param serializationObject The object to serialize to
  47260. */
  47261. serialize(serializationObject: any): void;
  47262. /**
  47263. * Disposes the component and the associated ressources.
  47264. */
  47265. dispose(): void;
  47266. private _draw;
  47267. }
  47268. }
  47269. declare module "babylonjs/LensFlares/index" {
  47270. export * from "babylonjs/LensFlares/lensFlare";
  47271. export * from "babylonjs/LensFlares/lensFlareSystem";
  47272. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  47273. }
  47274. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  47275. import { Scene } from "babylonjs/scene";
  47276. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  47277. import { AbstractScene } from "babylonjs/abstractScene";
  47278. /**
  47279. * Defines the shadow generator component responsible to manage any shadow generators
  47280. * in a given scene.
  47281. */
  47282. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  47283. /**
  47284. * The component name helpfull to identify the component in the list of scene components.
  47285. */
  47286. readonly name: string;
  47287. /**
  47288. * The scene the component belongs to.
  47289. */
  47290. scene: Scene;
  47291. /**
  47292. * Creates a new instance of the component for the given scene
  47293. * @param scene Defines the scene to register the component in
  47294. */
  47295. constructor(scene: Scene);
  47296. /**
  47297. * Registers the component in a given scene
  47298. */
  47299. register(): void;
  47300. /**
  47301. * Rebuilds the elements related to this component in case of
  47302. * context lost for instance.
  47303. */
  47304. rebuild(): void;
  47305. /**
  47306. * Serializes the component data to the specified json object
  47307. * @param serializationObject The object to serialize to
  47308. */
  47309. serialize(serializationObject: any): void;
  47310. /**
  47311. * Adds all the element from the container to the scene
  47312. * @param container the container holding the elements
  47313. */
  47314. addFromContainer(container: AbstractScene): void;
  47315. /**
  47316. * Removes all the elements in the container from the scene
  47317. * @param container contains the elements to remove
  47318. */
  47319. removeFromContainer(container: AbstractScene): void;
  47320. /**
  47321. * Rebuilds the elements related to this component in case of
  47322. * context lost for instance.
  47323. */
  47324. dispose(): void;
  47325. private _gatherRenderTargets;
  47326. }
  47327. }
  47328. declare module "babylonjs/Lights/Shadows/index" {
  47329. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  47330. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  47331. }
  47332. declare module "babylonjs/Lights/directionalLight" {
  47333. import { Camera } from "babylonjs/Cameras/camera";
  47334. import { Scene } from "babylonjs/scene";
  47335. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  47336. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47337. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  47338. import { Effect } from "babylonjs/Materials/effect";
  47339. /**
  47340. * A directional light is defined by a direction (what a surprise!).
  47341. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  47342. * 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.
  47343. * Documentation: https://doc.babylonjs.com/babylon101/lights
  47344. */
  47345. export class DirectionalLight extends ShadowLight {
  47346. private _shadowFrustumSize;
  47347. /**
  47348. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  47349. */
  47350. /**
  47351. * Specifies a fix frustum size for the shadow generation.
  47352. */
  47353. shadowFrustumSize: number;
  47354. private _shadowOrthoScale;
  47355. /**
  47356. * Gets the shadow projection scale against the optimal computed one.
  47357. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  47358. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  47359. */
  47360. /**
  47361. * Sets the shadow projection scale against the optimal computed one.
  47362. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  47363. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  47364. */
  47365. shadowOrthoScale: number;
  47366. /**
  47367. * Automatically compute the projection matrix to best fit (including all the casters)
  47368. * on each frame.
  47369. */
  47370. autoUpdateExtends: boolean;
  47371. private _orthoLeft;
  47372. private _orthoRight;
  47373. private _orthoTop;
  47374. private _orthoBottom;
  47375. /**
  47376. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  47377. * The directional light is emitted from everywhere in the given direction.
  47378. * It can cast shadows.
  47379. * Documentation : https://doc.babylonjs.com/babylon101/lights
  47380. * @param name The friendly name of the light
  47381. * @param direction The direction of the light
  47382. * @param scene The scene the light belongs to
  47383. */
  47384. constructor(name: string, direction: Vector3, scene: Scene);
  47385. /**
  47386. * Returns the string "DirectionalLight".
  47387. * @return The class name
  47388. */
  47389. getClassName(): string;
  47390. /**
  47391. * Returns the integer 1.
  47392. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  47393. */
  47394. getTypeID(): number;
  47395. /**
  47396. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  47397. * Returns the DirectionalLight Shadow projection matrix.
  47398. */
  47399. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  47400. /**
  47401. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  47402. * Returns the DirectionalLight Shadow projection matrix.
  47403. */
  47404. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  47405. /**
  47406. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  47407. * Returns the DirectionalLight Shadow projection matrix.
  47408. */
  47409. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  47410. protected _buildUniformLayout(): void;
  47411. /**
  47412. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  47413. * @param effect The effect to update
  47414. * @param lightIndex The index of the light in the effect to update
  47415. * @returns The directional light
  47416. */
  47417. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  47418. /**
  47419. * Gets the minZ used for shadow according to both the scene and the light.
  47420. *
  47421. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  47422. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  47423. * @param activeCamera The camera we are returning the min for
  47424. * @returns the depth min z
  47425. */
  47426. getDepthMinZ(activeCamera: Camera): number;
  47427. /**
  47428. * Gets the maxZ used for shadow according to both the scene and the light.
  47429. *
  47430. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  47431. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  47432. * @param activeCamera The camera we are returning the max for
  47433. * @returns the depth max z
  47434. */
  47435. getDepthMaxZ(activeCamera: Camera): number;
  47436. /**
  47437. * Prepares the list of defines specific to the light type.
  47438. * @param defines the list of defines
  47439. * @param lightIndex defines the index of the light for the effect
  47440. */
  47441. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  47442. }
  47443. }
  47444. declare module "babylonjs/Lights/pointLight" {
  47445. import { Scene } from "babylonjs/scene";
  47446. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  47447. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47448. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  47449. import { Effect } from "babylonjs/Materials/effect";
  47450. /**
  47451. * A point light is a light defined by an unique point in world space.
  47452. * The light is emitted in every direction from this point.
  47453. * A good example of a point light is a standard light bulb.
  47454. * Documentation: https://doc.babylonjs.com/babylon101/lights
  47455. */
  47456. export class PointLight extends ShadowLight {
  47457. private _shadowAngle;
  47458. /**
  47459. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  47460. * This specifies what angle the shadow will use to be created.
  47461. *
  47462. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  47463. */
  47464. /**
  47465. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  47466. * This specifies what angle the shadow will use to be created.
  47467. *
  47468. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  47469. */
  47470. shadowAngle: number;
  47471. /**
  47472. * Gets the direction if it has been set.
  47473. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  47474. */
  47475. /**
  47476. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  47477. */
  47478. direction: Vector3;
  47479. /**
  47480. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  47481. * A PointLight emits the light in every direction.
  47482. * It can cast shadows.
  47483. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  47484. * ```javascript
  47485. * var pointLight = new PointLight("pl", camera.position, scene);
  47486. * ```
  47487. * Documentation : https://doc.babylonjs.com/babylon101/lights
  47488. * @param name The light friendly name
  47489. * @param position The position of the point light in the scene
  47490. * @param scene The scene the lights belongs to
  47491. */
  47492. constructor(name: string, position: Vector3, scene: Scene);
  47493. /**
  47494. * Returns the string "PointLight"
  47495. * @returns the class name
  47496. */
  47497. getClassName(): string;
  47498. /**
  47499. * Returns the integer 0.
  47500. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  47501. */
  47502. getTypeID(): number;
  47503. /**
  47504. * Specifies wether or not the shadowmap should be a cube texture.
  47505. * @returns true if the shadowmap needs to be a cube texture.
  47506. */
  47507. needCube(): boolean;
  47508. /**
  47509. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  47510. * @param faceIndex The index of the face we are computed the direction to generate shadow
  47511. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  47512. */
  47513. getShadowDirection(faceIndex?: number): Vector3;
  47514. /**
  47515. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  47516. * - fov = PI / 2
  47517. * - aspect ratio : 1.0
  47518. * - z-near and far equal to the active camera minZ and maxZ.
  47519. * Returns the PointLight.
  47520. */
  47521. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  47522. protected _buildUniformLayout(): void;
  47523. /**
  47524. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  47525. * @param effect The effect to update
  47526. * @param lightIndex The index of the light in the effect to update
  47527. * @returns The point light
  47528. */
  47529. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  47530. /**
  47531. * Prepares the list of defines specific to the light type.
  47532. * @param defines the list of defines
  47533. * @param lightIndex defines the index of the light for the effect
  47534. */
  47535. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  47536. }
  47537. }
  47538. declare module "babylonjs/Lights/spotLight" {
  47539. import { Nullable } from "babylonjs/types";
  47540. import { Scene } from "babylonjs/scene";
  47541. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  47542. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47543. import { Effect } from "babylonjs/Materials/effect";
  47544. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47545. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  47546. /**
  47547. * A spot light is defined by a position, a direction, an angle, and an exponent.
  47548. * These values define a cone of light starting from the position, emitting toward the direction.
  47549. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  47550. * and the exponent defines the speed of the decay of the light with distance (reach).
  47551. * Documentation: https://doc.babylonjs.com/babylon101/lights
  47552. */
  47553. export class SpotLight extends ShadowLight {
  47554. private _angle;
  47555. private _innerAngle;
  47556. private _cosHalfAngle;
  47557. private _lightAngleScale;
  47558. private _lightAngleOffset;
  47559. /**
  47560. * Gets the cone angle of the spot light in Radians.
  47561. */
  47562. /**
  47563. * Sets the cone angle of the spot light in Radians.
  47564. */
  47565. angle: number;
  47566. /**
  47567. * Only used in gltf falloff mode, this defines the angle where
  47568. * the directional falloff will start before cutting at angle which could be seen
  47569. * as outer angle.
  47570. */
  47571. /**
  47572. * Only used in gltf falloff mode, this defines the angle where
  47573. * the directional falloff will start before cutting at angle which could be seen
  47574. * as outer angle.
  47575. */
  47576. innerAngle: number;
  47577. private _shadowAngleScale;
  47578. /**
  47579. * Allows scaling the angle of the light for shadow generation only.
  47580. */
  47581. /**
  47582. * Allows scaling the angle of the light for shadow generation only.
  47583. */
  47584. shadowAngleScale: number;
  47585. /**
  47586. * The light decay speed with the distance from the emission spot.
  47587. */
  47588. exponent: number;
  47589. private _projectionTextureMatrix;
  47590. /**
  47591. * Allows reading the projecton texture
  47592. */
  47593. readonly projectionTextureMatrix: Matrix;
  47594. protected _projectionTextureLightNear: number;
  47595. /**
  47596. * Gets the near clip of the Spotlight for texture projection.
  47597. */
  47598. /**
  47599. * Sets the near clip of the Spotlight for texture projection.
  47600. */
  47601. projectionTextureLightNear: number;
  47602. protected _projectionTextureLightFar: number;
  47603. /**
  47604. * Gets the far clip of the Spotlight for texture projection.
  47605. */
  47606. /**
  47607. * Sets the far clip of the Spotlight for texture projection.
  47608. */
  47609. projectionTextureLightFar: number;
  47610. protected _projectionTextureUpDirection: Vector3;
  47611. /**
  47612. * Gets the Up vector of the Spotlight for texture projection.
  47613. */
  47614. /**
  47615. * Sets the Up vector of the Spotlight for texture projection.
  47616. */
  47617. projectionTextureUpDirection: Vector3;
  47618. private _projectionTexture;
  47619. /**
  47620. * Gets the projection texture of the light.
  47621. */
  47622. /**
  47623. * Sets the projection texture of the light.
  47624. */
  47625. projectionTexture: Nullable<BaseTexture>;
  47626. private _projectionTextureViewLightDirty;
  47627. private _projectionTextureProjectionLightDirty;
  47628. private _projectionTextureDirty;
  47629. private _projectionTextureViewTargetVector;
  47630. private _projectionTextureViewLightMatrix;
  47631. private _projectionTextureProjectionLightMatrix;
  47632. private _projectionTextureScalingMatrix;
  47633. /**
  47634. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  47635. * It can cast shadows.
  47636. * Documentation : https://doc.babylonjs.com/babylon101/lights
  47637. * @param name The light friendly name
  47638. * @param position The position of the spot light in the scene
  47639. * @param direction The direction of the light in the scene
  47640. * @param angle The cone angle of the light in Radians
  47641. * @param exponent The light decay speed with the distance from the emission spot
  47642. * @param scene The scene the lights belongs to
  47643. */
  47644. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  47645. /**
  47646. * Returns the string "SpotLight".
  47647. * @returns the class name
  47648. */
  47649. getClassName(): string;
  47650. /**
  47651. * Returns the integer 2.
  47652. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  47653. */
  47654. getTypeID(): number;
  47655. /**
  47656. * Overrides the direction setter to recompute the projection texture view light Matrix.
  47657. */
  47658. protected _setDirection(value: Vector3): void;
  47659. /**
  47660. * Overrides the position setter to recompute the projection texture view light Matrix.
  47661. */
  47662. protected _setPosition(value: Vector3): void;
  47663. /**
  47664. * 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.
  47665. * Returns the SpotLight.
  47666. */
  47667. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  47668. protected _computeProjectionTextureViewLightMatrix(): void;
  47669. protected _computeProjectionTextureProjectionLightMatrix(): void;
  47670. /**
  47671. * Main function for light texture projection matrix computing.
  47672. */
  47673. protected _computeProjectionTextureMatrix(): void;
  47674. protected _buildUniformLayout(): void;
  47675. private _computeAngleValues;
  47676. /**
  47677. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  47678. * @param effect The effect to update
  47679. * @param lightIndex The index of the light in the effect to update
  47680. * @returns The spot light
  47681. */
  47682. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  47683. /**
  47684. * Disposes the light and the associated resources.
  47685. */
  47686. dispose(): void;
  47687. /**
  47688. * Prepares the list of defines specific to the light type.
  47689. * @param defines the list of defines
  47690. * @param lightIndex defines the index of the light for the effect
  47691. */
  47692. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  47693. }
  47694. }
  47695. declare module "babylonjs/Lights/index" {
  47696. export * from "babylonjs/Lights/light";
  47697. export * from "babylonjs/Lights/shadowLight";
  47698. export * from "babylonjs/Lights/Shadows/index";
  47699. export * from "babylonjs/Lights/directionalLight";
  47700. export * from "babylonjs/Lights/hemisphericLight";
  47701. export * from "babylonjs/Lights/pointLight";
  47702. export * from "babylonjs/Lights/spotLight";
  47703. }
  47704. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  47705. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  47706. /**
  47707. * Header information of HDR texture files.
  47708. */
  47709. export interface HDRInfo {
  47710. /**
  47711. * The height of the texture in pixels.
  47712. */
  47713. height: number;
  47714. /**
  47715. * The width of the texture in pixels.
  47716. */
  47717. width: number;
  47718. /**
  47719. * The index of the beginning of the data in the binary file.
  47720. */
  47721. dataPosition: number;
  47722. }
  47723. /**
  47724. * This groups tools to convert HDR texture to native colors array.
  47725. */
  47726. export class HDRTools {
  47727. private static Ldexp;
  47728. private static Rgbe2float;
  47729. private static readStringLine;
  47730. /**
  47731. * Reads header information from an RGBE texture stored in a native array.
  47732. * More information on this format are available here:
  47733. * https://en.wikipedia.org/wiki/RGBE_image_format
  47734. *
  47735. * @param uint8array The binary file stored in native array.
  47736. * @return The header information.
  47737. */
  47738. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  47739. /**
  47740. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  47741. * This RGBE texture needs to store the information as a panorama.
  47742. *
  47743. * More information on this format are available here:
  47744. * https://en.wikipedia.org/wiki/RGBE_image_format
  47745. *
  47746. * @param buffer The binary file stored in an array buffer.
  47747. * @param size The expected size of the extracted cubemap.
  47748. * @return The Cube Map information.
  47749. */
  47750. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  47751. /**
  47752. * Returns the pixels data extracted from an RGBE texture.
  47753. * This pixels will be stored left to right up to down in the R G B order in one array.
  47754. *
  47755. * More information on this format are available here:
  47756. * https://en.wikipedia.org/wiki/RGBE_image_format
  47757. *
  47758. * @param uint8array The binary file stored in an array buffer.
  47759. * @param hdrInfo The header information of the file.
  47760. * @return The pixels data in RGB right to left up to down order.
  47761. */
  47762. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  47763. private static RGBE_ReadPixels_RLE;
  47764. }
  47765. }
  47766. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  47767. import { Nullable } from "babylonjs/types";
  47768. import { Scene } from "babylonjs/scene";
  47769. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  47770. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47771. /**
  47772. * This represents a texture coming from an HDR input.
  47773. *
  47774. * The only supported format is currently panorama picture stored in RGBE format.
  47775. * Example of such files can be found on HDRLib: http://hdrlib.com/
  47776. */
  47777. export class HDRCubeTexture extends BaseTexture {
  47778. private static _facesMapping;
  47779. private _generateHarmonics;
  47780. private _noMipmap;
  47781. private _textureMatrix;
  47782. private _size;
  47783. private _onLoad;
  47784. private _onError;
  47785. /**
  47786. * The texture URL.
  47787. */
  47788. url: string;
  47789. /**
  47790. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  47791. */
  47792. coordinatesMode: number;
  47793. protected _isBlocking: boolean;
  47794. /**
  47795. * Sets wether or not the texture is blocking during loading.
  47796. */
  47797. /**
  47798. * Gets wether or not the texture is blocking during loading.
  47799. */
  47800. isBlocking: boolean;
  47801. protected _rotationY: number;
  47802. /**
  47803. * Sets texture matrix rotation angle around Y axis in radians.
  47804. */
  47805. /**
  47806. * Gets texture matrix rotation angle around Y axis radians.
  47807. */
  47808. rotationY: number;
  47809. /**
  47810. * Gets or sets the center of the bounding box associated with the cube texture
  47811. * It must define where the camera used to render the texture was set
  47812. */
  47813. boundingBoxPosition: Vector3;
  47814. private _boundingBoxSize;
  47815. /**
  47816. * Gets or sets the size of the bounding box associated with the cube texture
  47817. * When defined, the cubemap will switch to local mode
  47818. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  47819. * @example https://www.babylonjs-playground.com/#RNASML
  47820. */
  47821. boundingBoxSize: Vector3;
  47822. /**
  47823. * Instantiates an HDRTexture from the following parameters.
  47824. *
  47825. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  47826. * @param scene The scene the texture will be used in
  47827. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  47828. * @param noMipmap Forces to not generate the mipmap if true
  47829. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  47830. * @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)
  47831. * @param reserved Reserved flag for internal use.
  47832. */
  47833. 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>);
  47834. /**
  47835. * Get the current class name of the texture useful for serialization or dynamic coding.
  47836. * @returns "HDRCubeTexture"
  47837. */
  47838. getClassName(): string;
  47839. /**
  47840. * Occurs when the file is raw .hdr file.
  47841. */
  47842. private loadTexture;
  47843. clone(): HDRCubeTexture;
  47844. delayLoad(): void;
  47845. /**
  47846. * Get the texture reflection matrix used to rotate/transform the reflection.
  47847. * @returns the reflection matrix
  47848. */
  47849. getReflectionTextureMatrix(): Matrix;
  47850. /**
  47851. * Set the texture reflection matrix used to rotate/transform the reflection.
  47852. * @param value Define the reflection matrix to set
  47853. */
  47854. setReflectionTextureMatrix(value: Matrix): void;
  47855. /**
  47856. * Parses a JSON representation of an HDR Texture in order to create the texture
  47857. * @param parsedTexture Define the JSON representation
  47858. * @param scene Define the scene the texture should be created in
  47859. * @param rootUrl Define the root url in case we need to load relative dependencies
  47860. * @returns the newly created texture after parsing
  47861. */
  47862. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  47863. serialize(): any;
  47864. }
  47865. }
  47866. declare module "babylonjs/Physics/physicsEngine" {
  47867. import { Nullable } from "babylonjs/types";
  47868. import { Vector3 } from "babylonjs/Maths/math";
  47869. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  47870. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  47871. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  47872. /**
  47873. * Class used to control physics engine
  47874. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  47875. */
  47876. export class PhysicsEngine implements IPhysicsEngine {
  47877. private _physicsPlugin;
  47878. /**
  47879. * Global value used to control the smallest number supported by the simulation
  47880. */
  47881. static Epsilon: number;
  47882. private _impostors;
  47883. private _joints;
  47884. /**
  47885. * Gets the gravity vector used by the simulation
  47886. */
  47887. gravity: Vector3;
  47888. /**
  47889. * Factory used to create the default physics plugin.
  47890. * @returns The default physics plugin
  47891. */
  47892. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  47893. /**
  47894. * Creates a new Physics Engine
  47895. * @param gravity defines the gravity vector used by the simulation
  47896. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  47897. */
  47898. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  47899. /**
  47900. * Sets the gravity vector used by the simulation
  47901. * @param gravity defines the gravity vector to use
  47902. */
  47903. setGravity(gravity: Vector3): void;
  47904. /**
  47905. * Set the time step of the physics engine.
  47906. * Default is 1/60.
  47907. * To slow it down, enter 1/600 for example.
  47908. * To speed it up, 1/30
  47909. * @param newTimeStep defines the new timestep to apply to this world.
  47910. */
  47911. setTimeStep(newTimeStep?: number): void;
  47912. /**
  47913. * Get the time step of the physics engine.
  47914. * @returns the current time step
  47915. */
  47916. getTimeStep(): number;
  47917. /**
  47918. * Release all resources
  47919. */
  47920. dispose(): void;
  47921. /**
  47922. * Gets the name of the current physics plugin
  47923. * @returns the name of the plugin
  47924. */
  47925. getPhysicsPluginName(): string;
  47926. /**
  47927. * Adding a new impostor for the impostor tracking.
  47928. * This will be done by the impostor itself.
  47929. * @param impostor the impostor to add
  47930. */
  47931. addImpostor(impostor: PhysicsImpostor): void;
  47932. /**
  47933. * Remove an impostor from the engine.
  47934. * This impostor and its mesh will not longer be updated by the physics engine.
  47935. * @param impostor the impostor to remove
  47936. */
  47937. removeImpostor(impostor: PhysicsImpostor): void;
  47938. /**
  47939. * Add a joint to the physics engine
  47940. * @param mainImpostor defines the main impostor to which the joint is added.
  47941. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  47942. * @param joint defines the joint that will connect both impostors.
  47943. */
  47944. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  47945. /**
  47946. * Removes a joint from the simulation
  47947. * @param mainImpostor defines the impostor used with the joint
  47948. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  47949. * @param joint defines the joint to remove
  47950. */
  47951. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  47952. /**
  47953. * Called by the scene. No need to call it.
  47954. * @param delta defines the timespam between frames
  47955. */
  47956. _step(delta: number): void;
  47957. /**
  47958. * Gets the current plugin used to run the simulation
  47959. * @returns current plugin
  47960. */
  47961. getPhysicsPlugin(): IPhysicsEnginePlugin;
  47962. /**
  47963. * Gets the list of physic impostors
  47964. * @returns an array of PhysicsImpostor
  47965. */
  47966. getImpostors(): Array<PhysicsImpostor>;
  47967. /**
  47968. * Gets the impostor for a physics enabled object
  47969. * @param object defines the object impersonated by the impostor
  47970. * @returns the PhysicsImpostor or null if not found
  47971. */
  47972. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  47973. /**
  47974. * Gets the impostor for a physics body object
  47975. * @param body defines physics body used by the impostor
  47976. * @returns the PhysicsImpostor or null if not found
  47977. */
  47978. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  47979. }
  47980. }
  47981. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  47982. import { Nullable } from "babylonjs/types";
  47983. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  47984. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47985. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  47986. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  47987. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  47988. /** @hidden */
  47989. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  47990. private _useDeltaForWorldStep;
  47991. world: any;
  47992. name: string;
  47993. private _physicsMaterials;
  47994. private _fixedTimeStep;
  47995. BJSCANNON: any;
  47996. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  47997. setGravity(gravity: Vector3): void;
  47998. setTimeStep(timeStep: number): void;
  47999. getTimeStep(): number;
  48000. executeStep(delta: number): void;
  48001. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48002. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48003. generatePhysicsBody(impostor: PhysicsImpostor): void;
  48004. private _processChildMeshes;
  48005. removePhysicsBody(impostor: PhysicsImpostor): void;
  48006. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  48007. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  48008. private _addMaterial;
  48009. private _checkWithEpsilon;
  48010. private _createShape;
  48011. private _createHeightmap;
  48012. private _minus90X;
  48013. private _plus90X;
  48014. private _tmpPosition;
  48015. private _tmpDeltaPosition;
  48016. private _tmpUnityRotation;
  48017. private _updatePhysicsBodyTransformation;
  48018. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  48019. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  48020. isSupported(): boolean;
  48021. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48022. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48023. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48024. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48025. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  48026. getBodyMass(impostor: PhysicsImpostor): number;
  48027. getBodyFriction(impostor: PhysicsImpostor): number;
  48028. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  48029. getBodyRestitution(impostor: PhysicsImpostor): number;
  48030. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  48031. sleepBody(impostor: PhysicsImpostor): void;
  48032. wakeUpBody(impostor: PhysicsImpostor): void;
  48033. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  48034. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  48035. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  48036. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  48037. getRadius(impostor: PhysicsImpostor): number;
  48038. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  48039. dispose(): void;
  48040. private _extendNamespace;
  48041. }
  48042. }
  48043. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  48044. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  48045. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  48046. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  48047. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48048. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  48049. import { Nullable } from "babylonjs/types";
  48050. /** @hidden */
  48051. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  48052. world: any;
  48053. name: string;
  48054. BJSOIMO: any;
  48055. constructor(iterations?: number, oimoInjection?: any);
  48056. setGravity(gravity: Vector3): void;
  48057. setTimeStep(timeStep: number): void;
  48058. getTimeStep(): number;
  48059. private _tmpImpostorsArray;
  48060. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  48061. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48062. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48063. generatePhysicsBody(impostor: PhysicsImpostor): void;
  48064. private _tmpPositionVector;
  48065. removePhysicsBody(impostor: PhysicsImpostor): void;
  48066. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  48067. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  48068. isSupported(): boolean;
  48069. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  48070. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  48071. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48072. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48073. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48074. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48075. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  48076. getBodyMass(impostor: PhysicsImpostor): number;
  48077. getBodyFriction(impostor: PhysicsImpostor): number;
  48078. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  48079. getBodyRestitution(impostor: PhysicsImpostor): number;
  48080. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  48081. sleepBody(impostor: PhysicsImpostor): void;
  48082. wakeUpBody(impostor: PhysicsImpostor): void;
  48083. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  48084. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  48085. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  48086. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  48087. getRadius(impostor: PhysicsImpostor): number;
  48088. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  48089. dispose(): void;
  48090. }
  48091. }
  48092. declare module "babylonjs/Probes/reflectionProbe" {
  48093. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  48094. import { Vector3 } from "babylonjs/Maths/math";
  48095. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48096. import { Nullable } from "babylonjs/types";
  48097. import { Scene } from "babylonjs/scene";
  48098. module "babylonjs/abstractScene" {
  48099. interface AbstractScene {
  48100. /**
  48101. * The list of reflection probes added to the scene
  48102. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  48103. */
  48104. reflectionProbes: Array<ReflectionProbe>;
  48105. /**
  48106. * Removes the given reflection probe from this scene.
  48107. * @param toRemove The reflection probe to remove
  48108. * @returns The index of the removed reflection probe
  48109. */
  48110. removeReflectionProbe(toRemove: ReflectionProbe): number;
  48111. /**
  48112. * Adds the given reflection probe to this scene.
  48113. * @param newReflectionProbe The reflection probe to add
  48114. */
  48115. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  48116. }
  48117. }
  48118. /**
  48119. * Class used to generate realtime reflection / refraction cube textures
  48120. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  48121. */
  48122. export class ReflectionProbe {
  48123. /** defines the name of the probe */
  48124. name: string;
  48125. private _scene;
  48126. private _renderTargetTexture;
  48127. private _projectionMatrix;
  48128. private _viewMatrix;
  48129. private _target;
  48130. private _add;
  48131. private _attachedMesh;
  48132. private _invertYAxis;
  48133. /** Gets or sets probe position (center of the cube map) */
  48134. position: Vector3;
  48135. /**
  48136. * Creates a new reflection probe
  48137. * @param name defines the name of the probe
  48138. * @param size defines the texture resolution (for each face)
  48139. * @param scene defines the hosting scene
  48140. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  48141. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  48142. */
  48143. constructor(
  48144. /** defines the name of the probe */
  48145. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  48146. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  48147. samples: number;
  48148. /** Gets or sets the refresh rate to use (on every frame by default) */
  48149. refreshRate: number;
  48150. /**
  48151. * Gets the hosting scene
  48152. * @returns a Scene
  48153. */
  48154. getScene(): Scene;
  48155. /** Gets the internal CubeTexture used to render to */
  48156. readonly cubeTexture: RenderTargetTexture;
  48157. /** Gets the list of meshes to render */
  48158. readonly renderList: Nullable<AbstractMesh[]>;
  48159. /**
  48160. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  48161. * @param mesh defines the mesh to attach to
  48162. */
  48163. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  48164. /**
  48165. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  48166. * @param renderingGroupId The rendering group id corresponding to its index
  48167. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  48168. */
  48169. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  48170. /**
  48171. * Clean all associated resources
  48172. */
  48173. dispose(): void;
  48174. /**
  48175. * Converts the reflection probe information to a readable string for debug purpose.
  48176. * @param fullDetails Supports for multiple levels of logging within scene loading
  48177. * @returns the human readable reflection probe info
  48178. */
  48179. toString(fullDetails?: boolean): string;
  48180. /**
  48181. * Get the class name of the relfection probe.
  48182. * @returns "ReflectionProbe"
  48183. */
  48184. getClassName(): string;
  48185. /**
  48186. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  48187. * @returns The JSON representation of the texture
  48188. */
  48189. serialize(): any;
  48190. /**
  48191. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  48192. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  48193. * @param scene Define the scene the parsed reflection probe should be instantiated in
  48194. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  48195. * @returns The parsed reflection probe if successful
  48196. */
  48197. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  48198. }
  48199. }
  48200. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  48201. /** @hidden */
  48202. export var _BabylonLoaderRegistered: boolean;
  48203. }
  48204. declare module "babylonjs/Loading/Plugins/index" {
  48205. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  48206. }
  48207. declare module "babylonjs/Loading/index" {
  48208. export * from "babylonjs/Loading/loadingScreen";
  48209. export * from "babylonjs/Loading/Plugins/index";
  48210. export * from "babylonjs/Loading/sceneLoader";
  48211. export * from "babylonjs/Loading/sceneLoaderFlags";
  48212. }
  48213. declare module "babylonjs/Materials/Background/index" {
  48214. export * from "babylonjs/Materials/Background/backgroundMaterial";
  48215. }
  48216. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  48217. import { Scene } from "babylonjs/scene";
  48218. import { Color3 } from "babylonjs/Maths/math";
  48219. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  48220. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48221. /**
  48222. * The Physically based simple base material of BJS.
  48223. *
  48224. * This enables better naming and convention enforcements on top of the pbrMaterial.
  48225. * It is used as the base class for both the specGloss and metalRough conventions.
  48226. */
  48227. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  48228. /**
  48229. * Number of Simultaneous lights allowed on the material.
  48230. */
  48231. maxSimultaneousLights: number;
  48232. /**
  48233. * If sets to true, disables all the lights affecting the material.
  48234. */
  48235. disableLighting: boolean;
  48236. /**
  48237. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  48238. */
  48239. environmentTexture: BaseTexture;
  48240. /**
  48241. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  48242. */
  48243. invertNormalMapX: boolean;
  48244. /**
  48245. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  48246. */
  48247. invertNormalMapY: boolean;
  48248. /**
  48249. * Normal map used in the model.
  48250. */
  48251. normalTexture: BaseTexture;
  48252. /**
  48253. * Emissivie color used to self-illuminate the model.
  48254. */
  48255. emissiveColor: Color3;
  48256. /**
  48257. * Emissivie texture used to self-illuminate the model.
  48258. */
  48259. emissiveTexture: BaseTexture;
  48260. /**
  48261. * Occlusion Channel Strenght.
  48262. */
  48263. occlusionStrength: number;
  48264. /**
  48265. * Occlusion Texture of the material (adding extra occlusion effects).
  48266. */
  48267. occlusionTexture: BaseTexture;
  48268. /**
  48269. * Defines the alpha limits in alpha test mode.
  48270. */
  48271. alphaCutOff: number;
  48272. /**
  48273. * Gets the current double sided mode.
  48274. */
  48275. /**
  48276. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  48277. */
  48278. doubleSided: boolean;
  48279. /**
  48280. * Stores the pre-calculated light information of a mesh in a texture.
  48281. */
  48282. lightmapTexture: BaseTexture;
  48283. /**
  48284. * If true, the light map contains occlusion information instead of lighting info.
  48285. */
  48286. useLightmapAsShadowmap: boolean;
  48287. /**
  48288. * Instantiates a new PBRMaterial instance.
  48289. *
  48290. * @param name The material name
  48291. * @param scene The scene the material will be use in.
  48292. */
  48293. constructor(name: string, scene: Scene);
  48294. getClassName(): string;
  48295. }
  48296. }
  48297. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  48298. import { Scene } from "babylonjs/scene";
  48299. import { Color3 } from "babylonjs/Maths/math";
  48300. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48301. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  48302. /**
  48303. * The PBR material of BJS following the metal roughness convention.
  48304. *
  48305. * This fits to the PBR convention in the GLTF definition:
  48306. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  48307. */
  48308. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  48309. /**
  48310. * The base color has two different interpretations depending on the value of metalness.
  48311. * When the material is a metal, the base color is the specific measured reflectance value
  48312. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  48313. * of the material.
  48314. */
  48315. baseColor: Color3;
  48316. /**
  48317. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  48318. * well as opacity information in the alpha channel.
  48319. */
  48320. baseTexture: BaseTexture;
  48321. /**
  48322. * Specifies the metallic scalar value of the material.
  48323. * Can also be used to scale the metalness values of the metallic texture.
  48324. */
  48325. metallic: number;
  48326. /**
  48327. * Specifies the roughness scalar value of the material.
  48328. * Can also be used to scale the roughness values of the metallic texture.
  48329. */
  48330. roughness: number;
  48331. /**
  48332. * Texture containing both the metallic value in the B channel and the
  48333. * roughness value in the G channel to keep better precision.
  48334. */
  48335. metallicRoughnessTexture: BaseTexture;
  48336. /**
  48337. * Instantiates a new PBRMetalRoughnessMaterial instance.
  48338. *
  48339. * @param name The material name
  48340. * @param scene The scene the material will be use in.
  48341. */
  48342. constructor(name: string, scene: Scene);
  48343. /**
  48344. * Return the currrent class name of the material.
  48345. */
  48346. getClassName(): string;
  48347. /**
  48348. * Makes a duplicate of the current material.
  48349. * @param name - name to use for the new material.
  48350. */
  48351. clone(name: string): PBRMetallicRoughnessMaterial;
  48352. /**
  48353. * Serialize the material to a parsable JSON object.
  48354. */
  48355. serialize(): any;
  48356. /**
  48357. * Parses a JSON object correponding to the serialize function.
  48358. */
  48359. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  48360. }
  48361. }
  48362. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  48363. import { Scene } from "babylonjs/scene";
  48364. import { Color3 } from "babylonjs/Maths/math";
  48365. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48366. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  48367. /**
  48368. * The PBR material of BJS following the specular glossiness convention.
  48369. *
  48370. * This fits to the PBR convention in the GLTF definition:
  48371. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  48372. */
  48373. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  48374. /**
  48375. * Specifies the diffuse color of the material.
  48376. */
  48377. diffuseColor: Color3;
  48378. /**
  48379. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  48380. * channel.
  48381. */
  48382. diffuseTexture: BaseTexture;
  48383. /**
  48384. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  48385. */
  48386. specularColor: Color3;
  48387. /**
  48388. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  48389. */
  48390. glossiness: number;
  48391. /**
  48392. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  48393. */
  48394. specularGlossinessTexture: BaseTexture;
  48395. /**
  48396. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  48397. *
  48398. * @param name The material name
  48399. * @param scene The scene the material will be use in.
  48400. */
  48401. constructor(name: string, scene: Scene);
  48402. /**
  48403. * Return the currrent class name of the material.
  48404. */
  48405. getClassName(): string;
  48406. /**
  48407. * Makes a duplicate of the current material.
  48408. * @param name - name to use for the new material.
  48409. */
  48410. clone(name: string): PBRSpecularGlossinessMaterial;
  48411. /**
  48412. * Serialize the material to a parsable JSON object.
  48413. */
  48414. serialize(): any;
  48415. /**
  48416. * Parses a JSON object correponding to the serialize function.
  48417. */
  48418. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  48419. }
  48420. }
  48421. declare module "babylonjs/Materials/PBR/index" {
  48422. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  48423. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  48424. export * from "babylonjs/Materials/PBR/pbrMaterial";
  48425. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  48426. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  48427. }
  48428. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  48429. import { Nullable } from "babylonjs/types";
  48430. import { Scene } from "babylonjs/scene";
  48431. import { Matrix } from "babylonjs/Maths/math";
  48432. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48433. /**
  48434. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  48435. * It can help converting any input color in a desired output one. This can then be used to create effects
  48436. * from sepia, black and white to sixties or futuristic rendering...
  48437. *
  48438. * The only supported format is currently 3dl.
  48439. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  48440. */
  48441. export class ColorGradingTexture extends BaseTexture {
  48442. /**
  48443. * The current texture matrix. (will always be identity in color grading texture)
  48444. */
  48445. private _textureMatrix;
  48446. /**
  48447. * The texture URL.
  48448. */
  48449. url: string;
  48450. /**
  48451. * Empty line regex stored for GC.
  48452. */
  48453. private static _noneEmptyLineRegex;
  48454. private _engine;
  48455. /**
  48456. * Instantiates a ColorGradingTexture from the following parameters.
  48457. *
  48458. * @param url The location of the color gradind data (currently only supporting 3dl)
  48459. * @param scene The scene the texture will be used in
  48460. */
  48461. constructor(url: string, scene: Scene);
  48462. /**
  48463. * Returns the texture matrix used in most of the material.
  48464. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  48465. */
  48466. getTextureMatrix(): Matrix;
  48467. /**
  48468. * Occurs when the file being loaded is a .3dl LUT file.
  48469. */
  48470. private load3dlTexture;
  48471. /**
  48472. * Starts the loading process of the texture.
  48473. */
  48474. private loadTexture;
  48475. /**
  48476. * Clones the color gradind texture.
  48477. */
  48478. clone(): ColorGradingTexture;
  48479. /**
  48480. * Called during delayed load for textures.
  48481. */
  48482. delayLoad(): void;
  48483. /**
  48484. * Parses a color grading texture serialized by Babylon.
  48485. * @param parsedTexture The texture information being parsedTexture
  48486. * @param scene The scene to load the texture in
  48487. * @param rootUrl The root url of the data assets to load
  48488. * @return A color gradind texture
  48489. */
  48490. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  48491. /**
  48492. * Serializes the LUT texture to json format.
  48493. */
  48494. serialize(): any;
  48495. }
  48496. }
  48497. declare module "babylonjs/Misc/dds" {
  48498. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  48499. import { Engine } from "babylonjs/Engines/engine";
  48500. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48501. import { Nullable } from "babylonjs/types";
  48502. import { Scene } from "babylonjs/scene";
  48503. /**
  48504. * Direct draw surface info
  48505. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  48506. */
  48507. export interface DDSInfo {
  48508. /**
  48509. * Width of the texture
  48510. */
  48511. width: number;
  48512. /**
  48513. * Width of the texture
  48514. */
  48515. height: number;
  48516. /**
  48517. * Number of Mipmaps for the texture
  48518. * @see https://en.wikipedia.org/wiki/Mipmap
  48519. */
  48520. mipmapCount: number;
  48521. /**
  48522. * If the textures format is a known fourCC format
  48523. * @see https://www.fourcc.org/
  48524. */
  48525. isFourCC: boolean;
  48526. /**
  48527. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  48528. */
  48529. isRGB: boolean;
  48530. /**
  48531. * If the texture is a lumincance format
  48532. */
  48533. isLuminance: boolean;
  48534. /**
  48535. * If this is a cube texture
  48536. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  48537. */
  48538. isCube: boolean;
  48539. /**
  48540. * If the texture is a compressed format eg. FOURCC_DXT1
  48541. */
  48542. isCompressed: boolean;
  48543. /**
  48544. * The dxgiFormat of the texture
  48545. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  48546. */
  48547. dxgiFormat: number;
  48548. /**
  48549. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  48550. */
  48551. textureType: number;
  48552. /**
  48553. * Sphericle polynomial created for the dds texture
  48554. */
  48555. sphericalPolynomial?: SphericalPolynomial;
  48556. }
  48557. /**
  48558. * Class used to provide DDS decompression tools
  48559. */
  48560. export class DDSTools {
  48561. /**
  48562. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  48563. */
  48564. static StoreLODInAlphaChannel: boolean;
  48565. /**
  48566. * Gets DDS information from an array buffer
  48567. * @param arrayBuffer defines the array buffer to read data from
  48568. * @returns the DDS information
  48569. */
  48570. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  48571. private static _FloatView;
  48572. private static _Int32View;
  48573. private static _ToHalfFloat;
  48574. private static _FromHalfFloat;
  48575. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  48576. private static _GetHalfFloatRGBAArrayBuffer;
  48577. private static _GetFloatRGBAArrayBuffer;
  48578. private static _GetFloatAsUIntRGBAArrayBuffer;
  48579. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  48580. private static _GetRGBAArrayBuffer;
  48581. private static _ExtractLongWordOrder;
  48582. private static _GetRGBArrayBuffer;
  48583. private static _GetLuminanceArrayBuffer;
  48584. /**
  48585. * Uploads DDS Levels to a Babylon Texture
  48586. * @hidden
  48587. */
  48588. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  48589. }
  48590. module "babylonjs/Engines/engine" {
  48591. interface Engine {
  48592. /**
  48593. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  48594. * @param rootUrl defines the url where the file to load is located
  48595. * @param scene defines the current scene
  48596. * @param lodScale defines scale to apply to the mip map selection
  48597. * @param lodOffset defines offset to apply to the mip map selection
  48598. * @param onLoad defines an optional callback raised when the texture is loaded
  48599. * @param onError defines an optional callback raised if there is an issue to load the texture
  48600. * @param format defines the format of the data
  48601. * @param forcedExtension defines the extension to use to pick the right loader
  48602. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  48603. * @returns the cube texture as an InternalTexture
  48604. */
  48605. 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;
  48606. }
  48607. }
  48608. }
  48609. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  48610. import { Nullable } from "babylonjs/types";
  48611. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48612. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  48613. /**
  48614. * Implementation of the DDS Texture Loader.
  48615. * @hidden
  48616. */
  48617. export class _DDSTextureLoader implements IInternalTextureLoader {
  48618. /**
  48619. * Defines wether the loader supports cascade loading the different faces.
  48620. */
  48621. readonly supportCascades: boolean;
  48622. /**
  48623. * This returns if the loader support the current file information.
  48624. * @param extension defines the file extension of the file being loaded
  48625. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48626. * @param fallback defines the fallback internal texture if any
  48627. * @param isBase64 defines whether the texture is encoded as a base64
  48628. * @param isBuffer defines whether the texture data are stored as a buffer
  48629. * @returns true if the loader can load the specified file
  48630. */
  48631. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48632. /**
  48633. * Transform the url before loading if required.
  48634. * @param rootUrl the url of the texture
  48635. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48636. * @returns the transformed texture
  48637. */
  48638. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48639. /**
  48640. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48641. * @param rootUrl the url of the texture
  48642. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48643. * @returns the fallback texture
  48644. */
  48645. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48646. /**
  48647. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48648. * @param data contains the texture data
  48649. * @param texture defines the BabylonJS internal texture
  48650. * @param createPolynomials will be true if polynomials have been requested
  48651. * @param onLoad defines the callback to trigger once the texture is ready
  48652. * @param onError defines the callback to trigger in case of error
  48653. */
  48654. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48655. /**
  48656. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48657. * @param data contains the texture data
  48658. * @param texture defines the BabylonJS internal texture
  48659. * @param callback defines the method to call once ready to upload
  48660. */
  48661. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  48662. }
  48663. }
  48664. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  48665. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  48666. /** @hidden */
  48667. export var rgbdEncodePixelShader: {
  48668. name: string;
  48669. shader: string;
  48670. };
  48671. }
  48672. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  48673. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  48674. /** @hidden */
  48675. export var rgbdDecodePixelShader: {
  48676. name: string;
  48677. shader: string;
  48678. };
  48679. }
  48680. declare module "babylonjs/Misc/environmentTextureTools" {
  48681. import { Nullable } from "babylonjs/types";
  48682. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  48683. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48684. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  48685. import "babylonjs/Shaders/rgbdEncode.fragment";
  48686. import "babylonjs/Shaders/rgbdDecode.fragment";
  48687. /**
  48688. * Raw texture data and descriptor sufficient for WebGL texture upload
  48689. */
  48690. export interface EnvironmentTextureInfo {
  48691. /**
  48692. * Version of the environment map
  48693. */
  48694. version: number;
  48695. /**
  48696. * Width of image
  48697. */
  48698. width: number;
  48699. /**
  48700. * Irradiance information stored in the file.
  48701. */
  48702. irradiance: any;
  48703. /**
  48704. * Specular information stored in the file.
  48705. */
  48706. specular: any;
  48707. }
  48708. /**
  48709. * Sets of helpers addressing the serialization and deserialization of environment texture
  48710. * stored in a BabylonJS env file.
  48711. * Those files are usually stored as .env files.
  48712. */
  48713. export class EnvironmentTextureTools {
  48714. /**
  48715. * Magic number identifying the env file.
  48716. */
  48717. private static _MagicBytes;
  48718. /**
  48719. * Gets the environment info from an env file.
  48720. * @param data The array buffer containing the .env bytes.
  48721. * @returns the environment file info (the json header) if successfully parsed.
  48722. */
  48723. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  48724. /**
  48725. * Creates an environment texture from a loaded cube texture.
  48726. * @param texture defines the cube texture to convert in env file
  48727. * @return a promise containing the environment data if succesfull.
  48728. */
  48729. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  48730. /**
  48731. * Creates a JSON representation of the spherical data.
  48732. * @param texture defines the texture containing the polynomials
  48733. * @return the JSON representation of the spherical info
  48734. */
  48735. private static _CreateEnvTextureIrradiance;
  48736. /**
  48737. * Uploads the texture info contained in the env file to the GPU.
  48738. * @param texture defines the internal texture to upload to
  48739. * @param arrayBuffer defines the buffer cotaining the data to load
  48740. * @param info defines the texture info retrieved through the GetEnvInfo method
  48741. * @returns a promise
  48742. */
  48743. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  48744. /**
  48745. * Uploads the levels of image data to the GPU.
  48746. * @param texture defines the internal texture to upload to
  48747. * @param imageData defines the array buffer views of image data [mipmap][face]
  48748. * @returns a promise
  48749. */
  48750. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  48751. /**
  48752. * Uploads spherical polynomials information to the texture.
  48753. * @param texture defines the texture we are trying to upload the information to
  48754. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  48755. */
  48756. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  48757. /** @hidden */
  48758. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  48759. }
  48760. }
  48761. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  48762. import { Nullable } from "babylonjs/types";
  48763. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48764. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  48765. /**
  48766. * Implementation of the ENV Texture Loader.
  48767. * @hidden
  48768. */
  48769. export class _ENVTextureLoader implements IInternalTextureLoader {
  48770. /**
  48771. * Defines wether the loader supports cascade loading the different faces.
  48772. */
  48773. readonly supportCascades: boolean;
  48774. /**
  48775. * This returns if the loader support the current file information.
  48776. * @param extension defines the file extension of the file being loaded
  48777. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48778. * @param fallback defines the fallback internal texture if any
  48779. * @param isBase64 defines whether the texture is encoded as a base64
  48780. * @param isBuffer defines whether the texture data are stored as a buffer
  48781. * @returns true if the loader can load the specified file
  48782. */
  48783. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48784. /**
  48785. * Transform the url before loading if required.
  48786. * @param rootUrl the url of the texture
  48787. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48788. * @returns the transformed texture
  48789. */
  48790. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48791. /**
  48792. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48793. * @param rootUrl the url of the texture
  48794. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48795. * @returns the fallback texture
  48796. */
  48797. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48798. /**
  48799. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48800. * @param data contains the texture data
  48801. * @param texture defines the BabylonJS internal texture
  48802. * @param createPolynomials will be true if polynomials have been requested
  48803. * @param onLoad defines the callback to trigger once the texture is ready
  48804. * @param onError defines the callback to trigger in case of error
  48805. */
  48806. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48807. /**
  48808. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48809. * @param data contains the texture data
  48810. * @param texture defines the BabylonJS internal texture
  48811. * @param callback defines the method to call once ready to upload
  48812. */
  48813. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  48814. }
  48815. }
  48816. declare module "babylonjs/Misc/khronosTextureContainer" {
  48817. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48818. /**
  48819. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  48820. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  48821. */
  48822. export class KhronosTextureContainer {
  48823. /** contents of the KTX container file */
  48824. arrayBuffer: any;
  48825. private static HEADER_LEN;
  48826. private static COMPRESSED_2D;
  48827. private static COMPRESSED_3D;
  48828. private static TEX_2D;
  48829. private static TEX_3D;
  48830. /**
  48831. * Gets the openGL type
  48832. */
  48833. glType: number;
  48834. /**
  48835. * Gets the openGL type size
  48836. */
  48837. glTypeSize: number;
  48838. /**
  48839. * Gets the openGL format
  48840. */
  48841. glFormat: number;
  48842. /**
  48843. * Gets the openGL internal format
  48844. */
  48845. glInternalFormat: number;
  48846. /**
  48847. * Gets the base internal format
  48848. */
  48849. glBaseInternalFormat: number;
  48850. /**
  48851. * Gets image width in pixel
  48852. */
  48853. pixelWidth: number;
  48854. /**
  48855. * Gets image height in pixel
  48856. */
  48857. pixelHeight: number;
  48858. /**
  48859. * Gets image depth in pixels
  48860. */
  48861. pixelDepth: number;
  48862. /**
  48863. * Gets the number of array elements
  48864. */
  48865. numberOfArrayElements: number;
  48866. /**
  48867. * Gets the number of faces
  48868. */
  48869. numberOfFaces: number;
  48870. /**
  48871. * Gets the number of mipmap levels
  48872. */
  48873. numberOfMipmapLevels: number;
  48874. /**
  48875. * Gets the bytes of key value data
  48876. */
  48877. bytesOfKeyValueData: number;
  48878. /**
  48879. * Gets the load type
  48880. */
  48881. loadType: number;
  48882. /**
  48883. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  48884. */
  48885. isInvalid: boolean;
  48886. /**
  48887. * Creates a new KhronosTextureContainer
  48888. * @param arrayBuffer contents of the KTX container file
  48889. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  48890. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  48891. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  48892. */
  48893. constructor(
  48894. /** contents of the KTX container file */
  48895. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  48896. /**
  48897. * Uploads KTX content to a Babylon Texture.
  48898. * It is assumed that the texture has already been created & is currently bound
  48899. * @hidden
  48900. */
  48901. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  48902. private _upload2DCompressedLevels;
  48903. }
  48904. }
  48905. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  48906. import { Nullable } from "babylonjs/types";
  48907. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48908. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  48909. /**
  48910. * Implementation of the KTX Texture Loader.
  48911. * @hidden
  48912. */
  48913. export class _KTXTextureLoader implements IInternalTextureLoader {
  48914. /**
  48915. * Defines wether the loader supports cascade loading the different faces.
  48916. */
  48917. readonly supportCascades: boolean;
  48918. /**
  48919. * This returns if the loader support the current file information.
  48920. * @param extension defines the file extension of the file being loaded
  48921. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48922. * @param fallback defines the fallback internal texture if any
  48923. * @param isBase64 defines whether the texture is encoded as a base64
  48924. * @param isBuffer defines whether the texture data are stored as a buffer
  48925. * @returns true if the loader can load the specified file
  48926. */
  48927. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48928. /**
  48929. * Transform the url before loading if required.
  48930. * @param rootUrl the url of the texture
  48931. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48932. * @returns the transformed texture
  48933. */
  48934. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48935. /**
  48936. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48937. * @param rootUrl the url of the texture
  48938. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48939. * @returns the fallback texture
  48940. */
  48941. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48942. /**
  48943. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48944. * @param data contains the texture data
  48945. * @param texture defines the BabylonJS internal texture
  48946. * @param createPolynomials will be true if polynomials have been requested
  48947. * @param onLoad defines the callback to trigger once the texture is ready
  48948. * @param onError defines the callback to trigger in case of error
  48949. */
  48950. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48951. /**
  48952. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48953. * @param data contains the texture data
  48954. * @param texture defines the BabylonJS internal texture
  48955. * @param callback defines the method to call once ready to upload
  48956. */
  48957. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  48958. }
  48959. }
  48960. declare module "babylonjs/Misc/tga" {
  48961. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48962. /**
  48963. * Based on jsTGALoader - Javascript loader for TGA file
  48964. * By Vincent Thibault
  48965. * @see http://blog.robrowser.com/javascript-tga-loader.html
  48966. */
  48967. export class TGATools {
  48968. private static _TYPE_INDEXED;
  48969. private static _TYPE_RGB;
  48970. private static _TYPE_GREY;
  48971. private static _TYPE_RLE_INDEXED;
  48972. private static _TYPE_RLE_RGB;
  48973. private static _TYPE_RLE_GREY;
  48974. private static _ORIGIN_MASK;
  48975. private static _ORIGIN_SHIFT;
  48976. private static _ORIGIN_BL;
  48977. private static _ORIGIN_BR;
  48978. private static _ORIGIN_UL;
  48979. private static _ORIGIN_UR;
  48980. /**
  48981. * Gets the header of a TGA file
  48982. * @param data defines the TGA data
  48983. * @returns the header
  48984. */
  48985. static GetTGAHeader(data: Uint8Array): any;
  48986. /**
  48987. * Uploads TGA content to a Babylon Texture
  48988. * @hidden
  48989. */
  48990. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  48991. /** @hidden */
  48992. 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;
  48993. /** @hidden */
  48994. 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;
  48995. /** @hidden */
  48996. 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;
  48997. /** @hidden */
  48998. 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;
  48999. /** @hidden */
  49000. 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;
  49001. /** @hidden */
  49002. 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;
  49003. }
  49004. }
  49005. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  49006. import { Nullable } from "babylonjs/types";
  49007. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49008. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  49009. /**
  49010. * Implementation of the TGA Texture Loader.
  49011. * @hidden
  49012. */
  49013. export class _TGATextureLoader implements IInternalTextureLoader {
  49014. /**
  49015. * Defines wether the loader supports cascade loading the different faces.
  49016. */
  49017. readonly supportCascades: boolean;
  49018. /**
  49019. * This returns if the loader support the current file information.
  49020. * @param extension defines the file extension of the file being loaded
  49021. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49022. * @param fallback defines the fallback internal texture if any
  49023. * @param isBase64 defines whether the texture is encoded as a base64
  49024. * @param isBuffer defines whether the texture data are stored as a buffer
  49025. * @returns true if the loader can load the specified file
  49026. */
  49027. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  49028. /**
  49029. * Transform the url before loading if required.
  49030. * @param rootUrl the url of the texture
  49031. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49032. * @returns the transformed texture
  49033. */
  49034. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  49035. /**
  49036. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  49037. * @param rootUrl the url of the texture
  49038. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49039. * @returns the fallback texture
  49040. */
  49041. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  49042. /**
  49043. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  49044. * @param data contains the texture data
  49045. * @param texture defines the BabylonJS internal texture
  49046. * @param createPolynomials will be true if polynomials have been requested
  49047. * @param onLoad defines the callback to trigger once the texture is ready
  49048. * @param onError defines the callback to trigger in case of error
  49049. */
  49050. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  49051. /**
  49052. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  49053. * @param data contains the texture data
  49054. * @param texture defines the BabylonJS internal texture
  49055. * @param callback defines the method to call once ready to upload
  49056. */
  49057. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  49058. }
  49059. }
  49060. declare module "babylonjs/Materials/Textures/Loaders/index" {
  49061. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  49062. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  49063. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  49064. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  49065. }
  49066. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  49067. import { Scene } from "babylonjs/scene";
  49068. import { Texture } from "babylonjs/Materials/Textures/texture";
  49069. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  49070. /**
  49071. * 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.
  49072. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  49073. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  49074. */
  49075. export class CustomProceduralTexture extends ProceduralTexture {
  49076. private _animate;
  49077. private _time;
  49078. private _config;
  49079. private _texturePath;
  49080. /**
  49081. * Instantiates a new Custom Procedural Texture.
  49082. * 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.
  49083. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  49084. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  49085. * @param name Define the name of the texture
  49086. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  49087. * @param size Define the size of the texture to create
  49088. * @param scene Define the scene the texture belongs to
  49089. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  49090. * @param generateMipMaps Define if the texture should creates mip maps or not
  49091. */
  49092. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  49093. private _loadJson;
  49094. /**
  49095. * Is the texture ready to be used ? (rendered at least once)
  49096. * @returns true if ready, otherwise, false.
  49097. */
  49098. isReady(): boolean;
  49099. /**
  49100. * Render the texture to its associated render target.
  49101. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  49102. */
  49103. render(useCameraPostProcess?: boolean): void;
  49104. /**
  49105. * Update the list of dependant textures samplers in the shader.
  49106. */
  49107. updateTextures(): void;
  49108. /**
  49109. * Update the uniform values of the procedural texture in the shader.
  49110. */
  49111. updateShaderUniforms(): void;
  49112. /**
  49113. * Define if the texture animates or not.
  49114. */
  49115. animate: boolean;
  49116. }
  49117. }
  49118. declare module "babylonjs/Shaders/noise.fragment" {
  49119. /** @hidden */
  49120. export var noisePixelShader: {
  49121. name: string;
  49122. shader: string;
  49123. };
  49124. }
  49125. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  49126. import { Nullable } from "babylonjs/types";
  49127. import { Scene } from "babylonjs/scene";
  49128. import { Texture } from "babylonjs/Materials/Textures/texture";
  49129. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  49130. import "babylonjs/Shaders/noise.fragment";
  49131. /**
  49132. * Class used to generate noise procedural textures
  49133. */
  49134. export class NoiseProceduralTexture extends ProceduralTexture {
  49135. private _time;
  49136. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  49137. brightness: number;
  49138. /** Defines the number of octaves to process */
  49139. octaves: number;
  49140. /** Defines the level of persistence (0.8 by default) */
  49141. persistence: number;
  49142. /** Gets or sets animation speed factor (default is 1) */
  49143. animationSpeedFactor: number;
  49144. /**
  49145. * Creates a new NoiseProceduralTexture
  49146. * @param name defines the name fo the texture
  49147. * @param size defines the size of the texture (default is 256)
  49148. * @param scene defines the hosting scene
  49149. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  49150. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  49151. */
  49152. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  49153. private _updateShaderUniforms;
  49154. protected _getDefines(): string;
  49155. /** Generate the current state of the procedural texture */
  49156. render(useCameraPostProcess?: boolean): void;
  49157. /**
  49158. * Serializes this noise procedural texture
  49159. * @returns a serialized noise procedural texture object
  49160. */
  49161. serialize(): any;
  49162. /**
  49163. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  49164. * @param parsedTexture defines parsed texture data
  49165. * @param scene defines the current scene
  49166. * @param rootUrl defines the root URL containing noise procedural texture information
  49167. * @returns a parsed NoiseProceduralTexture
  49168. */
  49169. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  49170. }
  49171. }
  49172. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  49173. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  49174. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  49175. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  49176. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  49177. }
  49178. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  49179. import { Nullable } from "babylonjs/types";
  49180. import { Scene } from "babylonjs/scene";
  49181. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  49182. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49183. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  49184. /**
  49185. * Raw cube texture where the raw buffers are passed in
  49186. */
  49187. export class RawCubeTexture extends CubeTexture {
  49188. /**
  49189. * Creates a cube texture where the raw buffers are passed in.
  49190. * @param scene defines the scene the texture is attached to
  49191. * @param data defines the array of data to use to create each face
  49192. * @param size defines the size of the textures
  49193. * @param format defines the format of the data
  49194. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  49195. * @param generateMipMaps defines if the engine should generate the mip levels
  49196. * @param invertY defines if data must be stored with Y axis inverted
  49197. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  49198. * @param compression defines the compression used (null by default)
  49199. */
  49200. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  49201. /**
  49202. * Updates the raw cube texture.
  49203. * @param data defines the data to store
  49204. * @param format defines the data format
  49205. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  49206. * @param invertY defines if data must be stored with Y axis inverted
  49207. * @param compression defines the compression used (null by default)
  49208. * @param level defines which level of the texture to update
  49209. */
  49210. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  49211. /**
  49212. * Updates a raw cube texture with RGBD encoded data.
  49213. * @param data defines the array of data [mipmap][face] to use to create each face
  49214. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  49215. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  49216. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  49217. * @returns a promsie that resolves when the operation is complete
  49218. */
  49219. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  49220. /**
  49221. * Clones the raw cube texture.
  49222. * @return a new cube texture
  49223. */
  49224. clone(): CubeTexture;
  49225. /** @hidden */
  49226. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  49227. }
  49228. }
  49229. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  49230. import { Scene } from "babylonjs/scene";
  49231. import { Texture } from "babylonjs/Materials/Textures/texture";
  49232. /**
  49233. * Class used to store 3D textures containing user data
  49234. */
  49235. export class RawTexture3D extends Texture {
  49236. /** Gets or sets the texture format to use */
  49237. format: number;
  49238. private _engine;
  49239. /**
  49240. * Create a new RawTexture3D
  49241. * @param data defines the data of the texture
  49242. * @param width defines the width of the texture
  49243. * @param height defines the height of the texture
  49244. * @param depth defines the depth of the texture
  49245. * @param format defines the texture format to use
  49246. * @param scene defines the hosting scene
  49247. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  49248. * @param invertY defines if texture must be stored with Y axis inverted
  49249. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  49250. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  49251. */
  49252. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  49253. /** Gets or sets the texture format to use */
  49254. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  49255. /**
  49256. * Update the texture with new data
  49257. * @param data defines the data to store in the texture
  49258. */
  49259. update(data: ArrayBufferView): void;
  49260. }
  49261. }
  49262. declare module "babylonjs/Materials/Textures/refractionTexture" {
  49263. import { Scene } from "babylonjs/scene";
  49264. import { Plane } from "babylonjs/Maths/math";
  49265. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  49266. /**
  49267. * Creates a refraction texture used by refraction channel of the standard material.
  49268. * It is like a mirror but to see through a material.
  49269. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  49270. */
  49271. export class RefractionTexture extends RenderTargetTexture {
  49272. /**
  49273. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  49274. * 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.
  49275. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  49276. */
  49277. refractionPlane: Plane;
  49278. /**
  49279. * Define how deep under the surface we should see.
  49280. */
  49281. depth: number;
  49282. /**
  49283. * Creates a refraction texture used by refraction channel of the standard material.
  49284. * It is like a mirror but to see through a material.
  49285. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  49286. * @param name Define the texture name
  49287. * @param size Define the size of the underlying texture
  49288. * @param scene Define the scene the refraction belongs to
  49289. * @param generateMipMaps Define if we need to generate mips level for the refraction
  49290. */
  49291. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  49292. /**
  49293. * Clone the refraction texture.
  49294. * @returns the cloned texture
  49295. */
  49296. clone(): RefractionTexture;
  49297. /**
  49298. * Serialize the texture to a JSON representation you could use in Parse later on
  49299. * @returns the serialized JSON representation
  49300. */
  49301. serialize(): any;
  49302. }
  49303. }
  49304. declare module "babylonjs/Materials/Textures/index" {
  49305. export * from "babylonjs/Materials/Textures/baseTexture";
  49306. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  49307. export * from "babylonjs/Materials/Textures/cubeTexture";
  49308. export * from "babylonjs/Materials/Textures/dynamicTexture";
  49309. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  49310. export * from "babylonjs/Materials/Textures/internalTexture";
  49311. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  49312. export * from "babylonjs/Materials/Textures/internalTextureTracker";
  49313. export * from "babylonjs/Materials/Textures/Loaders/index";
  49314. export * from "babylonjs/Materials/Textures/mirrorTexture";
  49315. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  49316. export * from "babylonjs/Materials/Textures/Procedurals/index";
  49317. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  49318. export * from "babylonjs/Materials/Textures/rawTexture";
  49319. export * from "babylonjs/Materials/Textures/rawTexture3D";
  49320. export * from "babylonjs/Materials/Textures/refractionTexture";
  49321. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  49322. export * from "babylonjs/Materials/Textures/texture";
  49323. export * from "babylonjs/Materials/Textures/videoTexture";
  49324. }
  49325. declare module "babylonjs/Materials/index" {
  49326. export * from "babylonjs/Materials/Background/index";
  49327. export * from "babylonjs/Materials/colorCurves";
  49328. export * from "babylonjs/Materials/effect";
  49329. export * from "babylonjs/Materials/fresnelParameters";
  49330. export * from "babylonjs/Materials/imageProcessingConfiguration";
  49331. export * from "babylonjs/Materials/material";
  49332. export * from "babylonjs/Materials/materialDefines";
  49333. export * from "babylonjs/Materials/materialHelper";
  49334. export * from "babylonjs/Materials/multiMaterial";
  49335. export * from "babylonjs/Materials/PBR/index";
  49336. export * from "babylonjs/Materials/pushMaterial";
  49337. export * from "babylonjs/Materials/shaderMaterial";
  49338. export * from "babylonjs/Materials/standardMaterial";
  49339. export * from "babylonjs/Materials/Textures/index";
  49340. export * from "babylonjs/Materials/uniformBuffer";
  49341. export * from "babylonjs/Materials/materialFlags";
  49342. }
  49343. declare module "babylonjs/Maths/index" {
  49344. export * from "babylonjs/Maths/math.scalar";
  49345. export * from "babylonjs/Maths/math";
  49346. export * from "babylonjs/Maths/sphericalPolynomial";
  49347. }
  49348. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  49349. import { IDisposable } from "babylonjs/scene";
  49350. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  49351. /**
  49352. * Configuration for Draco compression
  49353. */
  49354. export interface IDracoCompressionConfiguration {
  49355. /**
  49356. * Configuration for the decoder.
  49357. */
  49358. decoder?: {
  49359. /**
  49360. * The url to the WebAssembly module.
  49361. */
  49362. wasmUrl?: string;
  49363. /**
  49364. * The url to the WebAssembly binary.
  49365. */
  49366. wasmBinaryUrl?: string;
  49367. /**
  49368. * The url to the fallback JavaScript module.
  49369. */
  49370. fallbackUrl?: string;
  49371. };
  49372. }
  49373. /**
  49374. * Draco compression (https://google.github.io/draco/)
  49375. *
  49376. * This class wraps the Draco module.
  49377. *
  49378. * **Encoder**
  49379. *
  49380. * The encoder is not currently implemented.
  49381. *
  49382. * **Decoder**
  49383. *
  49384. * 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.
  49385. *
  49386. * To update the configuration, use the following code:
  49387. * ```javascript
  49388. * DracoCompression.Configuration = {
  49389. * decoder: {
  49390. * wasmUrl: "<url to the WebAssembly library>",
  49391. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  49392. * fallbackUrl: "<url to the fallback JavaScript library>",
  49393. * }
  49394. * };
  49395. * ```
  49396. *
  49397. * 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.
  49398. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  49399. * Use `DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  49400. *
  49401. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  49402. * ```javascript
  49403. * var dracoCompression = new DracoCompression();
  49404. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  49405. * [VertexBuffer.PositionKind]: 0
  49406. * });
  49407. * ```
  49408. *
  49409. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  49410. */
  49411. export class DracoCompression implements IDisposable {
  49412. private static _DecoderModulePromise;
  49413. /**
  49414. * The configuration. Defaults to the following urls:
  49415. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  49416. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  49417. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  49418. */
  49419. static Configuration: IDracoCompressionConfiguration;
  49420. /**
  49421. * Returns true if the decoder is available.
  49422. */
  49423. static readonly DecoderAvailable: boolean;
  49424. /**
  49425. * Constructor
  49426. */
  49427. constructor();
  49428. /**
  49429. * Stop all async operations and release resources.
  49430. */
  49431. dispose(): void;
  49432. /**
  49433. * Decode Draco compressed mesh data to vertex data.
  49434. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  49435. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  49436. * @returns A promise that resolves with the decoded vertex data
  49437. */
  49438. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes: {
  49439. [kind: string]: number;
  49440. }): Promise<VertexData>;
  49441. private static _GetDecoderModule;
  49442. private static _LoadScriptAsync;
  49443. private static _LoadFileAsync;
  49444. }
  49445. }
  49446. declare module "babylonjs/Meshes/Compression/index" {
  49447. export * from "babylonjs/Meshes/Compression/dracoCompression";
  49448. }
  49449. declare module "babylonjs/Meshes/csg" {
  49450. import { Nullable } from "babylonjs/types";
  49451. import { Scene } from "babylonjs/scene";
  49452. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  49453. import { Mesh } from "babylonjs/Meshes/mesh";
  49454. import { Material } from "babylonjs/Materials/material";
  49455. /**
  49456. * Class for building Constructive Solid Geometry
  49457. */
  49458. export class CSG {
  49459. private polygons;
  49460. /**
  49461. * The world matrix
  49462. */
  49463. matrix: Matrix;
  49464. /**
  49465. * Stores the position
  49466. */
  49467. position: Vector3;
  49468. /**
  49469. * Stores the rotation
  49470. */
  49471. rotation: Vector3;
  49472. /**
  49473. * Stores the rotation quaternion
  49474. */
  49475. rotationQuaternion: Nullable<Quaternion>;
  49476. /**
  49477. * Stores the scaling vector
  49478. */
  49479. scaling: Vector3;
  49480. /**
  49481. * Convert the Mesh to CSG
  49482. * @param mesh The Mesh to convert to CSG
  49483. * @returns A new CSG from the Mesh
  49484. */
  49485. static FromMesh(mesh: Mesh): CSG;
  49486. /**
  49487. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  49488. * @param polygons Polygons used to construct a CSG solid
  49489. */
  49490. private static FromPolygons;
  49491. /**
  49492. * Clones, or makes a deep copy, of the CSG
  49493. * @returns A new CSG
  49494. */
  49495. clone(): CSG;
  49496. /**
  49497. * Unions this CSG with another CSG
  49498. * @param csg The CSG to union against this CSG
  49499. * @returns The unioned CSG
  49500. */
  49501. union(csg: CSG): CSG;
  49502. /**
  49503. * Unions this CSG with another CSG in place
  49504. * @param csg The CSG to union against this CSG
  49505. */
  49506. unionInPlace(csg: CSG): void;
  49507. /**
  49508. * Subtracts this CSG with another CSG
  49509. * @param csg The CSG to subtract against this CSG
  49510. * @returns A new CSG
  49511. */
  49512. subtract(csg: CSG): CSG;
  49513. /**
  49514. * Subtracts this CSG with another CSG in place
  49515. * @param csg The CSG to subtact against this CSG
  49516. */
  49517. subtractInPlace(csg: CSG): void;
  49518. /**
  49519. * Intersect this CSG with another CSG
  49520. * @param csg The CSG to intersect against this CSG
  49521. * @returns A new CSG
  49522. */
  49523. intersect(csg: CSG): CSG;
  49524. /**
  49525. * Intersects this CSG with another CSG in place
  49526. * @param csg The CSG to intersect against this CSG
  49527. */
  49528. intersectInPlace(csg: CSG): void;
  49529. /**
  49530. * Return a new CSG solid with solid and empty space switched. This solid is
  49531. * not modified.
  49532. * @returns A new CSG solid with solid and empty space switched
  49533. */
  49534. inverse(): CSG;
  49535. /**
  49536. * Inverses the CSG in place
  49537. */
  49538. inverseInPlace(): void;
  49539. /**
  49540. * This is used to keep meshes transformations so they can be restored
  49541. * when we build back a Babylon Mesh
  49542. * NB : All CSG operations are performed in world coordinates
  49543. * @param csg The CSG to copy the transform attributes from
  49544. * @returns This CSG
  49545. */
  49546. copyTransformAttributes(csg: CSG): CSG;
  49547. /**
  49548. * Build Raw mesh from CSG
  49549. * Coordinates here are in world space
  49550. * @param name The name of the mesh geometry
  49551. * @param scene The Scene
  49552. * @param keepSubMeshes Specifies if the submeshes should be kept
  49553. * @returns A new Mesh
  49554. */
  49555. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  49556. /**
  49557. * Build Mesh from CSG taking material and transforms into account
  49558. * @param name The name of the Mesh
  49559. * @param material The material of the Mesh
  49560. * @param scene The Scene
  49561. * @param keepSubMeshes Specifies if submeshes should be kept
  49562. * @returns The new Mesh
  49563. */
  49564. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  49565. }
  49566. }
  49567. declare module "babylonjs/Meshes/trailMesh" {
  49568. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49569. import { Mesh } from "babylonjs/Meshes/mesh";
  49570. import { Scene } from "babylonjs/scene";
  49571. /**
  49572. * Class used to create a trail following a mesh
  49573. */
  49574. export class TrailMesh extends Mesh {
  49575. private _generator;
  49576. private _autoStart;
  49577. private _running;
  49578. private _diameter;
  49579. private _length;
  49580. private _sectionPolygonPointsCount;
  49581. private _sectionVectors;
  49582. private _sectionNormalVectors;
  49583. private _beforeRenderObserver;
  49584. /**
  49585. * @constructor
  49586. * @param name The value used by scene.getMeshByName() to do a lookup.
  49587. * @param generator The mesh to generate a trail.
  49588. * @param scene The scene to add this mesh to.
  49589. * @param diameter Diameter of trailing mesh. Default is 1.
  49590. * @param length Length of trailing mesh. Default is 60.
  49591. * @param autoStart Automatically start trailing mesh. Default true.
  49592. */
  49593. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  49594. /**
  49595. * "TrailMesh"
  49596. * @returns "TrailMesh"
  49597. */
  49598. getClassName(): string;
  49599. private _createMesh;
  49600. /**
  49601. * Start trailing mesh.
  49602. */
  49603. start(): void;
  49604. /**
  49605. * Stop trailing mesh.
  49606. */
  49607. stop(): void;
  49608. /**
  49609. * Update trailing mesh geometry.
  49610. */
  49611. update(): void;
  49612. /**
  49613. * Returns a new TrailMesh object.
  49614. * @param name is a string, the name given to the new mesh
  49615. * @param newGenerator use new generator object for cloned trail mesh
  49616. * @returns a new mesh
  49617. */
  49618. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  49619. /**
  49620. * Serializes this trail mesh
  49621. * @param serializationObject object to write serialization to
  49622. */
  49623. serialize(serializationObject: any): void;
  49624. /**
  49625. * Parses a serialized trail mesh
  49626. * @param parsedMesh the serialized mesh
  49627. * @param scene the scene to create the trail mesh in
  49628. * @returns the created trail mesh
  49629. */
  49630. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  49631. }
  49632. }
  49633. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  49634. import { Nullable } from "babylonjs/types";
  49635. import { Scene } from "babylonjs/scene";
  49636. import { Vector3, Vector2, Color4, Vector4 } from "babylonjs/Maths/math";
  49637. import { Mesh } from "babylonjs/Meshes/mesh";
  49638. /**
  49639. * Class containing static functions to help procedurally build meshes
  49640. */
  49641. export class RibbonBuilder {
  49642. /**
  49643. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  49644. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  49645. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  49646. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  49647. * * 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
  49648. * * 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
  49649. * * 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
  49650. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49651. * * If you create a double-sided mesh, you can choose what parts of 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
  49652. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49653. * * 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
  49654. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  49655. * * 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
  49656. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  49657. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49658. * @param name defines the name of the mesh
  49659. * @param options defines the options used to create the mesh
  49660. * @param scene defines the hosting scene
  49661. * @returns the ribbon mesh
  49662. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  49663. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49664. */
  49665. static CreateRibbon(name: string, options: {
  49666. pathArray: Vector3[][];
  49667. closeArray?: boolean;
  49668. closePath?: boolean;
  49669. offset?: number;
  49670. updatable?: boolean;
  49671. sideOrientation?: number;
  49672. frontUVs?: Vector4;
  49673. backUVs?: Vector4;
  49674. instance?: Mesh;
  49675. invertUV?: boolean;
  49676. uvs?: Vector2[];
  49677. colors?: Color4[];
  49678. }, scene?: Nullable<Scene>): Mesh;
  49679. }
  49680. }
  49681. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  49682. import { Vector4 } from "babylonjs/Maths/math";
  49683. import { Mesh } from "babylonjs/Meshes/mesh";
  49684. /**
  49685. * Class containing static functions to help procedurally build meshes
  49686. */
  49687. export class TorusKnotBuilder {
  49688. /**
  49689. * Creates a torus knot mesh
  49690. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  49691. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  49692. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  49693. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  49694. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49695. * * If you create a double-sided mesh, you can choose what parts of 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
  49696. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49697. * @param name defines the name of the mesh
  49698. * @param options defines the options used to create the mesh
  49699. * @param scene defines the hosting scene
  49700. * @returns the torus knot mesh
  49701. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  49702. */
  49703. static CreateTorusKnot(name: string, options: {
  49704. radius?: number;
  49705. tube?: number;
  49706. radialSegments?: number;
  49707. tubularSegments?: number;
  49708. p?: number;
  49709. q?: number;
  49710. updatable?: boolean;
  49711. sideOrientation?: number;
  49712. frontUVs?: Vector4;
  49713. backUVs?: Vector4;
  49714. }, scene: any): Mesh;
  49715. }
  49716. }
  49717. declare module "babylonjs/Meshes/polygonMesh" {
  49718. import { Scene } from "babylonjs/scene";
  49719. import { Vector2, Path2 } from "babylonjs/Maths/math";
  49720. import { Mesh } from "babylonjs/Meshes/mesh";
  49721. /**
  49722. * Polygon
  49723. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  49724. */
  49725. export class Polygon {
  49726. /**
  49727. * Creates a rectangle
  49728. * @param xmin bottom X coord
  49729. * @param ymin bottom Y coord
  49730. * @param xmax top X coord
  49731. * @param ymax top Y coord
  49732. * @returns points that make the resulting rectation
  49733. */
  49734. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  49735. /**
  49736. * Creates a circle
  49737. * @param radius radius of circle
  49738. * @param cx scale in x
  49739. * @param cy scale in y
  49740. * @param numberOfSides number of sides that make up the circle
  49741. * @returns points that make the resulting circle
  49742. */
  49743. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  49744. /**
  49745. * Creates a polygon from input string
  49746. * @param input Input polygon data
  49747. * @returns the parsed points
  49748. */
  49749. static Parse(input: string): Vector2[];
  49750. /**
  49751. * Starts building a polygon from x and y coordinates
  49752. * @param x x coordinate
  49753. * @param y y coordinate
  49754. * @returns the started path2
  49755. */
  49756. static StartingAt(x: number, y: number): Path2;
  49757. }
  49758. /**
  49759. * Builds a polygon
  49760. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  49761. */
  49762. export class PolygonMeshBuilder {
  49763. private _points;
  49764. private _outlinepoints;
  49765. private _holes;
  49766. private _name;
  49767. private _scene;
  49768. private _epoints;
  49769. private _eholes;
  49770. private _addToepoint;
  49771. /**
  49772. * Babylon reference to the earcut plugin.
  49773. */
  49774. bjsEarcut: any;
  49775. /**
  49776. * Creates a PolygonMeshBuilder
  49777. * @param name name of the builder
  49778. * @param contours Path of the polygon
  49779. * @param scene scene to add to
  49780. * @param earcutInjection can be used to inject your own earcut reference
  49781. */
  49782. constructor(name: string, contours: Path2 | Vector2[] | any, scene: Scene, earcutInjection?: any);
  49783. /**
  49784. * Adds a whole within the polygon
  49785. * @param hole Array of points defining the hole
  49786. * @returns this
  49787. */
  49788. addHole(hole: Vector2[]): PolygonMeshBuilder;
  49789. /**
  49790. * Creates the polygon
  49791. * @param updatable If the mesh should be updatable
  49792. * @param depth The depth of the mesh created
  49793. * @returns the created mesh
  49794. */
  49795. build(updatable?: boolean, depth?: number): Mesh;
  49796. /**
  49797. * Adds a side to the polygon
  49798. * @param positions points that make the polygon
  49799. * @param normals normals of the polygon
  49800. * @param uvs uvs of the polygon
  49801. * @param indices indices of the polygon
  49802. * @param bounds bounds of the polygon
  49803. * @param points points of the polygon
  49804. * @param depth depth of the polygon
  49805. * @param flip flip of the polygon
  49806. */
  49807. private addSide;
  49808. }
  49809. }
  49810. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  49811. import { Scene } from "babylonjs/scene";
  49812. import { Vector3, Color4, Vector4 } from "babylonjs/Maths/math";
  49813. import { Mesh } from "babylonjs/Meshes/mesh";
  49814. /**
  49815. * Class containing static functions to help procedurally build meshes
  49816. */
  49817. export class PolygonBuilder {
  49818. /**
  49819. * Creates a polygon mesh
  49820. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  49821. * * 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
  49822. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  49823. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49824. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  49825. * * Remember you can only change the shape positions, not their number when updating a polygon
  49826. * @param name defines the name of the mesh
  49827. * @param options defines the options used to create the mesh
  49828. * @param scene defines the hosting scene
  49829. * @param earcutInjection can be used to inject your own earcut reference
  49830. * @returns the polygon mesh
  49831. */
  49832. static CreatePolygon(name: string, options: {
  49833. shape: Vector3[];
  49834. holes?: Vector3[][];
  49835. depth?: number;
  49836. faceUV?: Vector4[];
  49837. faceColors?: Color4[];
  49838. updatable?: boolean;
  49839. sideOrientation?: number;
  49840. frontUVs?: Vector4;
  49841. backUVs?: Vector4;
  49842. }, scene: Scene, earcutInjection?: any): Mesh;
  49843. /**
  49844. * Creates an extruded polygon mesh, with depth in the Y direction.
  49845. * * 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)
  49846. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  49847. * @param name defines the name of the mesh
  49848. * @param options defines the options used to create the mesh
  49849. * @param scene defines the hosting scene
  49850. * @param earcutInjection can be used to inject your own earcut reference
  49851. * @returns the polygon mesh
  49852. */
  49853. static ExtrudePolygon(name: string, options: {
  49854. shape: Vector3[];
  49855. holes?: Vector3[][];
  49856. depth?: number;
  49857. faceUV?: Vector4[];
  49858. faceColors?: Color4[];
  49859. updatable?: boolean;
  49860. sideOrientation?: number;
  49861. frontUVs?: Vector4;
  49862. backUVs?: Vector4;
  49863. }, scene: Scene, earcutInjection?: any): Mesh;
  49864. }
  49865. }
  49866. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  49867. import { Nullable } from "babylonjs/types";
  49868. import { Scene } from "babylonjs/scene";
  49869. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  49870. import { Mesh } from "babylonjs/Meshes/mesh";
  49871. /**
  49872. * Class containing static functions to help procedurally build meshes
  49873. */
  49874. export class ShapeBuilder {
  49875. /**
  49876. * 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.
  49877. * * 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.
  49878. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  49879. * * 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.
  49880. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  49881. * * 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
  49882. * * 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
  49883. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  49884. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49885. * * If you create a double-sided mesh, you can choose what parts of 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
  49886. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  49887. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49888. * @param name defines the name of the mesh
  49889. * @param options defines the options used to create the mesh
  49890. * @param scene defines the hosting scene
  49891. * @returns the extruded shape mesh
  49892. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49893. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  49894. */
  49895. static ExtrudeShape(name: string, options: {
  49896. shape: Vector3[];
  49897. path: Vector3[];
  49898. scale?: number;
  49899. rotation?: number;
  49900. cap?: number;
  49901. updatable?: boolean;
  49902. sideOrientation?: number;
  49903. frontUVs?: Vector4;
  49904. backUVs?: Vector4;
  49905. instance?: Mesh;
  49906. invertUV?: boolean;
  49907. }, scene?: Nullable<Scene>): Mesh;
  49908. /**
  49909. * Creates an custom extruded shape mesh.
  49910. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  49911. * * 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.
  49912. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  49913. * * 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
  49914. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  49915. * * 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
  49916. * * It must returns a float value that will be the scale value applied to the shape on each path point
  49917. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  49918. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  49919. * * 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
  49920. * * 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
  49921. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  49922. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49923. * * If you create a double-sided mesh, you can choose what parts of 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
  49924. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49925. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49926. * @param name defines the name of the mesh
  49927. * @param options defines the options used to create the mesh
  49928. * @param scene defines the hosting scene
  49929. * @returns the custom extruded shape mesh
  49930. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  49931. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49932. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  49933. */
  49934. static ExtrudeShapeCustom(name: string, options: {
  49935. shape: Vector3[];
  49936. path: Vector3[];
  49937. scaleFunction?: any;
  49938. rotationFunction?: any;
  49939. ribbonCloseArray?: boolean;
  49940. ribbonClosePath?: boolean;
  49941. cap?: number;
  49942. updatable?: boolean;
  49943. sideOrientation?: number;
  49944. frontUVs?: Vector4;
  49945. backUVs?: Vector4;
  49946. instance?: Mesh;
  49947. invertUV?: boolean;
  49948. }, scene: Scene): Mesh;
  49949. private static _ExtrudeShapeGeneric;
  49950. }
  49951. }
  49952. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  49953. import { Scene } from "babylonjs/scene";
  49954. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  49955. import { Mesh } from "babylonjs/Meshes/mesh";
  49956. /**
  49957. * Class containing static functions to help procedurally build meshes
  49958. */
  49959. export class LatheBuilder {
  49960. /**
  49961. * Creates lathe mesh.
  49962. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  49963. * * 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
  49964. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  49965. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  49966. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  49967. * * 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
  49968. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  49969. * * 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
  49970. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49971. * * If you create a double-sided mesh, you can choose what parts of 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
  49972. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49973. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49974. * @param name defines the name of the mesh
  49975. * @param options defines the options used to create the mesh
  49976. * @param scene defines the hosting scene
  49977. * @returns the lathe mesh
  49978. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  49979. */
  49980. static CreateLathe(name: string, options: {
  49981. shape: Vector3[];
  49982. radius?: number;
  49983. tessellation?: number;
  49984. clip?: number;
  49985. arc?: number;
  49986. closed?: boolean;
  49987. updatable?: boolean;
  49988. sideOrientation?: number;
  49989. frontUVs?: Vector4;
  49990. backUVs?: Vector4;
  49991. cap?: number;
  49992. invertUV?: boolean;
  49993. }, scene: Scene): Mesh;
  49994. }
  49995. }
  49996. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  49997. import { Scene } from "babylonjs/scene";
  49998. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  49999. import { Mesh } from "babylonjs/Meshes/mesh";
  50000. /**
  50001. * Class containing static functions to help procedurally build meshes
  50002. */
  50003. export class TubeBuilder {
  50004. /**
  50005. * Creates a tube mesh.
  50006. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  50007. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  50008. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  50009. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  50010. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  50011. * * 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)
  50012. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  50013. * * 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
  50014. * * 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
  50015. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50016. * * If you create a double-sided mesh, you can choose what parts of 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
  50017. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50018. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50019. * @param name defines the name of the mesh
  50020. * @param options defines the options used to create the mesh
  50021. * @param scene defines the hosting scene
  50022. * @returns the tube mesh
  50023. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50024. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  50025. */
  50026. static CreateTube(name: string, options: {
  50027. path: Vector3[];
  50028. radius?: number;
  50029. tessellation?: number;
  50030. radiusFunction?: {
  50031. (i: number, distance: number): number;
  50032. };
  50033. cap?: number;
  50034. arc?: number;
  50035. updatable?: boolean;
  50036. sideOrientation?: number;
  50037. frontUVs?: Vector4;
  50038. backUVs?: Vector4;
  50039. instance?: Mesh;
  50040. invertUV?: boolean;
  50041. }, scene: Scene): Mesh;
  50042. }
  50043. }
  50044. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  50045. import { Scene } from "babylonjs/scene";
  50046. import { Vector4 } from "babylonjs/Maths/math";
  50047. import { Mesh } from "babylonjs/Meshes/mesh";
  50048. /**
  50049. * Class containing static functions to help procedurally build meshes
  50050. */
  50051. export class IcoSphereBuilder {
  50052. /**
  50053. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  50054. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  50055. * * 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`)
  50056. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  50057. * * 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
  50058. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50059. * * If you create a double-sided mesh, you can choose what parts of 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
  50060. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50061. * @param name defines the name of the mesh
  50062. * @param options defines the options used to create the mesh
  50063. * @param scene defines the hosting scene
  50064. * @returns the icosahedron mesh
  50065. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  50066. */
  50067. static CreateIcoSphere(name: string, options: {
  50068. radius?: number;
  50069. radiusX?: number;
  50070. radiusY?: number;
  50071. radiusZ?: number;
  50072. flat?: boolean;
  50073. subdivisions?: number;
  50074. sideOrientation?: number;
  50075. frontUVs?: Vector4;
  50076. backUVs?: Vector4;
  50077. updatable?: boolean;
  50078. }, scene: Scene): Mesh;
  50079. }
  50080. }
  50081. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  50082. import { Vector3 } from "babylonjs/Maths/math";
  50083. import { Mesh } from "babylonjs/Meshes/mesh";
  50084. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50085. /**
  50086. * Class containing static functions to help procedurally build meshes
  50087. */
  50088. export class DecalBuilder {
  50089. /**
  50090. * Creates a decal mesh.
  50091. * 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
  50092. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  50093. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  50094. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  50095. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  50096. * @param name defines the name of the mesh
  50097. * @param sourceMesh defines the mesh where the decal must be applied
  50098. * @param options defines the options used to create the mesh
  50099. * @param scene defines the hosting scene
  50100. * @returns the decal mesh
  50101. * @see https://doc.babylonjs.com/how_to/decals
  50102. */
  50103. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  50104. position?: Vector3;
  50105. normal?: Vector3;
  50106. size?: Vector3;
  50107. angle?: number;
  50108. }): Mesh;
  50109. }
  50110. }
  50111. declare module "babylonjs/Meshes/meshBuilder" {
  50112. import { Vector4, Color4, Vector3, Vector2, Plane, Color3 } from "babylonjs/Maths/math";
  50113. import { Nullable } from "babylonjs/types";
  50114. import { Scene } from "babylonjs/scene";
  50115. import { Mesh } from "babylonjs/Meshes/mesh";
  50116. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  50117. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  50118. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50119. /**
  50120. * Class containing static functions to help procedurally build meshes
  50121. */
  50122. export class MeshBuilder {
  50123. /**
  50124. * Creates a box mesh
  50125. * * The parameter `size` sets the size (float) of each box side (default 1)
  50126. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  50127. * * 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)
  50128. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  50129. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50130. * * If you create a double-sided mesh, you can choose what parts of 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
  50131. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50132. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  50133. * @param name defines the name of the mesh
  50134. * @param options defines the options used to create the mesh
  50135. * @param scene defines the hosting scene
  50136. * @returns the box mesh
  50137. */
  50138. static CreateBox(name: string, options: {
  50139. size?: number;
  50140. width?: number;
  50141. height?: number;
  50142. depth?: number;
  50143. faceUV?: Vector4[];
  50144. faceColors?: Color4[];
  50145. sideOrientation?: number;
  50146. frontUVs?: Vector4;
  50147. backUVs?: Vector4;
  50148. updatable?: boolean;
  50149. }, scene?: Nullable<Scene>): Mesh;
  50150. /**
  50151. * Creates a sphere mesh
  50152. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  50153. * * 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`)
  50154. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  50155. * * 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
  50156. * * 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)
  50157. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50158. * * If you create a double-sided mesh, you can choose what parts of 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
  50159. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50160. * @param name defines the name of the mesh
  50161. * @param options defines the options used to create the mesh
  50162. * @param scene defines the hosting scene
  50163. * @returns the sphere mesh
  50164. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  50165. */
  50166. static CreateSphere(name: string, options: {
  50167. segments?: number;
  50168. diameter?: number;
  50169. diameterX?: number;
  50170. diameterY?: number;
  50171. diameterZ?: number;
  50172. arc?: number;
  50173. slice?: number;
  50174. sideOrientation?: number;
  50175. frontUVs?: Vector4;
  50176. backUVs?: Vector4;
  50177. updatable?: boolean;
  50178. }, scene: any): Mesh;
  50179. /**
  50180. * Creates a plane polygonal mesh. By default, this is a disc
  50181. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  50182. * * 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
  50183. * * 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
  50184. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50185. * * If you create a double-sided mesh, you can choose what parts of 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
  50186. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50187. * @param name defines the name of the mesh
  50188. * @param options defines the options used to create the mesh
  50189. * @param scene defines the hosting scene
  50190. * @returns the plane polygonal mesh
  50191. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  50192. */
  50193. static CreateDisc(name: string, options: {
  50194. radius?: number;
  50195. tessellation?: number;
  50196. arc?: number;
  50197. updatable?: boolean;
  50198. sideOrientation?: number;
  50199. frontUVs?: Vector4;
  50200. backUVs?: Vector4;
  50201. }, scene?: Nullable<Scene>): Mesh;
  50202. /**
  50203. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  50204. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  50205. * * 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`)
  50206. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  50207. * * 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
  50208. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50209. * * If you create a double-sided mesh, you can choose what parts of 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
  50210. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50211. * @param name defines the name of the mesh
  50212. * @param options defines the options used to create the mesh
  50213. * @param scene defines the hosting scene
  50214. * @returns the icosahedron mesh
  50215. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  50216. */
  50217. static CreateIcoSphere(name: string, options: {
  50218. radius?: number;
  50219. radiusX?: number;
  50220. radiusY?: number;
  50221. radiusZ?: number;
  50222. flat?: boolean;
  50223. subdivisions?: number;
  50224. sideOrientation?: number;
  50225. frontUVs?: Vector4;
  50226. backUVs?: Vector4;
  50227. updatable?: boolean;
  50228. }, scene: Scene): Mesh;
  50229. /**
  50230. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  50231. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  50232. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  50233. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  50234. * * 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
  50235. * * 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
  50236. * * 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
  50237. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50238. * * If you create a double-sided mesh, you can choose what parts of 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
  50239. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50240. * * 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
  50241. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  50242. * * 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
  50243. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  50244. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50245. * @param name defines the name of the mesh
  50246. * @param options defines the options used to create the mesh
  50247. * @param scene defines the hosting scene
  50248. * @returns the ribbon mesh
  50249. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  50250. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50251. */
  50252. static CreateRibbon(name: string, options: {
  50253. pathArray: Vector3[][];
  50254. closeArray?: boolean;
  50255. closePath?: boolean;
  50256. offset?: number;
  50257. updatable?: boolean;
  50258. sideOrientation?: number;
  50259. frontUVs?: Vector4;
  50260. backUVs?: Vector4;
  50261. instance?: Mesh;
  50262. invertUV?: boolean;
  50263. uvs?: Vector2[];
  50264. colors?: Color4[];
  50265. }, scene?: Nullable<Scene>): Mesh;
  50266. /**
  50267. * Creates a cylinder or a cone mesh
  50268. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  50269. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  50270. * * 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.
  50271. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  50272. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  50273. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  50274. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  50275. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  50276. * * 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).
  50277. * * 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
  50278. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  50279. * * 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
  50280. * * 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.
  50281. * * If `enclose` is false, a ring surface is one element.
  50282. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  50283. * * 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
  50284. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50285. * * If you create a double-sided mesh, you can choose what parts of 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
  50286. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50287. * @param name defines the name of the mesh
  50288. * @param options defines the options used to create the mesh
  50289. * @param scene defines the hosting scene
  50290. * @returns the cylinder mesh
  50291. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  50292. */
  50293. static CreateCylinder(name: string, options: {
  50294. height?: number;
  50295. diameterTop?: number;
  50296. diameterBottom?: number;
  50297. diameter?: number;
  50298. tessellation?: number;
  50299. subdivisions?: number;
  50300. arc?: number;
  50301. faceColors?: Color4[];
  50302. faceUV?: Vector4[];
  50303. updatable?: boolean;
  50304. hasRings?: boolean;
  50305. enclose?: boolean;
  50306. sideOrientation?: number;
  50307. frontUVs?: Vector4;
  50308. backUVs?: Vector4;
  50309. }, scene: any): Mesh;
  50310. /**
  50311. * Creates a torus mesh
  50312. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  50313. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  50314. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  50315. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50316. * * If you create a double-sided mesh, you can choose what parts of 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
  50317. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50318. * @param name defines the name of the mesh
  50319. * @param options defines the options used to create the mesh
  50320. * @param scene defines the hosting scene
  50321. * @returns the torus mesh
  50322. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  50323. */
  50324. static CreateTorus(name: string, options: {
  50325. diameter?: number;
  50326. thickness?: number;
  50327. tessellation?: number;
  50328. updatable?: boolean;
  50329. sideOrientation?: number;
  50330. frontUVs?: Vector4;
  50331. backUVs?: Vector4;
  50332. }, scene: any): Mesh;
  50333. /**
  50334. * Creates a torus knot mesh
  50335. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  50336. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  50337. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  50338. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  50339. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50340. * * If you create a double-sided mesh, you can choose what parts of 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
  50341. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50342. * @param name defines the name of the mesh
  50343. * @param options defines the options used to create the mesh
  50344. * @param scene defines the hosting scene
  50345. * @returns the torus knot mesh
  50346. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  50347. */
  50348. static CreateTorusKnot(name: string, options: {
  50349. radius?: number;
  50350. tube?: number;
  50351. radialSegments?: number;
  50352. tubularSegments?: number;
  50353. p?: number;
  50354. q?: number;
  50355. updatable?: boolean;
  50356. sideOrientation?: number;
  50357. frontUVs?: Vector4;
  50358. backUVs?: Vector4;
  50359. }, scene: any): Mesh;
  50360. /**
  50361. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  50362. * * 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
  50363. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  50364. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  50365. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  50366. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  50367. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  50368. * * 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
  50369. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  50370. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50371. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  50372. * @param name defines the name of the new line system
  50373. * @param options defines the options used to create the line system
  50374. * @param scene defines the hosting scene
  50375. * @returns a new line system mesh
  50376. */
  50377. static CreateLineSystem(name: string, options: {
  50378. lines: Vector3[][];
  50379. updatable?: boolean;
  50380. instance?: Nullable<LinesMesh>;
  50381. colors?: Nullable<Color4[][]>;
  50382. useVertexAlpha?: boolean;
  50383. }, scene: Nullable<Scene>): LinesMesh;
  50384. /**
  50385. * Creates a line mesh
  50386. * 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
  50387. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  50388. * * The parameter `points` is an array successive Vector3
  50389. * * 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
  50390. * * The optional parameter `colors` is an array of successive Color4, one per line point
  50391. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  50392. * * When updating an instance, remember that only point positions can change, not the number of points
  50393. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50394. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  50395. * @param name defines the name of the new line system
  50396. * @param options defines the options used to create the line system
  50397. * @param scene defines the hosting scene
  50398. * @returns a new line mesh
  50399. */
  50400. static CreateLines(name: string, options: {
  50401. points: Vector3[];
  50402. updatable?: boolean;
  50403. instance?: Nullable<LinesMesh>;
  50404. colors?: Color4[];
  50405. useVertexAlpha?: boolean;
  50406. }, scene?: Nullable<Scene>): LinesMesh;
  50407. /**
  50408. * Creates a dashed line mesh
  50409. * * 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
  50410. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  50411. * * The parameter `points` is an array successive Vector3
  50412. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  50413. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  50414. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  50415. * * 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
  50416. * * When updating an instance, remember that only point positions can change, not the number of points
  50417. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50418. * @param name defines the name of the mesh
  50419. * @param options defines the options used to create the mesh
  50420. * @param scene defines the hosting scene
  50421. * @returns the dashed line mesh
  50422. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  50423. */
  50424. static CreateDashedLines(name: string, options: {
  50425. points: Vector3[];
  50426. dashSize?: number;
  50427. gapSize?: number;
  50428. dashNb?: number;
  50429. updatable?: boolean;
  50430. instance?: LinesMesh;
  50431. }, scene?: Nullable<Scene>): LinesMesh;
  50432. /**
  50433. * 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.
  50434. * * 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.
  50435. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  50436. * * 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.
  50437. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  50438. * * 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
  50439. * * 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
  50440. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  50441. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50442. * * If you create a double-sided mesh, you can choose what parts of 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
  50443. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  50444. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50445. * @param name defines the name of the mesh
  50446. * @param options defines the options used to create the mesh
  50447. * @param scene defines the hosting scene
  50448. * @returns the extruded shape mesh
  50449. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50450. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  50451. */
  50452. static ExtrudeShape(name: string, options: {
  50453. shape: Vector3[];
  50454. path: Vector3[];
  50455. scale?: number;
  50456. rotation?: number;
  50457. cap?: number;
  50458. updatable?: boolean;
  50459. sideOrientation?: number;
  50460. frontUVs?: Vector4;
  50461. backUVs?: Vector4;
  50462. instance?: Mesh;
  50463. invertUV?: boolean;
  50464. }, scene?: Nullable<Scene>): Mesh;
  50465. /**
  50466. * Creates an custom extruded shape mesh.
  50467. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  50468. * * 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.
  50469. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  50470. * * 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
  50471. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  50472. * * 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
  50473. * * It must returns a float value that will be the scale value applied to the shape on each path point
  50474. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  50475. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  50476. * * 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
  50477. * * 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
  50478. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  50479. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50480. * * If you create a double-sided mesh, you can choose what parts of 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
  50481. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50482. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50483. * @param name defines the name of the mesh
  50484. * @param options defines the options used to create the mesh
  50485. * @param scene defines the hosting scene
  50486. * @returns the custom extruded shape mesh
  50487. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  50488. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50489. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  50490. */
  50491. static ExtrudeShapeCustom(name: string, options: {
  50492. shape: Vector3[];
  50493. path: Vector3[];
  50494. scaleFunction?: any;
  50495. rotationFunction?: any;
  50496. ribbonCloseArray?: boolean;
  50497. ribbonClosePath?: boolean;
  50498. cap?: number;
  50499. updatable?: boolean;
  50500. sideOrientation?: number;
  50501. frontUVs?: Vector4;
  50502. backUVs?: Vector4;
  50503. instance?: Mesh;
  50504. invertUV?: boolean;
  50505. }, scene: Scene): Mesh;
  50506. /**
  50507. * Creates lathe mesh.
  50508. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  50509. * * 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
  50510. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  50511. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  50512. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  50513. * * 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
  50514. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  50515. * * 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
  50516. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50517. * * If you create a double-sided mesh, you can choose what parts of 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
  50518. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50519. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50520. * @param name defines the name of the mesh
  50521. * @param options defines the options used to create the mesh
  50522. * @param scene defines the hosting scene
  50523. * @returns the lathe mesh
  50524. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  50525. */
  50526. static CreateLathe(name: string, options: {
  50527. shape: Vector3[];
  50528. radius?: number;
  50529. tessellation?: number;
  50530. clip?: number;
  50531. arc?: number;
  50532. closed?: boolean;
  50533. updatable?: boolean;
  50534. sideOrientation?: number;
  50535. frontUVs?: Vector4;
  50536. backUVs?: Vector4;
  50537. cap?: number;
  50538. invertUV?: boolean;
  50539. }, scene: Scene): Mesh;
  50540. /**
  50541. * Creates a plane mesh
  50542. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  50543. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  50544. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  50545. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50546. * * If you create a double-sided mesh, you can choose what parts of 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
  50547. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50548. * @param name defines the name of the mesh
  50549. * @param options defines the options used to create the mesh
  50550. * @param scene defines the hosting scene
  50551. * @returns the plane mesh
  50552. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  50553. */
  50554. static CreatePlane(name: string, options: {
  50555. size?: number;
  50556. width?: number;
  50557. height?: number;
  50558. sideOrientation?: number;
  50559. frontUVs?: Vector4;
  50560. backUVs?: Vector4;
  50561. updatable?: boolean;
  50562. sourcePlane?: Plane;
  50563. }, scene: Scene): Mesh;
  50564. /**
  50565. * Creates a ground mesh
  50566. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  50567. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  50568. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50569. * @param name defines the name of the mesh
  50570. * @param options defines the options used to create the mesh
  50571. * @param scene defines the hosting scene
  50572. * @returns the ground mesh
  50573. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  50574. */
  50575. static CreateGround(name: string, options: {
  50576. width?: number;
  50577. height?: number;
  50578. subdivisions?: number;
  50579. subdivisionsX?: number;
  50580. subdivisionsY?: number;
  50581. updatable?: boolean;
  50582. }, scene: any): Mesh;
  50583. /**
  50584. * Creates a tiled ground mesh
  50585. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  50586. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  50587. * * 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
  50588. * * 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
  50589. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50590. * @param name defines the name of the mesh
  50591. * @param options defines the options used to create the mesh
  50592. * @param scene defines the hosting scene
  50593. * @returns the tiled ground mesh
  50594. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  50595. */
  50596. static CreateTiledGround(name: string, options: {
  50597. xmin: number;
  50598. zmin: number;
  50599. xmax: number;
  50600. zmax: number;
  50601. subdivisions?: {
  50602. w: number;
  50603. h: number;
  50604. };
  50605. precision?: {
  50606. w: number;
  50607. h: number;
  50608. };
  50609. updatable?: boolean;
  50610. }, scene: Scene): Mesh;
  50611. /**
  50612. * Creates a ground mesh from a height map
  50613. * * The parameter `url` sets the URL of the height map image resource.
  50614. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  50615. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  50616. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  50617. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  50618. * * 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.
  50619. * * 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).
  50620. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  50621. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50622. * @param name defines the name of the mesh
  50623. * @param url defines the url to the height map
  50624. * @param options defines the options used to create the mesh
  50625. * @param scene defines the hosting scene
  50626. * @returns the ground mesh
  50627. * @see https://doc.babylonjs.com/babylon101/height_map
  50628. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  50629. */
  50630. static CreateGroundFromHeightMap(name: string, url: string, options: {
  50631. width?: number;
  50632. height?: number;
  50633. subdivisions?: number;
  50634. minHeight?: number;
  50635. maxHeight?: number;
  50636. colorFilter?: Color3;
  50637. alphaFilter?: number;
  50638. updatable?: boolean;
  50639. onReady?: (mesh: GroundMesh) => void;
  50640. }, scene: Scene): GroundMesh;
  50641. /**
  50642. * Creates a polygon mesh
  50643. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  50644. * * 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
  50645. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  50646. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50647. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  50648. * * Remember you can only change the shape positions, not their number when updating a polygon
  50649. * @param name defines the name of the mesh
  50650. * @param options defines the options used to create the mesh
  50651. * @param scene defines the hosting scene
  50652. * @param earcutInjection can be used to inject your own earcut reference
  50653. * @returns the polygon mesh
  50654. */
  50655. static CreatePolygon(name: string, options: {
  50656. shape: Vector3[];
  50657. holes?: Vector3[][];
  50658. depth?: number;
  50659. faceUV?: Vector4[];
  50660. faceColors?: Color4[];
  50661. updatable?: boolean;
  50662. sideOrientation?: number;
  50663. frontUVs?: Vector4;
  50664. backUVs?: Vector4;
  50665. }, scene: Scene, earcutInjection?: any): Mesh;
  50666. /**
  50667. * Creates an extruded polygon mesh, with depth in the Y direction.
  50668. * * 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)
  50669. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  50670. * @param name defines the name of the mesh
  50671. * @param options defines the options used to create the mesh
  50672. * @param scene defines the hosting scene
  50673. * @param earcutInjection can be used to inject your own earcut reference
  50674. * @returns the polygon mesh
  50675. */
  50676. static ExtrudePolygon(name: string, options: {
  50677. shape: Vector3[];
  50678. holes?: Vector3[][];
  50679. depth?: number;
  50680. faceUV?: Vector4[];
  50681. faceColors?: Color4[];
  50682. updatable?: boolean;
  50683. sideOrientation?: number;
  50684. frontUVs?: Vector4;
  50685. backUVs?: Vector4;
  50686. }, scene: Scene, earcutInjection?: any): Mesh;
  50687. /**
  50688. * Creates a tube mesh.
  50689. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  50690. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  50691. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  50692. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  50693. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  50694. * * 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)
  50695. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  50696. * * 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
  50697. * * 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
  50698. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50699. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50700. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50701. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50702. * @param name defines the name of the mesh
  50703. * @param options defines the options used to create the mesh
  50704. * @param scene defines the hosting scene
  50705. * @returns the tube mesh
  50706. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50707. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  50708. */
  50709. static CreateTube(name: string, options: {
  50710. path: Vector3[];
  50711. radius?: number;
  50712. tessellation?: number;
  50713. radiusFunction?: {
  50714. (i: number, distance: number): number;
  50715. };
  50716. cap?: number;
  50717. arc?: number;
  50718. updatable?: boolean;
  50719. sideOrientation?: number;
  50720. frontUVs?: Vector4;
  50721. backUVs?: Vector4;
  50722. instance?: Mesh;
  50723. invertUV?: boolean;
  50724. }, scene: Scene): Mesh;
  50725. /**
  50726. * Creates a polyhedron mesh
  50727. * * 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
  50728. * * The parameter `size` (positive float, default 1) sets the polygon size
  50729. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  50730. * * 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`
  50731. * * 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
  50732. * * 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)`)
  50733. * * 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
  50734. * * 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
  50735. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50736. * * If you create a double-sided mesh, you can choose what parts of 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
  50737. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50738. * @param name defines the name of the mesh
  50739. * @param options defines the options used to create the mesh
  50740. * @param scene defines the hosting scene
  50741. * @returns the polyhedron mesh
  50742. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  50743. */
  50744. static CreatePolyhedron(name: string, options: {
  50745. type?: number;
  50746. size?: number;
  50747. sizeX?: number;
  50748. sizeY?: number;
  50749. sizeZ?: number;
  50750. custom?: any;
  50751. faceUV?: Vector4[];
  50752. faceColors?: Color4[];
  50753. flat?: boolean;
  50754. updatable?: boolean;
  50755. sideOrientation?: number;
  50756. frontUVs?: Vector4;
  50757. backUVs?: Vector4;
  50758. }, scene: Scene): Mesh;
  50759. /**
  50760. * Creates a decal mesh.
  50761. * 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
  50762. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  50763. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  50764. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  50765. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  50766. * @param name defines the name of the mesh
  50767. * @param sourceMesh defines the mesh where the decal must be applied
  50768. * @param options defines the options used to create the mesh
  50769. * @param scene defines the hosting scene
  50770. * @returns the decal mesh
  50771. * @see https://doc.babylonjs.com/how_to/decals
  50772. */
  50773. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  50774. position?: Vector3;
  50775. normal?: Vector3;
  50776. size?: Vector3;
  50777. angle?: number;
  50778. }): Mesh;
  50779. }
  50780. }
  50781. declare module "babylonjs/Meshes/meshSimplification" {
  50782. import { Mesh } from "babylonjs/Meshes/mesh";
  50783. /**
  50784. * A simplifier interface for future simplification implementations
  50785. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  50786. */
  50787. export interface ISimplifier {
  50788. /**
  50789. * Simplification of a given mesh according to the given settings.
  50790. * Since this requires computation, it is assumed that the function runs async.
  50791. * @param settings The settings of the simplification, including quality and distance
  50792. * @param successCallback A callback that will be called after the mesh was simplified.
  50793. * @param errorCallback in case of an error, this callback will be called. optional.
  50794. */
  50795. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  50796. }
  50797. /**
  50798. * Expected simplification settings.
  50799. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  50800. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  50801. */
  50802. export interface ISimplificationSettings {
  50803. /**
  50804. * Gets or sets the expected quality
  50805. */
  50806. quality: number;
  50807. /**
  50808. * Gets or sets the distance when this optimized version should be used
  50809. */
  50810. distance: number;
  50811. /**
  50812. * Gets an already optimized mesh
  50813. */
  50814. optimizeMesh?: boolean;
  50815. }
  50816. /**
  50817. * Class used to specify simplification options
  50818. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  50819. */
  50820. export class SimplificationSettings implements ISimplificationSettings {
  50821. /** expected quality */
  50822. quality: number;
  50823. /** distance when this optimized version should be used */
  50824. distance: number;
  50825. /** already optimized mesh */
  50826. optimizeMesh?: boolean | undefined;
  50827. /**
  50828. * Creates a SimplificationSettings
  50829. * @param quality expected quality
  50830. * @param distance distance when this optimized version should be used
  50831. * @param optimizeMesh already optimized mesh
  50832. */
  50833. constructor(
  50834. /** expected quality */
  50835. quality: number,
  50836. /** distance when this optimized version should be used */
  50837. distance: number,
  50838. /** already optimized mesh */
  50839. optimizeMesh?: boolean | undefined);
  50840. }
  50841. /**
  50842. * Interface used to define a simplification task
  50843. */
  50844. export interface ISimplificationTask {
  50845. /**
  50846. * Array of settings
  50847. */
  50848. settings: Array<ISimplificationSettings>;
  50849. /**
  50850. * Simplification type
  50851. */
  50852. simplificationType: SimplificationType;
  50853. /**
  50854. * Mesh to simplify
  50855. */
  50856. mesh: Mesh;
  50857. /**
  50858. * Callback called on success
  50859. */
  50860. successCallback?: () => void;
  50861. /**
  50862. * Defines if parallel processing can be used
  50863. */
  50864. parallelProcessing: boolean;
  50865. }
  50866. /**
  50867. * Queue used to order the simplification tasks
  50868. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  50869. */
  50870. export class SimplificationQueue {
  50871. private _simplificationArray;
  50872. /**
  50873. * Gets a boolean indicating that the process is still running
  50874. */
  50875. running: boolean;
  50876. /**
  50877. * Creates a new queue
  50878. */
  50879. constructor();
  50880. /**
  50881. * Adds a new simplification task
  50882. * @param task defines a task to add
  50883. */
  50884. addTask(task: ISimplificationTask): void;
  50885. /**
  50886. * Execute next task
  50887. */
  50888. executeNext(): void;
  50889. /**
  50890. * Execute a simplification task
  50891. * @param task defines the task to run
  50892. */
  50893. runSimplification(task: ISimplificationTask): void;
  50894. private getSimplifier;
  50895. }
  50896. /**
  50897. * The implemented types of simplification
  50898. * At the moment only Quadratic Error Decimation is implemented
  50899. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  50900. */
  50901. export enum SimplificationType {
  50902. /** Quadratic error decimation */
  50903. QUADRATIC = 0
  50904. }
  50905. }
  50906. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  50907. import { Scene } from "babylonjs/scene";
  50908. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  50909. import { ISceneComponent } from "babylonjs/sceneComponent";
  50910. module "babylonjs/scene" {
  50911. interface Scene {
  50912. /** @hidden (Backing field) */
  50913. _simplificationQueue: SimplificationQueue;
  50914. /**
  50915. * Gets or sets the simplification queue attached to the scene
  50916. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  50917. */
  50918. simplificationQueue: SimplificationQueue;
  50919. }
  50920. }
  50921. module "babylonjs/Meshes/mesh" {
  50922. interface Mesh {
  50923. /**
  50924. * Simplify the mesh according to the given array of settings.
  50925. * Function will return immediately and will simplify async
  50926. * @param settings a collection of simplification settings
  50927. * @param parallelProcessing should all levels calculate parallel or one after the other
  50928. * @param simplificationType the type of simplification to run
  50929. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  50930. * @returns the current mesh
  50931. */
  50932. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  50933. }
  50934. }
  50935. /**
  50936. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  50937. * created in a scene
  50938. */
  50939. export class SimplicationQueueSceneComponent implements ISceneComponent {
  50940. /**
  50941. * The component name helpfull to identify the component in the list of scene components.
  50942. */
  50943. readonly name: string;
  50944. /**
  50945. * The scene the component belongs to.
  50946. */
  50947. scene: Scene;
  50948. /**
  50949. * Creates a new instance of the component for the given scene
  50950. * @param scene Defines the scene to register the component in
  50951. */
  50952. constructor(scene: Scene);
  50953. /**
  50954. * Registers the component in a given scene
  50955. */
  50956. register(): void;
  50957. /**
  50958. * Rebuilds the elements related to this component in case of
  50959. * context lost for instance.
  50960. */
  50961. rebuild(): void;
  50962. /**
  50963. * Disposes the component and the associated ressources
  50964. */
  50965. dispose(): void;
  50966. private _beforeCameraUpdate;
  50967. }
  50968. }
  50969. declare module "babylonjs/Meshes/Builders/index" {
  50970. export * from "babylonjs/Meshes/Builders/boxBuilder";
  50971. export * from "babylonjs/Meshes/Builders/discBuilder";
  50972. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  50973. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  50974. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  50975. export * from "babylonjs/Meshes/Builders/torusBuilder";
  50976. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  50977. export * from "babylonjs/Meshes/Builders/linesBuilder";
  50978. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  50979. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  50980. export * from "babylonjs/Meshes/Builders/latheBuilder";
  50981. export * from "babylonjs/Meshes/Builders/planeBuilder";
  50982. export * from "babylonjs/Meshes/Builders/groundBuilder";
  50983. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  50984. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  50985. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  50986. export * from "babylonjs/Meshes/Builders/decalBuilder";
  50987. }
  50988. declare module "babylonjs/Meshes/index" {
  50989. export * from "babylonjs/Meshes/abstractMesh";
  50990. export * from "babylonjs/Meshes/buffer";
  50991. export * from "babylonjs/Meshes/Compression/index";
  50992. export * from "babylonjs/Meshes/csg";
  50993. export * from "babylonjs/Meshes/geometry";
  50994. export * from "babylonjs/Meshes/groundMesh";
  50995. export * from "babylonjs/Meshes/trailMesh";
  50996. export * from "babylonjs/Meshes/instancedMesh";
  50997. export * from "babylonjs/Meshes/linesMesh";
  50998. export * from "babylonjs/Meshes/mesh";
  50999. export * from "babylonjs/Meshes/mesh.vertexData";
  51000. export * from "babylonjs/Meshes/meshBuilder";
  51001. export * from "babylonjs/Meshes/meshSimplification";
  51002. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  51003. export * from "babylonjs/Meshes/polygonMesh";
  51004. export * from "babylonjs/Meshes/subMesh";
  51005. export * from "babylonjs/Meshes/transformNode";
  51006. export * from "babylonjs/Meshes/Builders/index";
  51007. }
  51008. declare module "babylonjs/Morph/index" {
  51009. export * from "babylonjs/Morph/morphTarget";
  51010. export * from "babylonjs/Morph/morphTargetManager";
  51011. }
  51012. declare module "babylonjs/Offline/database" {
  51013. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  51014. /**
  51015. * Class used to enable access to IndexedDB
  51016. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  51017. */
  51018. export class Database implements IOfflineProvider {
  51019. private _callbackManifestChecked;
  51020. private _currentSceneUrl;
  51021. private _db;
  51022. private _enableSceneOffline;
  51023. private _enableTexturesOffline;
  51024. private _manifestVersionFound;
  51025. private _mustUpdateRessources;
  51026. private _hasReachedQuota;
  51027. private _isSupported;
  51028. private _idbFactory;
  51029. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  51030. private static IsUASupportingBlobStorage;
  51031. /**
  51032. * Gets a boolean indicating if Database storate is enabled (off by default)
  51033. */
  51034. static IDBStorageEnabled: boolean;
  51035. /**
  51036. * Gets a boolean indicating if scene must be saved in the database
  51037. */
  51038. readonly enableSceneOffline: boolean;
  51039. /**
  51040. * Gets a boolean indicating if textures must be saved in the database
  51041. */
  51042. readonly enableTexturesOffline: boolean;
  51043. /**
  51044. * Creates a new Database
  51045. * @param urlToScene defines the url to load the scene
  51046. * @param callbackManifestChecked defines the callback to use when manifest is checked
  51047. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  51048. */
  51049. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  51050. private static _ParseURL;
  51051. private static _ReturnFullUrlLocation;
  51052. private _checkManifestFile;
  51053. /**
  51054. * Open the database and make it available
  51055. * @param successCallback defines the callback to call on success
  51056. * @param errorCallback defines the callback to call on error
  51057. */
  51058. open(successCallback: () => void, errorCallback: () => void): void;
  51059. /**
  51060. * Loads an image from the database
  51061. * @param url defines the url to load from
  51062. * @param image defines the target DOM image
  51063. */
  51064. loadImage(url: string, image: HTMLImageElement): void;
  51065. private _loadImageFromDBAsync;
  51066. private _saveImageIntoDBAsync;
  51067. private _checkVersionFromDB;
  51068. private _loadVersionFromDBAsync;
  51069. private _saveVersionIntoDBAsync;
  51070. /**
  51071. * Loads a file from database
  51072. * @param url defines the URL to load from
  51073. * @param sceneLoaded defines a callback to call on success
  51074. * @param progressCallBack defines a callback to call when progress changed
  51075. * @param errorCallback defines a callback to call on error
  51076. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  51077. */
  51078. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  51079. private _loadFileAsync;
  51080. private _saveFileAsync;
  51081. /**
  51082. * Validates if xhr data is correct
  51083. * @param xhr defines the request to validate
  51084. * @param dataType defines the expected data type
  51085. * @returns true if data is correct
  51086. */
  51087. private static _ValidateXHRData;
  51088. }
  51089. }
  51090. declare module "babylonjs/Offline/index" {
  51091. export * from "babylonjs/Offline/database";
  51092. export * from "babylonjs/Offline/IOfflineProvider";
  51093. }
  51094. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  51095. /** @hidden */
  51096. export var gpuUpdateParticlesPixelShader: {
  51097. name: string;
  51098. shader: string;
  51099. };
  51100. }
  51101. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  51102. /** @hidden */
  51103. export var gpuUpdateParticlesVertexShader: {
  51104. name: string;
  51105. shader: string;
  51106. };
  51107. }
  51108. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  51109. /** @hidden */
  51110. export var clipPlaneFragmentDeclaration2: {
  51111. name: string;
  51112. shader: string;
  51113. };
  51114. }
  51115. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  51116. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  51117. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  51118. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  51119. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  51120. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  51121. /** @hidden */
  51122. export var gpuRenderParticlesPixelShader: {
  51123. name: string;
  51124. shader: string;
  51125. };
  51126. }
  51127. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  51128. /** @hidden */
  51129. export var clipPlaneVertexDeclaration2: {
  51130. name: string;
  51131. shader: string;
  51132. };
  51133. }
  51134. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  51135. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  51136. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  51137. /** @hidden */
  51138. export var gpuRenderParticlesVertexShader: {
  51139. name: string;
  51140. shader: string;
  51141. };
  51142. }
  51143. declare module "babylonjs/Particles/gpuParticleSystem" {
  51144. import { Nullable } from "babylonjs/types";
  51145. import { IAnimatable, IValueGradient, Color3Gradient } from "babylonjs/Misc/tools";
  51146. import { Observable } from "babylonjs/Misc/observable";
  51147. import { Color4, Color3 } from "babylonjs/Maths/math";
  51148. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  51149. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  51150. import { Scene, IDisposable } from "babylonjs/scene";
  51151. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  51152. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  51153. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  51154. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  51155. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  51156. /**
  51157. * This represents a GPU particle system in Babylon
  51158. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  51159. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  51160. */
  51161. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  51162. /**
  51163. * The layer mask we are rendering the particles through.
  51164. */
  51165. layerMask: number;
  51166. private _capacity;
  51167. private _activeCount;
  51168. private _currentActiveCount;
  51169. private _accumulatedCount;
  51170. private _renderEffect;
  51171. private _updateEffect;
  51172. private _buffer0;
  51173. private _buffer1;
  51174. private _spriteBuffer;
  51175. private _updateVAO;
  51176. private _renderVAO;
  51177. private _targetIndex;
  51178. private _sourceBuffer;
  51179. private _targetBuffer;
  51180. private _engine;
  51181. private _currentRenderId;
  51182. private _started;
  51183. private _stopped;
  51184. private _timeDelta;
  51185. private _randomTexture;
  51186. private _randomTexture2;
  51187. private _attributesStrideSize;
  51188. private _updateEffectOptions;
  51189. private _randomTextureSize;
  51190. private _actualFrame;
  51191. private readonly _rawTextureWidth;
  51192. /**
  51193. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  51194. */
  51195. static readonly IsSupported: boolean;
  51196. /**
  51197. * An event triggered when the system is disposed.
  51198. */
  51199. onDisposeObservable: Observable<GPUParticleSystem>;
  51200. /**
  51201. * Gets the maximum number of particles active at the same time.
  51202. * @returns The max number of active particles.
  51203. */
  51204. getCapacity(): number;
  51205. /**
  51206. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  51207. * to override the particles.
  51208. */
  51209. forceDepthWrite: boolean;
  51210. /**
  51211. * Gets or set the number of active particles
  51212. */
  51213. activeParticleCount: number;
  51214. private _preWarmDone;
  51215. /**
  51216. * Is this system ready to be used/rendered
  51217. * @return true if the system is ready
  51218. */
  51219. isReady(): boolean;
  51220. /**
  51221. * Gets if the system has been started. (Note: this will still be true after stop is called)
  51222. * @returns True if it has been started, otherwise false.
  51223. */
  51224. isStarted(): boolean;
  51225. /**
  51226. * Starts the particle system and begins to emit
  51227. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  51228. */
  51229. start(delay?: number): void;
  51230. /**
  51231. * Stops the particle system.
  51232. */
  51233. stop(): void;
  51234. /**
  51235. * Remove all active particles
  51236. */
  51237. reset(): void;
  51238. /**
  51239. * Returns the string "GPUParticleSystem"
  51240. * @returns a string containing the class name
  51241. */
  51242. getClassName(): string;
  51243. private _colorGradientsTexture;
  51244. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  51245. /**
  51246. * Adds a new color gradient
  51247. * @param gradient defines the gradient to use (between 0 and 1)
  51248. * @param color1 defines the color to affect to the specified gradient
  51249. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  51250. * @returns the current particle system
  51251. */
  51252. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  51253. /**
  51254. * Remove a specific color gradient
  51255. * @param gradient defines the gradient to remove
  51256. * @returns the current particle system
  51257. */
  51258. removeColorGradient(gradient: number): GPUParticleSystem;
  51259. private _angularSpeedGradientsTexture;
  51260. private _sizeGradientsTexture;
  51261. private _velocityGradientsTexture;
  51262. private _limitVelocityGradientsTexture;
  51263. private _dragGradientsTexture;
  51264. private _addFactorGradient;
  51265. /**
  51266. * Adds a new size gradient
  51267. * @param gradient defines the gradient to use (between 0 and 1)
  51268. * @param factor defines the size factor to affect to the specified gradient
  51269. * @returns the current particle system
  51270. */
  51271. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  51272. /**
  51273. * Remove a specific size gradient
  51274. * @param gradient defines the gradient to remove
  51275. * @returns the current particle system
  51276. */
  51277. removeSizeGradient(gradient: number): GPUParticleSystem;
  51278. /**
  51279. * Adds a new angular speed gradient
  51280. * @param gradient defines the gradient to use (between 0 and 1)
  51281. * @param factor defines the angular speed to affect to the specified gradient
  51282. * @returns the current particle system
  51283. */
  51284. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  51285. /**
  51286. * Remove a specific angular speed gradient
  51287. * @param gradient defines the gradient to remove
  51288. * @returns the current particle system
  51289. */
  51290. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  51291. /**
  51292. * Adds a new velocity gradient
  51293. * @param gradient defines the gradient to use (between 0 and 1)
  51294. * @param factor defines the velocity to affect to the specified gradient
  51295. * @returns the current particle system
  51296. */
  51297. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  51298. /**
  51299. * Remove a specific velocity gradient
  51300. * @param gradient defines the gradient to remove
  51301. * @returns the current particle system
  51302. */
  51303. removeVelocityGradient(gradient: number): GPUParticleSystem;
  51304. /**
  51305. * Adds a new limit velocity gradient
  51306. * @param gradient defines the gradient to use (between 0 and 1)
  51307. * @param factor defines the limit velocity value to affect to the specified gradient
  51308. * @returns the current particle system
  51309. */
  51310. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  51311. /**
  51312. * Remove a specific limit velocity gradient
  51313. * @param gradient defines the gradient to remove
  51314. * @returns the current particle system
  51315. */
  51316. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  51317. /**
  51318. * Adds a new drag gradient
  51319. * @param gradient defines the gradient to use (between 0 and 1)
  51320. * @param factor defines the drag value to affect to the specified gradient
  51321. * @returns the current particle system
  51322. */
  51323. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  51324. /**
  51325. * Remove a specific drag gradient
  51326. * @param gradient defines the gradient to remove
  51327. * @returns the current particle system
  51328. */
  51329. removeDragGradient(gradient: number): GPUParticleSystem;
  51330. /**
  51331. * Not supported by GPUParticleSystem
  51332. * @param gradient defines the gradient to use (between 0 and 1)
  51333. * @param factor defines the emit rate value to affect to the specified gradient
  51334. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  51335. * @returns the current particle system
  51336. */
  51337. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  51338. /**
  51339. * Not supported by GPUParticleSystem
  51340. * @param gradient defines the gradient to remove
  51341. * @returns the current particle system
  51342. */
  51343. removeEmitRateGradient(gradient: number): IParticleSystem;
  51344. /**
  51345. * Not supported by GPUParticleSystem
  51346. * @param gradient defines the gradient to use (between 0 and 1)
  51347. * @param factor defines the start size value to affect to the specified gradient
  51348. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  51349. * @returns the current particle system
  51350. */
  51351. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  51352. /**
  51353. * Not supported by GPUParticleSystem
  51354. * @param gradient defines the gradient to remove
  51355. * @returns the current particle system
  51356. */
  51357. removeStartSizeGradient(gradient: number): IParticleSystem;
  51358. /**
  51359. * Not supported by GPUParticleSystem
  51360. * @param gradient defines the gradient to use (between 0 and 1)
  51361. * @param min defines the color remap minimal range
  51362. * @param max defines the color remap maximal range
  51363. * @returns the current particle system
  51364. */
  51365. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  51366. /**
  51367. * Not supported by GPUParticleSystem
  51368. * @param gradient defines the gradient to remove
  51369. * @returns the current particle system
  51370. */
  51371. removeColorRemapGradient(): IParticleSystem;
  51372. /**
  51373. * Not supported by GPUParticleSystem
  51374. * @param gradient defines the gradient to use (between 0 and 1)
  51375. * @param min defines the alpha remap minimal range
  51376. * @param max defines the alpha remap maximal range
  51377. * @returns the current particle system
  51378. */
  51379. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  51380. /**
  51381. * Not supported by GPUParticleSystem
  51382. * @param gradient defines the gradient to remove
  51383. * @returns the current particle system
  51384. */
  51385. removeAlphaRemapGradient(): IParticleSystem;
  51386. /**
  51387. * Not supported by GPUParticleSystem
  51388. * @param gradient defines the gradient to use (between 0 and 1)
  51389. * @param color defines the color to affect to the specified gradient
  51390. * @returns the current particle system
  51391. */
  51392. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  51393. /**
  51394. * Not supported by GPUParticleSystem
  51395. * @param gradient defines the gradient to remove
  51396. * @returns the current particle system
  51397. */
  51398. removeRampGradient(): IParticleSystem;
  51399. /**
  51400. * Not supported by GPUParticleSystem
  51401. * @returns the list of ramp gradients
  51402. */
  51403. getRampGradients(): Nullable<Array<Color3Gradient>>;
  51404. /**
  51405. * Not supported by GPUParticleSystem
  51406. * Gets or sets a boolean indicating that ramp gradients must be used
  51407. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  51408. */
  51409. useRampGradients: boolean;
  51410. /**
  51411. * Not supported by GPUParticleSystem
  51412. * @param gradient defines the gradient to use (between 0 and 1)
  51413. * @param factor defines the life time factor to affect to the specified gradient
  51414. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  51415. * @returns the current particle system
  51416. */
  51417. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  51418. /**
  51419. * Not supported by GPUParticleSystem
  51420. * @param gradient defines the gradient to remove
  51421. * @returns the current particle system
  51422. */
  51423. removeLifeTimeGradient(gradient: number): IParticleSystem;
  51424. /**
  51425. * Instantiates a GPU particle system.
  51426. * 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.
  51427. * @param name The name of the particle system
  51428. * @param options The options used to create the system
  51429. * @param scene The scene the particle system belongs to
  51430. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  51431. */
  51432. constructor(name: string, options: Partial<{
  51433. capacity: number;
  51434. randomTextureSize: number;
  51435. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  51436. protected _reset(): void;
  51437. private _createUpdateVAO;
  51438. private _createRenderVAO;
  51439. private _initialize;
  51440. /** @hidden */
  51441. _recreateUpdateEffect(): void;
  51442. /** @hidden */
  51443. _recreateRenderEffect(): void;
  51444. /**
  51445. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  51446. * @param preWarm defines if we are in the pre-warmimg phase
  51447. */
  51448. animate(preWarm?: boolean): void;
  51449. private _createFactorGradientTexture;
  51450. private _createSizeGradientTexture;
  51451. private _createAngularSpeedGradientTexture;
  51452. private _createVelocityGradientTexture;
  51453. private _createLimitVelocityGradientTexture;
  51454. private _createDragGradientTexture;
  51455. private _createColorGradientTexture;
  51456. /**
  51457. * Renders the particle system in its current state
  51458. * @param preWarm defines if the system should only update the particles but not render them
  51459. * @returns the current number of particles
  51460. */
  51461. render(preWarm?: boolean): number;
  51462. /**
  51463. * Rebuilds the particle system
  51464. */
  51465. rebuild(): void;
  51466. private _releaseBuffers;
  51467. private _releaseVAOs;
  51468. /**
  51469. * Disposes the particle system and free the associated resources
  51470. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  51471. */
  51472. dispose(disposeTexture?: boolean): void;
  51473. /**
  51474. * Clones the particle system.
  51475. * @param name The name of the cloned object
  51476. * @param newEmitter The new emitter to use
  51477. * @returns the cloned particle system
  51478. */
  51479. clone(name: string, newEmitter: any): GPUParticleSystem;
  51480. /**
  51481. * Serializes the particle system to a JSON object.
  51482. * @returns the JSON object
  51483. */
  51484. serialize(): any;
  51485. /**
  51486. * Parses a JSON object to create a GPU particle system.
  51487. * @param parsedParticleSystem The JSON object to parse
  51488. * @param scene The scene to create the particle system in
  51489. * @param rootUrl The root url to use to load external dependencies like texture
  51490. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  51491. * @returns the parsed GPU particle system
  51492. */
  51493. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  51494. }
  51495. }
  51496. declare module "babylonjs/Particles/particleSystemSet" {
  51497. import { Nullable } from "babylonjs/types";
  51498. import { Color3 } from "babylonjs/Maths/math";
  51499. import { TransformNode } from "babylonjs/Meshes/transformNode";
  51500. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51501. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  51502. import { Scene, IDisposable } from "babylonjs/scene";
  51503. /**
  51504. * Represents a set of particle systems working together to create a specific effect
  51505. */
  51506. export class ParticleSystemSet implements IDisposable {
  51507. private _emitterCreationOptions;
  51508. private _emitterNode;
  51509. /**
  51510. * Gets the particle system list
  51511. */
  51512. systems: IParticleSystem[];
  51513. /**
  51514. * Gets the emitter node used with this set
  51515. */
  51516. readonly emitterNode: Nullable<TransformNode>;
  51517. /**
  51518. * Creates a new emitter mesh as a sphere
  51519. * @param options defines the options used to create the sphere
  51520. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  51521. * @param scene defines the hosting scene
  51522. */
  51523. setEmitterAsSphere(options: {
  51524. diameter: number;
  51525. segments: number;
  51526. color: Color3;
  51527. }, renderingGroupId: number, scene: Scene): void;
  51528. /**
  51529. * Starts all particle systems of the set
  51530. * @param emitter defines an optional mesh to use as emitter for the particle systems
  51531. */
  51532. start(emitter?: AbstractMesh): void;
  51533. /**
  51534. * Release all associated resources
  51535. */
  51536. dispose(): void;
  51537. /**
  51538. * Serialize the set into a JSON compatible object
  51539. * @returns a JSON compatible representation of the set
  51540. */
  51541. serialize(): any;
  51542. /**
  51543. * Parse a new ParticleSystemSet from a serialized source
  51544. * @param data defines a JSON compatible representation of the set
  51545. * @param scene defines the hosting scene
  51546. * @param gpu defines if we want GPU particles or CPU particles
  51547. * @returns a new ParticleSystemSet
  51548. */
  51549. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  51550. }
  51551. }
  51552. declare module "babylonjs/Particles/particleHelper" {
  51553. import { Nullable } from "babylonjs/types";
  51554. import { Scene } from "babylonjs/scene";
  51555. import { Vector3 } from "babylonjs/Maths/math";
  51556. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51557. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  51558. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  51559. /**
  51560. * This class is made for on one-liner static method to help creating particle system set.
  51561. */
  51562. export class ParticleHelper {
  51563. /**
  51564. * Gets or sets base Assets URL
  51565. */
  51566. static BaseAssetsUrl: string;
  51567. /**
  51568. * Create a default particle system that you can tweak
  51569. * @param emitter defines the emitter to use
  51570. * @param capacity defines the system capacity (default is 500 particles)
  51571. * @param scene defines the hosting scene
  51572. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  51573. * @returns the new Particle system
  51574. */
  51575. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  51576. /**
  51577. * This is the main static method (one-liner) of this helper to create different particle systems
  51578. * @param type This string represents the type to the particle system to create
  51579. * @param scene The scene where the particle system should live
  51580. * @param gpu If the system will use gpu
  51581. * @returns the ParticleSystemSet created
  51582. */
  51583. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  51584. /**
  51585. * Static function used to export a particle system to a ParticleSystemSet variable.
  51586. * Please note that the emitter shape is not exported
  51587. * @param systems defines the particle systems to export
  51588. * @returns the created particle system set
  51589. */
  51590. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  51591. }
  51592. }
  51593. declare module "babylonjs/Particles/particleSystemComponent" {
  51594. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  51595. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  51596. import "babylonjs/Shaders/particles.vertex";
  51597. module "babylonjs/Engines/engine" {
  51598. interface Engine {
  51599. /**
  51600. * Create an effect to use with particle systems.
  51601. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  51602. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  51603. * @param uniformsNames defines a list of attribute names
  51604. * @param samplers defines an array of string used to represent textures
  51605. * @param defines defines the string containing the defines to use to compile the shaders
  51606. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  51607. * @param onCompiled defines a function to call when the effect creation is successful
  51608. * @param onError defines a function to call when the effect creation has failed
  51609. * @returns the new Effect
  51610. */
  51611. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  51612. }
  51613. }
  51614. module "babylonjs/Meshes/mesh" {
  51615. interface Mesh {
  51616. /**
  51617. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  51618. * @returns an array of IParticleSystem
  51619. */
  51620. getEmittedParticleSystems(): IParticleSystem[];
  51621. /**
  51622. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  51623. * @returns an array of IParticleSystem
  51624. */
  51625. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  51626. }
  51627. }
  51628. /**
  51629. * @hidden
  51630. */
  51631. export var _IDoNeedToBeInTheBuild: number;
  51632. }
  51633. declare module "babylonjs/Particles/index" {
  51634. export * from "babylonjs/Particles/baseParticleSystem";
  51635. export * from "babylonjs/Particles/EmitterTypes/index";
  51636. export * from "babylonjs/Particles/gpuParticleSystem";
  51637. export * from "babylonjs/Particles/IParticleSystem";
  51638. export * from "babylonjs/Particles/particle";
  51639. export * from "babylonjs/Particles/particleHelper";
  51640. export * from "babylonjs/Particles/particleSystem";
  51641. export * from "babylonjs/Particles/particleSystemComponent";
  51642. export * from "babylonjs/Particles/particleSystemSet";
  51643. export * from "babylonjs/Particles/solidParticle";
  51644. export * from "babylonjs/Particles/solidParticleSystem";
  51645. export * from "babylonjs/Particles/subEmitter";
  51646. }
  51647. declare module "babylonjs/Physics/physicsEngineComponent" {
  51648. import { Nullable } from "babylonjs/types";
  51649. import { Observable, Observer } from "babylonjs/Misc/observable";
  51650. import { Vector3 } from "babylonjs/Maths/math";
  51651. import { Mesh } from "babylonjs/Meshes/mesh";
  51652. import { ISceneComponent } from "babylonjs/sceneComponent";
  51653. import { Scene } from "babylonjs/scene";
  51654. import { Node } from "babylonjs/node";
  51655. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  51656. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  51657. module "babylonjs/scene" {
  51658. interface Scene {
  51659. /** @hidden (Backing field) */
  51660. _physicsEngine: Nullable<IPhysicsEngine>;
  51661. /**
  51662. * Gets the current physics engine
  51663. * @returns a IPhysicsEngine or null if none attached
  51664. */
  51665. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  51666. /**
  51667. * Enables physics to the current scene
  51668. * @param gravity defines the scene's gravity for the physics engine
  51669. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  51670. * @return a boolean indicating if the physics engine was initialized
  51671. */
  51672. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  51673. /**
  51674. * Disables and disposes the physics engine associated with the scene
  51675. */
  51676. disablePhysicsEngine(): void;
  51677. /**
  51678. * Gets a boolean indicating if there is an active physics engine
  51679. * @returns a boolean indicating if there is an active physics engine
  51680. */
  51681. isPhysicsEnabled(): boolean;
  51682. /**
  51683. * Deletes a physics compound impostor
  51684. * @param compound defines the compound to delete
  51685. */
  51686. deleteCompoundImpostor(compound: any): void;
  51687. /**
  51688. * An event triggered when physic simulation is about to be run
  51689. */
  51690. onBeforePhysicsObservable: Observable<Scene>;
  51691. /**
  51692. * An event triggered when physic simulation has been done
  51693. */
  51694. onAfterPhysicsObservable: Observable<Scene>;
  51695. }
  51696. }
  51697. module "babylonjs/Meshes/abstractMesh" {
  51698. interface AbstractMesh {
  51699. /** @hidden */
  51700. _physicsImpostor: Nullable<PhysicsImpostor>;
  51701. /**
  51702. * Gets or sets impostor used for physic simulation
  51703. * @see http://doc.babylonjs.com/features/physics_engine
  51704. */
  51705. physicsImpostor: Nullable<PhysicsImpostor>;
  51706. /**
  51707. * Gets the current physics impostor
  51708. * @see http://doc.babylonjs.com/features/physics_engine
  51709. * @returns a physics impostor or null
  51710. */
  51711. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  51712. /** Apply a physic impulse to the mesh
  51713. * @param force defines the force to apply
  51714. * @param contactPoint defines where to apply the force
  51715. * @returns the current mesh
  51716. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  51717. */
  51718. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  51719. /**
  51720. * Creates a physic joint between two meshes
  51721. * @param otherMesh defines the other mesh to use
  51722. * @param pivot1 defines the pivot to use on this mesh
  51723. * @param pivot2 defines the pivot to use on the other mesh
  51724. * @param options defines additional options (can be plugin dependent)
  51725. * @returns the current mesh
  51726. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  51727. */
  51728. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  51729. /** @hidden */
  51730. _disposePhysicsObserver: Nullable<Observer<Node>>;
  51731. }
  51732. }
  51733. /**
  51734. * Defines the physics engine scene component responsible to manage a physics engine
  51735. */
  51736. export class PhysicsEngineSceneComponent implements ISceneComponent {
  51737. /**
  51738. * The component name helpful to identify the component in the list of scene components.
  51739. */
  51740. readonly name: string;
  51741. /**
  51742. * The scene the component belongs to.
  51743. */
  51744. scene: Scene;
  51745. /**
  51746. * Creates a new instance of the component for the given scene
  51747. * @param scene Defines the scene to register the component in
  51748. */
  51749. constructor(scene: Scene);
  51750. /**
  51751. * Registers the component in a given scene
  51752. */
  51753. register(): void;
  51754. /**
  51755. * Rebuilds the elements related to this component in case of
  51756. * context lost for instance.
  51757. */
  51758. rebuild(): void;
  51759. /**
  51760. * Disposes the component and the associated ressources
  51761. */
  51762. dispose(): void;
  51763. }
  51764. }
  51765. declare module "babylonjs/Physics/physicsHelper" {
  51766. import { Nullable } from "babylonjs/types";
  51767. import { Vector3 } from "babylonjs/Maths/math";
  51768. import { Mesh } from "babylonjs/Meshes/mesh";
  51769. import { Ray } from "babylonjs/Culling/ray";
  51770. import { Scene } from "babylonjs/scene";
  51771. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  51772. /**
  51773. * A helper for physics simulations
  51774. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  51775. */
  51776. export class PhysicsHelper {
  51777. private _scene;
  51778. private _physicsEngine;
  51779. /**
  51780. * Initializes the Physics helper
  51781. * @param scene Babylon.js scene
  51782. */
  51783. constructor(scene: Scene);
  51784. /**
  51785. * Applies a radial explosion impulse
  51786. * @param origin the origin of the explosion
  51787. * @param radius the explosion radius
  51788. * @param strength the explosion strength
  51789. * @param falloff possible options: Constant & Linear. Defaults to Constant
  51790. * @returns A physics radial explosion event, or null
  51791. */
  51792. applyRadialExplosionImpulse(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  51793. /**
  51794. * Applies a radial explosion force
  51795. * @param origin the origin of the explosion
  51796. * @param radius the explosion radius
  51797. * @param strength the explosion strength
  51798. * @param falloff possible options: Constant & Linear. Defaults to Constant
  51799. * @returns A physics radial explosion event, or null
  51800. */
  51801. applyRadialExplosionForce(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  51802. /**
  51803. * Creates a gravitational field
  51804. * @param origin the origin of the explosion
  51805. * @param radius the explosion radius
  51806. * @param strength the explosion strength
  51807. * @param falloff possible options: Constant & Linear. Defaults to Constant
  51808. * @returns A physics gravitational field event, or null
  51809. */
  51810. gravitationalField(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  51811. /**
  51812. * Creates a physics updraft event
  51813. * @param origin the origin of the updraft
  51814. * @param radius the radius of the updraft
  51815. * @param strength the strength of the updraft
  51816. * @param height the height of the updraft
  51817. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  51818. * @returns A physics updraft event, or null
  51819. */
  51820. updraft(origin: Vector3, radius: number, strength: number, height: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  51821. /**
  51822. * Creates a physics vortex event
  51823. * @param origin the of the vortex
  51824. * @param radius the radius of the vortex
  51825. * @param strength the strength of the vortex
  51826. * @param height the height of the vortex
  51827. * @returns a Physics vortex event, or null
  51828. * A physics vortex event or null
  51829. */
  51830. vortex(origin: Vector3, radius: number, strength: number, height: number): Nullable<PhysicsVortexEvent>;
  51831. }
  51832. /**
  51833. * Represents a physics radial explosion event
  51834. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  51835. */
  51836. export class PhysicsRadialExplosionEvent {
  51837. private _scene;
  51838. private _sphere;
  51839. private _sphereOptions;
  51840. private _rays;
  51841. private _dataFetched;
  51842. /**
  51843. * Initializes a radial explosioin event
  51844. * @param scene BabylonJS scene
  51845. */
  51846. constructor(scene: Scene);
  51847. /**
  51848. * Returns the data related to the radial explosion event (sphere & rays).
  51849. * @returns The radial explosion event data
  51850. */
  51851. getData(): PhysicsRadialExplosionEventData;
  51852. /**
  51853. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  51854. * @param impostor A physics imposter
  51855. * @param origin the origin of the explosion
  51856. * @param radius the explosion radius
  51857. * @param strength the explosion strength
  51858. * @param falloff possible options: Constant & Linear
  51859. * @returns {Nullable<PhysicsForceAndContactPoint>} A physics force and contact point, or null
  51860. */
  51861. getImpostorForceAndContactPoint(impostor: PhysicsImpostor, origin: Vector3, radius: number, strength: number, falloff: PhysicsRadialImpulseFalloff): Nullable<PhysicsForceAndContactPoint>;
  51862. /**
  51863. * Disposes the sphere.
  51864. * @param force Specifies if the sphere should be disposed by force
  51865. */
  51866. dispose(force?: boolean): void;
  51867. /*** Helpers ***/
  51868. private _prepareSphere;
  51869. private _intersectsWithSphere;
  51870. }
  51871. /**
  51872. * Represents a gravitational field event
  51873. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  51874. */
  51875. export class PhysicsGravitationalFieldEvent {
  51876. private _physicsHelper;
  51877. private _scene;
  51878. private _origin;
  51879. private _radius;
  51880. private _strength;
  51881. private _falloff;
  51882. private _tickCallback;
  51883. private _sphere;
  51884. private _dataFetched;
  51885. /**
  51886. * Initializes the physics gravitational field event
  51887. * @param physicsHelper A physics helper
  51888. * @param scene BabylonJS scene
  51889. * @param origin The origin position of the gravitational field event
  51890. * @param radius The radius of the gravitational field event
  51891. * @param strength The strength of the gravitational field event
  51892. * @param falloff The falloff for the gravitational field event
  51893. */
  51894. constructor(physicsHelper: PhysicsHelper, scene: Scene, origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff);
  51895. /**
  51896. * Returns the data related to the gravitational field event (sphere).
  51897. * @returns A gravitational field event
  51898. */
  51899. getData(): PhysicsGravitationalFieldEventData;
  51900. /**
  51901. * Enables the gravitational field.
  51902. */
  51903. enable(): void;
  51904. /**
  51905. * Disables the gravitational field.
  51906. */
  51907. disable(): void;
  51908. /**
  51909. * Disposes the sphere.
  51910. * @param force The force to dispose from the gravitational field event
  51911. */
  51912. dispose(force?: boolean): void;
  51913. private _tick;
  51914. }
  51915. /**
  51916. * Represents a physics updraft event
  51917. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  51918. */
  51919. export class PhysicsUpdraftEvent {
  51920. private _scene;
  51921. private _origin;
  51922. private _radius;
  51923. private _strength;
  51924. private _height;
  51925. private _updraftMode;
  51926. private _physicsEngine;
  51927. private _originTop;
  51928. private _originDirection;
  51929. private _tickCallback;
  51930. private _cylinder;
  51931. private _cylinderPosition;
  51932. private _dataFetched;
  51933. /**
  51934. * Initializes the physics updraft event
  51935. * @param _scene BabylonJS scene
  51936. * @param _origin The origin position of the updraft
  51937. * @param _radius The radius of the updraft
  51938. * @param _strength The strength of the updraft
  51939. * @param _height The height of the updraft
  51940. * @param _updraftMode The mode of the updraft
  51941. */
  51942. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number, _updraftMode: PhysicsUpdraftMode);
  51943. /**
  51944. * Returns the data related to the updraft event (cylinder).
  51945. * @returns A physics updraft event
  51946. */
  51947. getData(): PhysicsUpdraftEventData;
  51948. /**
  51949. * Enables the updraft.
  51950. */
  51951. enable(): void;
  51952. /**
  51953. * Disables the cortex.
  51954. */
  51955. disable(): void;
  51956. /**
  51957. * Disposes the sphere.
  51958. * @param force Specifies if the updraft should be disposed by force
  51959. */
  51960. dispose(force?: boolean): void;
  51961. private getImpostorForceAndContactPoint;
  51962. private _tick;
  51963. /*** Helpers ***/
  51964. private _prepareCylinder;
  51965. private _intersectsWithCylinder;
  51966. }
  51967. /**
  51968. * Represents a physics vortex event
  51969. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  51970. */
  51971. export class PhysicsVortexEvent {
  51972. private _scene;
  51973. private _origin;
  51974. private _radius;
  51975. private _strength;
  51976. private _height;
  51977. private _physicsEngine;
  51978. private _originTop;
  51979. private _centripetalForceThreshold;
  51980. private _updraftMultiplier;
  51981. private _tickCallback;
  51982. private _cylinder;
  51983. private _cylinderPosition;
  51984. private _dataFetched;
  51985. /**
  51986. * Initializes the physics vortex event
  51987. * @param _scene The BabylonJS scene
  51988. * @param _origin The origin position of the vortex
  51989. * @param _radius The radius of the vortex
  51990. * @param _strength The strength of the vortex
  51991. * @param _height The height of the vortex
  51992. */
  51993. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number);
  51994. /**
  51995. * Returns the data related to the vortex event (cylinder).
  51996. * @returns The physics vortex event data
  51997. */
  51998. getData(): PhysicsVortexEventData;
  51999. /**
  52000. * Enables the vortex.
  52001. */
  52002. enable(): void;
  52003. /**
  52004. * Disables the cortex.
  52005. */
  52006. disable(): void;
  52007. /**
  52008. * Disposes the sphere.
  52009. * @param force
  52010. */
  52011. dispose(force?: boolean): void;
  52012. private getImpostorForceAndContactPoint;
  52013. private _tick;
  52014. /*** Helpers ***/
  52015. private _prepareCylinder;
  52016. private _intersectsWithCylinder;
  52017. }
  52018. /**
  52019. * The strenght of the force in correspondence to the distance of the affected object
  52020. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52021. */
  52022. export enum PhysicsRadialImpulseFalloff {
  52023. /** Defines that impulse is constant in strength across it's whole radius */
  52024. Constant = 0,
  52025. /** DEfines that impulse gets weaker if it's further from the origin */
  52026. Linear = 1
  52027. }
  52028. /**
  52029. * The strength of the force in correspondence to the distance of the affected object
  52030. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52031. */
  52032. export enum PhysicsUpdraftMode {
  52033. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  52034. Center = 0,
  52035. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  52036. Perpendicular = 1
  52037. }
  52038. /**
  52039. * Interface for a physics force and contact point
  52040. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52041. */
  52042. export interface PhysicsForceAndContactPoint {
  52043. /**
  52044. * The force applied at the contact point
  52045. */
  52046. force: Vector3;
  52047. /**
  52048. * The contact point
  52049. */
  52050. contactPoint: Vector3;
  52051. }
  52052. /**
  52053. * Interface for radial explosion event data
  52054. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52055. */
  52056. export interface PhysicsRadialExplosionEventData {
  52057. /**
  52058. * A sphere used for the radial explosion event
  52059. */
  52060. sphere: Mesh;
  52061. /**
  52062. * An array of rays for the radial explosion event
  52063. */
  52064. rays: Array<Ray>;
  52065. }
  52066. /**
  52067. * Interface for gravitational field event data
  52068. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52069. */
  52070. export interface PhysicsGravitationalFieldEventData {
  52071. /**
  52072. * A sphere mesh used for the gravitational field event
  52073. */
  52074. sphere: Mesh;
  52075. }
  52076. /**
  52077. * Interface for updraft event data
  52078. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52079. */
  52080. export interface PhysicsUpdraftEventData {
  52081. /**
  52082. * A cylinder used for the updraft event
  52083. */
  52084. cylinder: Mesh;
  52085. }
  52086. /**
  52087. * Interface for vortex event data
  52088. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52089. */
  52090. export interface PhysicsVortexEventData {
  52091. /**
  52092. * A cylinder used for the vortex event
  52093. */
  52094. cylinder: Mesh;
  52095. }
  52096. }
  52097. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  52098. import { Quaternion, Vector3 } from "babylonjs/Maths/math";
  52099. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  52100. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  52101. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  52102. import { Nullable } from "babylonjs/types";
  52103. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52104. /**
  52105. * AmmoJS Physics plugin
  52106. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52107. * @see https://github.com/kripken/ammo.js/
  52108. */
  52109. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  52110. private _useDeltaForWorldStep;
  52111. /**
  52112. * Reference to the Ammo library
  52113. */
  52114. bjsAMMO: any;
  52115. /**
  52116. * Created ammoJS world which physics bodies are added to
  52117. */
  52118. world: any;
  52119. /**
  52120. * Name of the plugin
  52121. */
  52122. name: string;
  52123. private _timeStep;
  52124. private _fixedTimeStep;
  52125. private _maxSteps;
  52126. private _tmpQuaternion;
  52127. private _tmpAmmoTransform;
  52128. private _tmpAmmoQuaternion;
  52129. private _tmpAmmoConcreteContactResultCallback;
  52130. private _collisionConfiguration;
  52131. private _dispatcher;
  52132. private _overlappingPairCache;
  52133. private _solver;
  52134. private _tmpAmmoVectorA;
  52135. private _tmpAmmoVectorB;
  52136. private _tmpAmmoVectorC;
  52137. private _tmpContactCallbackResult;
  52138. private static readonly DISABLE_COLLISION_FLAG;
  52139. private static readonly KINEMATIC_FLAG;
  52140. private static readonly DISABLE_DEACTIVATION_FLAG;
  52141. /**
  52142. * Initializes the ammoJS plugin
  52143. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  52144. * @param ammoInjection can be used to inject your own ammo reference
  52145. */
  52146. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any);
  52147. /**
  52148. * Sets the gravity of the physics world (m/(s^2))
  52149. * @param gravity Gravity to set
  52150. */
  52151. setGravity(gravity: Vector3): void;
  52152. /**
  52153. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  52154. * @param timeStep timestep to use in seconds
  52155. */
  52156. setTimeStep(timeStep: number): void;
  52157. /**
  52158. * 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)
  52159. * @param fixedTimeStep fixedTimeStep to use in seconds
  52160. */
  52161. setFixedTimeStep(fixedTimeStep: number): void;
  52162. /**
  52163. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  52164. * @param maxSteps the maximum number of steps by the physics engine per frame
  52165. */
  52166. setMaxSteps(maxSteps: number): void;
  52167. /**
  52168. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  52169. * @returns the current timestep in seconds
  52170. */
  52171. getTimeStep(): number;
  52172. private _isImpostorInContact;
  52173. private _isImpostorPairInContact;
  52174. private _stepSimulation;
  52175. /**
  52176. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  52177. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  52178. * After the step the babylon meshes are set to the position of the physics imposters
  52179. * @param delta amount of time to step forward
  52180. * @param impostors array of imposters to update before/after the step
  52181. */
  52182. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  52183. private _tmpVector;
  52184. private _tmpMatrix;
  52185. /**
  52186. * Applies an implulse on the imposter
  52187. * @param impostor imposter to apply impulse
  52188. * @param force amount of force to be applied to the imposter
  52189. * @param contactPoint the location to apply the impulse on the imposter
  52190. */
  52191. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52192. /**
  52193. * Applies a force on the imposter
  52194. * @param impostor imposter to apply force
  52195. * @param force amount of force to be applied to the imposter
  52196. * @param contactPoint the location to apply the force on the imposter
  52197. */
  52198. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52199. /**
  52200. * Creates a physics body using the plugin
  52201. * @param impostor the imposter to create the physics body on
  52202. */
  52203. generatePhysicsBody(impostor: PhysicsImpostor): void;
  52204. /**
  52205. * Removes the physics body from the imposter and disposes of the body's memory
  52206. * @param impostor imposter to remove the physics body from
  52207. */
  52208. removePhysicsBody(impostor: PhysicsImpostor): void;
  52209. /**
  52210. * Generates a joint
  52211. * @param impostorJoint the imposter joint to create the joint with
  52212. */
  52213. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  52214. /**
  52215. * Removes a joint
  52216. * @param impostorJoint the imposter joint to remove the joint from
  52217. */
  52218. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  52219. private _addMeshVerts;
  52220. private _createShape;
  52221. /**
  52222. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  52223. * @param impostor imposter containing the physics body and babylon object
  52224. */
  52225. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  52226. /**
  52227. * Sets the babylon object's position/rotation from the physics body's position/rotation
  52228. * @param impostor imposter containing the physics body and babylon object
  52229. * @param newPosition new position
  52230. * @param newRotation new rotation
  52231. */
  52232. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  52233. /**
  52234. * If this plugin is supported
  52235. * @returns true if its supported
  52236. */
  52237. isSupported(): boolean;
  52238. /**
  52239. * Sets the linear velocity of the physics body
  52240. * @param impostor imposter to set the velocity on
  52241. * @param velocity velocity to set
  52242. */
  52243. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52244. /**
  52245. * Sets the angular velocity of the physics body
  52246. * @param impostor imposter to set the velocity on
  52247. * @param velocity velocity to set
  52248. */
  52249. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52250. /**
  52251. * gets the linear velocity
  52252. * @param impostor imposter to get linear velocity from
  52253. * @returns linear velocity
  52254. */
  52255. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52256. /**
  52257. * gets the angular velocity
  52258. * @param impostor imposter to get angular velocity from
  52259. * @returns angular velocity
  52260. */
  52261. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52262. /**
  52263. * Sets the mass of physics body
  52264. * @param impostor imposter to set the mass on
  52265. * @param mass mass to set
  52266. */
  52267. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  52268. /**
  52269. * Gets the mass of the physics body
  52270. * @param impostor imposter to get the mass from
  52271. * @returns mass
  52272. */
  52273. getBodyMass(impostor: PhysicsImpostor): number;
  52274. /**
  52275. * Gets friction of the impostor
  52276. * @param impostor impostor to get friction from
  52277. * @returns friction value
  52278. */
  52279. getBodyFriction(impostor: PhysicsImpostor): number;
  52280. /**
  52281. * Sets friction of the impostor
  52282. * @param impostor impostor to set friction on
  52283. * @param friction friction value
  52284. */
  52285. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  52286. /**
  52287. * Gets restitution of the impostor
  52288. * @param impostor impostor to get restitution from
  52289. * @returns restitution value
  52290. */
  52291. getBodyRestitution(impostor: PhysicsImpostor): number;
  52292. /**
  52293. * Sets resitution of the impostor
  52294. * @param impostor impostor to set resitution on
  52295. * @param restitution resitution value
  52296. */
  52297. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  52298. /**
  52299. * Sleeps the physics body and stops it from being active
  52300. * @param impostor impostor to sleep
  52301. */
  52302. sleepBody(impostor: PhysicsImpostor): void;
  52303. /**
  52304. * Activates the physics body
  52305. * @param impostor impostor to activate
  52306. */
  52307. wakeUpBody(impostor: PhysicsImpostor): void;
  52308. /**
  52309. * Updates the distance parameters of the joint
  52310. * @param joint joint to update
  52311. * @param maxDistance maximum distance of the joint
  52312. * @param minDistance minimum distance of the joint
  52313. */
  52314. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  52315. /**
  52316. * Sets a motor on the joint
  52317. * @param joint joint to set motor on
  52318. * @param speed speed of the motor
  52319. * @param maxForce maximum force of the motor
  52320. * @param motorIndex index of the motor
  52321. */
  52322. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  52323. /**
  52324. * Sets the motors limit
  52325. * @param joint joint to set limit on
  52326. * @param upperLimit upper limit
  52327. * @param lowerLimit lower limit
  52328. */
  52329. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  52330. /**
  52331. * Syncs the position and rotation of a mesh with the impostor
  52332. * @param mesh mesh to sync
  52333. * @param impostor impostor to update the mesh with
  52334. */
  52335. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  52336. /**
  52337. * Gets the radius of the impostor
  52338. * @param impostor impostor to get radius from
  52339. * @returns the radius
  52340. */
  52341. getRadius(impostor: PhysicsImpostor): number;
  52342. /**
  52343. * Gets the box size of the impostor
  52344. * @param impostor impostor to get box size from
  52345. * @param result the resulting box size
  52346. */
  52347. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  52348. /**
  52349. * Disposes of the impostor
  52350. */
  52351. dispose(): void;
  52352. }
  52353. }
  52354. declare module "babylonjs/Physics/Plugins/index" {
  52355. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  52356. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  52357. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  52358. }
  52359. declare module "babylonjs/Physics/index" {
  52360. export * from "babylonjs/Physics/IPhysicsEngine";
  52361. export * from "babylonjs/Physics/physicsEngine";
  52362. export * from "babylonjs/Physics/physicsEngineComponent";
  52363. export * from "babylonjs/Physics/physicsHelper";
  52364. export * from "babylonjs/Physics/physicsImpostor";
  52365. export * from "babylonjs/Physics/physicsJoint";
  52366. export * from "babylonjs/Physics/Plugins/index";
  52367. }
  52368. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  52369. /** @hidden */
  52370. export var blackAndWhitePixelShader: {
  52371. name: string;
  52372. shader: string;
  52373. };
  52374. }
  52375. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  52376. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52377. import { Camera } from "babylonjs/Cameras/camera";
  52378. import { Engine } from "babylonjs/Engines/engine";
  52379. import "babylonjs/Shaders/blackAndWhite.fragment";
  52380. /**
  52381. * Post process used to render in black and white
  52382. */
  52383. export class BlackAndWhitePostProcess extends PostProcess {
  52384. /**
  52385. * Linear about to convert he result to black and white (default: 1)
  52386. */
  52387. degree: number;
  52388. /**
  52389. * Creates a black and white post process
  52390. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  52391. * @param name The name of the effect.
  52392. * @param options The required width/height ratio to downsize to before computing the render pass.
  52393. * @param camera The camera to apply the render pass to.
  52394. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52395. * @param engine The engine which the post process will be applied. (default: current engine)
  52396. * @param reusable If the post process can be reused on the same frame. (default: false)
  52397. */
  52398. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  52399. }
  52400. }
  52401. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  52402. import { Nullable } from "babylonjs/types";
  52403. import { Camera } from "babylonjs/Cameras/camera";
  52404. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  52405. import { Engine } from "babylonjs/Engines/engine";
  52406. /**
  52407. * This represents a set of one or more post processes in Babylon.
  52408. * A post process can be used to apply a shader to a texture after it is rendered.
  52409. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  52410. */
  52411. export class PostProcessRenderEffect {
  52412. private _postProcesses;
  52413. private _getPostProcesses;
  52414. private _singleInstance;
  52415. private _cameras;
  52416. private _indicesForCamera;
  52417. /**
  52418. * Name of the effect
  52419. * @hidden
  52420. */
  52421. _name: string;
  52422. /**
  52423. * Instantiates a post process render effect.
  52424. * A post process can be used to apply a shader to a texture after it is rendered.
  52425. * @param engine The engine the effect is tied to
  52426. * @param name The name of the effect
  52427. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  52428. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  52429. */
  52430. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  52431. /**
  52432. * Checks if all the post processes in the effect are supported.
  52433. */
  52434. readonly isSupported: boolean;
  52435. /**
  52436. * Updates the current state of the effect
  52437. * @hidden
  52438. */
  52439. _update(): void;
  52440. /**
  52441. * Attaches the effect on cameras
  52442. * @param cameras The camera to attach to.
  52443. * @hidden
  52444. */
  52445. _attachCameras(cameras: Camera): void;
  52446. /**
  52447. * Attaches the effect on cameras
  52448. * @param cameras The camera to attach to.
  52449. * @hidden
  52450. */
  52451. _attachCameras(cameras: Camera[]): void;
  52452. /**
  52453. * Detatches the effect on cameras
  52454. * @param cameras The camera to detatch from.
  52455. * @hidden
  52456. */
  52457. _detachCameras(cameras: Camera): void;
  52458. /**
  52459. * Detatches the effect on cameras
  52460. * @param cameras The camera to detatch from.
  52461. * @hidden
  52462. */
  52463. _detachCameras(cameras: Camera[]): void;
  52464. /**
  52465. * Enables the effect on given cameras
  52466. * @param cameras The camera to enable.
  52467. * @hidden
  52468. */
  52469. _enable(cameras: Camera): void;
  52470. /**
  52471. * Enables the effect on given cameras
  52472. * @param cameras The camera to enable.
  52473. * @hidden
  52474. */
  52475. _enable(cameras: Nullable<Camera[]>): void;
  52476. /**
  52477. * Disables the effect on the given cameras
  52478. * @param cameras The camera to disable.
  52479. * @hidden
  52480. */
  52481. _disable(cameras: Camera): void;
  52482. /**
  52483. * Disables the effect on the given cameras
  52484. * @param cameras The camera to disable.
  52485. * @hidden
  52486. */
  52487. _disable(cameras: Nullable<Camera[]>): void;
  52488. /**
  52489. * Gets a list of the post processes contained in the effect.
  52490. * @param camera The camera to get the post processes on.
  52491. * @returns The list of the post processes in the effect.
  52492. */
  52493. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  52494. }
  52495. }
  52496. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  52497. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  52498. /** @hidden */
  52499. export var extractHighlightsPixelShader: {
  52500. name: string;
  52501. shader: string;
  52502. };
  52503. }
  52504. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  52505. import { Nullable } from "babylonjs/types";
  52506. import { Camera } from "babylonjs/Cameras/camera";
  52507. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52508. import { Engine } from "babylonjs/Engines/engine";
  52509. import "babylonjs/Shaders/extractHighlights.fragment";
  52510. /**
  52511. * 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.
  52512. */
  52513. export class ExtractHighlightsPostProcess extends PostProcess {
  52514. /**
  52515. * The luminance threshold, pixels below this value will be set to black.
  52516. */
  52517. threshold: number;
  52518. /** @hidden */
  52519. _exposure: number;
  52520. /**
  52521. * Post process which has the input texture to be used when performing highlight extraction
  52522. * @hidden
  52523. */
  52524. _inputPostProcess: Nullable<PostProcess>;
  52525. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  52526. }
  52527. }
  52528. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  52529. /** @hidden */
  52530. export var bloomMergePixelShader: {
  52531. name: string;
  52532. shader: string;
  52533. };
  52534. }
  52535. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  52536. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52537. import { Nullable } from "babylonjs/types";
  52538. import { Engine } from "babylonjs/Engines/engine";
  52539. import { Camera } from "babylonjs/Cameras/camera";
  52540. import "babylonjs/Shaders/bloomMerge.fragment";
  52541. /**
  52542. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  52543. */
  52544. export class BloomMergePostProcess extends PostProcess {
  52545. /** Weight of the bloom to be added to the original input. */
  52546. weight: number;
  52547. /**
  52548. * Creates a new instance of @see BloomMergePostProcess
  52549. * @param name The name of the effect.
  52550. * @param originalFromInput Post process which's input will be used for the merge.
  52551. * @param blurred Blurred highlights post process which's output will be used.
  52552. * @param weight Weight of the bloom to be added to the original input.
  52553. * @param options The required width/height ratio to downsize to before computing the render pass.
  52554. * @param camera The camera to apply the render pass to.
  52555. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52556. * @param engine The engine which the post process will be applied. (default: current engine)
  52557. * @param reusable If the post process can be reused on the same frame. (default: false)
  52558. * @param textureType Type of textures used when performing the post process. (default: 0)
  52559. * @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)
  52560. */
  52561. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  52562. /** Weight of the bloom to be added to the original input. */
  52563. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  52564. }
  52565. }
  52566. declare module "babylonjs/PostProcesses/bloomEffect" {
  52567. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  52568. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  52569. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  52570. import { Camera } from "babylonjs/Cameras/camera";
  52571. import { Scene } from "babylonjs/scene";
  52572. /**
  52573. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  52574. */
  52575. export class BloomEffect extends PostProcessRenderEffect {
  52576. private bloomScale;
  52577. /**
  52578. * @hidden Internal
  52579. */
  52580. _effects: Array<PostProcess>;
  52581. /**
  52582. * @hidden Internal
  52583. */
  52584. _downscale: ExtractHighlightsPostProcess;
  52585. private _blurX;
  52586. private _blurY;
  52587. private _merge;
  52588. /**
  52589. * The luminance threshold to find bright areas of the image to bloom.
  52590. */
  52591. threshold: number;
  52592. /**
  52593. * The strength of the bloom.
  52594. */
  52595. weight: number;
  52596. /**
  52597. * Specifies the size of the bloom blur kernel, relative to the final output size
  52598. */
  52599. kernel: number;
  52600. /**
  52601. * Creates a new instance of @see BloomEffect
  52602. * @param scene The scene the effect belongs to.
  52603. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  52604. * @param bloomKernel The size of the kernel to be used when applying the blur.
  52605. * @param bloomWeight The the strength of bloom.
  52606. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  52607. * @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)
  52608. */
  52609. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  52610. /**
  52611. * Disposes each of the internal effects for a given camera.
  52612. * @param camera The camera to dispose the effect on.
  52613. */
  52614. disposeEffects(camera: Camera): void;
  52615. /**
  52616. * @hidden Internal
  52617. */
  52618. _updateEffects(): void;
  52619. /**
  52620. * Internal
  52621. * @returns if all the contained post processes are ready.
  52622. * @hidden
  52623. */
  52624. _isReady(): boolean;
  52625. }
  52626. }
  52627. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  52628. /** @hidden */
  52629. export var chromaticAberrationPixelShader: {
  52630. name: string;
  52631. shader: string;
  52632. };
  52633. }
  52634. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  52635. import { Vector2 } from "babylonjs/Maths/math";
  52636. import { Nullable } from "babylonjs/types";
  52637. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52638. import { Camera } from "babylonjs/Cameras/camera";
  52639. import { Engine } from "babylonjs/Engines/engine";
  52640. import "babylonjs/Shaders/chromaticAberration.fragment";
  52641. /**
  52642. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  52643. */
  52644. export class ChromaticAberrationPostProcess extends PostProcess {
  52645. /**
  52646. * The amount of seperation of rgb channels (default: 30)
  52647. */
  52648. aberrationAmount: number;
  52649. /**
  52650. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  52651. */
  52652. radialIntensity: number;
  52653. /**
  52654. * 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))
  52655. */
  52656. direction: Vector2;
  52657. /**
  52658. * 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))
  52659. */
  52660. centerPosition: Vector2;
  52661. /**
  52662. * Creates a new instance ChromaticAberrationPostProcess
  52663. * @param name The name of the effect.
  52664. * @param screenWidth The width of the screen to apply the effect on.
  52665. * @param screenHeight The height of the screen to apply the effect on.
  52666. * @param options The required width/height ratio to downsize to before computing the render pass.
  52667. * @param camera The camera to apply the render pass to.
  52668. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52669. * @param engine The engine which the post process will be applied. (default: current engine)
  52670. * @param reusable If the post process can be reused on the same frame. (default: false)
  52671. * @param textureType Type of textures used when performing the post process. (default: 0)
  52672. * @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)
  52673. */
  52674. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  52675. }
  52676. }
  52677. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  52678. /** @hidden */
  52679. export var circleOfConfusionPixelShader: {
  52680. name: string;
  52681. shader: string;
  52682. };
  52683. }
  52684. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  52685. import { Nullable } from "babylonjs/types";
  52686. import { Engine } from "babylonjs/Engines/engine";
  52687. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52688. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  52689. import { Camera } from "babylonjs/Cameras/camera";
  52690. import "babylonjs/Shaders/circleOfConfusion.fragment";
  52691. /**
  52692. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  52693. */
  52694. export class CircleOfConfusionPostProcess extends PostProcess {
  52695. /**
  52696. * 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.
  52697. */
  52698. lensSize: number;
  52699. /**
  52700. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  52701. */
  52702. fStop: number;
  52703. /**
  52704. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  52705. */
  52706. focusDistance: number;
  52707. /**
  52708. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  52709. */
  52710. focalLength: number;
  52711. private _depthTexture;
  52712. /**
  52713. * Creates a new instance CircleOfConfusionPostProcess
  52714. * @param name The name of the effect.
  52715. * @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.
  52716. * @param options The required width/height ratio to downsize to before computing the render pass.
  52717. * @param camera The camera to apply the render pass to.
  52718. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52719. * @param engine The engine which the post process will be applied. (default: current engine)
  52720. * @param reusable If the post process can be reused on the same frame. (default: false)
  52721. * @param textureType Type of textures used when performing the post process. (default: 0)
  52722. * @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)
  52723. */
  52724. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  52725. /**
  52726. * 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.
  52727. */
  52728. depthTexture: RenderTargetTexture;
  52729. }
  52730. }
  52731. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  52732. /** @hidden */
  52733. export var colorCorrectionPixelShader: {
  52734. name: string;
  52735. shader: string;
  52736. };
  52737. }
  52738. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  52739. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52740. import { Engine } from "babylonjs/Engines/engine";
  52741. import { Camera } from "babylonjs/Cameras/camera";
  52742. import "babylonjs/Shaders/colorCorrection.fragment";
  52743. /**
  52744. *
  52745. * This post-process allows the modification of rendered colors by using
  52746. * a 'look-up table' (LUT). This effect is also called Color Grading.
  52747. *
  52748. * The object needs to be provided an url to a texture containing the color
  52749. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  52750. * Use an image editing software to tweak the LUT to match your needs.
  52751. *
  52752. * For an example of a color LUT, see here:
  52753. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  52754. * For explanations on color grading, see here:
  52755. * @see http://udn.epicgames.com/Three/ColorGrading.html
  52756. *
  52757. */
  52758. export class ColorCorrectionPostProcess extends PostProcess {
  52759. private _colorTableTexture;
  52760. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  52761. }
  52762. }
  52763. declare module "babylonjs/Shaders/convolution.fragment" {
  52764. /** @hidden */
  52765. export var convolutionPixelShader: {
  52766. name: string;
  52767. shader: string;
  52768. };
  52769. }
  52770. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  52771. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52772. import { Nullable } from "babylonjs/types";
  52773. import { Camera } from "babylonjs/Cameras/camera";
  52774. import { Engine } from "babylonjs/Engines/engine";
  52775. import "babylonjs/Shaders/convolution.fragment";
  52776. /**
  52777. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  52778. * input texture to perform effects such as edge detection or sharpening
  52779. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  52780. */
  52781. export class ConvolutionPostProcess extends PostProcess {
  52782. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  52783. kernel: number[];
  52784. /**
  52785. * Creates a new instance ConvolutionPostProcess
  52786. * @param name The name of the effect.
  52787. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  52788. * @param options The required width/height ratio to downsize to before computing the render pass.
  52789. * @param camera The camera to apply the render pass to.
  52790. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52791. * @param engine The engine which the post process will be applied. (default: current engine)
  52792. * @param reusable If the post process can be reused on the same frame. (default: false)
  52793. * @param textureType Type of textures used when performing the post process. (default: 0)
  52794. */
  52795. constructor(name: string,
  52796. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  52797. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  52798. /**
  52799. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  52800. */
  52801. static EdgeDetect0Kernel: number[];
  52802. /**
  52803. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  52804. */
  52805. static EdgeDetect1Kernel: number[];
  52806. /**
  52807. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  52808. */
  52809. static EdgeDetect2Kernel: number[];
  52810. /**
  52811. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  52812. */
  52813. static SharpenKernel: number[];
  52814. /**
  52815. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  52816. */
  52817. static EmbossKernel: number[];
  52818. /**
  52819. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  52820. */
  52821. static GaussianKernel: number[];
  52822. }
  52823. }
  52824. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  52825. import { Nullable } from "babylonjs/types";
  52826. import { Vector2 } from "babylonjs/Maths/math";
  52827. import { Camera } from "babylonjs/Cameras/camera";
  52828. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52829. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  52830. import { Engine } from "babylonjs/Engines/engine";
  52831. import { Scene } from "babylonjs/scene";
  52832. /**
  52833. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  52834. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  52835. * based on samples that have a large difference in distance than the center pixel.
  52836. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  52837. */
  52838. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  52839. direction: Vector2;
  52840. /**
  52841. * Creates a new instance CircleOfConfusionPostProcess
  52842. * @param name The name of the effect.
  52843. * @param scene The scene the effect belongs to.
  52844. * @param direction The direction the blur should be applied.
  52845. * @param kernel The size of the kernel used to blur.
  52846. * @param options The required width/height ratio to downsize to before computing the render pass.
  52847. * @param camera The camera to apply the render pass to.
  52848. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  52849. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  52850. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52851. * @param engine The engine which the post process will be applied. (default: current engine)
  52852. * @param reusable If the post process can be reused on the same frame. (default: false)
  52853. * @param textureType Type of textures used when performing the post process. (default: 0)
  52854. * @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)
  52855. */
  52856. 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);
  52857. }
  52858. }
  52859. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  52860. /** @hidden */
  52861. export var depthOfFieldMergePixelShader: {
  52862. name: string;
  52863. shader: string;
  52864. };
  52865. }
  52866. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  52867. import { Nullable } from "babylonjs/types";
  52868. import { Camera } from "babylonjs/Cameras/camera";
  52869. import { Effect } from "babylonjs/Materials/effect";
  52870. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52871. import { Engine } from "babylonjs/Engines/engine";
  52872. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  52873. /**
  52874. * Options to be set when merging outputs from the default pipeline.
  52875. */
  52876. export class DepthOfFieldMergePostProcessOptions {
  52877. /**
  52878. * The original image to merge on top of
  52879. */
  52880. originalFromInput: PostProcess;
  52881. /**
  52882. * Parameters to perform the merge of the depth of field effect
  52883. */
  52884. depthOfField?: {
  52885. circleOfConfusion: PostProcess;
  52886. blurSteps: Array<PostProcess>;
  52887. };
  52888. /**
  52889. * Parameters to perform the merge of bloom effect
  52890. */
  52891. bloom?: {
  52892. blurred: PostProcess;
  52893. weight: number;
  52894. };
  52895. }
  52896. /**
  52897. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  52898. */
  52899. export class DepthOfFieldMergePostProcess extends PostProcess {
  52900. private blurSteps;
  52901. /**
  52902. * Creates a new instance of DepthOfFieldMergePostProcess
  52903. * @param name The name of the effect.
  52904. * @param originalFromInput Post process which's input will be used for the merge.
  52905. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  52906. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  52907. * @param options The required width/height ratio to downsize to before computing the render pass.
  52908. * @param camera The camera to apply the render pass to.
  52909. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52910. * @param engine The engine which the post process will be applied. (default: current engine)
  52911. * @param reusable If the post process can be reused on the same frame. (default: false)
  52912. * @param textureType Type of textures used when performing the post process. (default: 0)
  52913. * @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)
  52914. */
  52915. 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);
  52916. /**
  52917. * Updates the effect with the current post process compile time values and recompiles the shader.
  52918. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  52919. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  52920. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  52921. * @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
  52922. * @param onCompiled Called when the shader has been compiled.
  52923. * @param onError Called if there is an error when compiling a shader.
  52924. */
  52925. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  52926. }
  52927. }
  52928. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  52929. import { Nullable } from "babylonjs/types";
  52930. import { Camera } from "babylonjs/Cameras/camera";
  52931. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  52932. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  52933. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  52934. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  52935. import { Scene } from "babylonjs/scene";
  52936. /**
  52937. * Specifies the level of max blur that should be applied when using the depth of field effect
  52938. */
  52939. export enum DepthOfFieldEffectBlurLevel {
  52940. /**
  52941. * Subtle blur
  52942. */
  52943. Low = 0,
  52944. /**
  52945. * Medium blur
  52946. */
  52947. Medium = 1,
  52948. /**
  52949. * Large blur
  52950. */
  52951. High = 2
  52952. }
  52953. /**
  52954. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  52955. */
  52956. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  52957. private _circleOfConfusion;
  52958. /**
  52959. * @hidden Internal, blurs from high to low
  52960. */
  52961. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  52962. private _depthOfFieldBlurY;
  52963. private _dofMerge;
  52964. /**
  52965. * @hidden Internal post processes in depth of field effect
  52966. */
  52967. _effects: Array<PostProcess>;
  52968. /**
  52969. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  52970. */
  52971. focalLength: number;
  52972. /**
  52973. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  52974. */
  52975. fStop: number;
  52976. /**
  52977. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  52978. */
  52979. focusDistance: number;
  52980. /**
  52981. * 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.
  52982. */
  52983. lensSize: number;
  52984. /**
  52985. * Creates a new instance DepthOfFieldEffect
  52986. * @param scene The scene the effect belongs to.
  52987. * @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.
  52988. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  52989. * @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)
  52990. */
  52991. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  52992. /**
  52993. * 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.
  52994. */
  52995. depthTexture: RenderTargetTexture;
  52996. /**
  52997. * Disposes each of the internal effects for a given camera.
  52998. * @param camera The camera to dispose the effect on.
  52999. */
  53000. disposeEffects(camera: Camera): void;
  53001. /**
  53002. * @hidden Internal
  53003. */
  53004. _updateEffects(): void;
  53005. /**
  53006. * Internal
  53007. * @returns if all the contained post processes are ready.
  53008. * @hidden
  53009. */
  53010. _isReady(): boolean;
  53011. }
  53012. }
  53013. declare module "babylonjs/Shaders/displayPass.fragment" {
  53014. /** @hidden */
  53015. export var displayPassPixelShader: {
  53016. name: string;
  53017. shader: string;
  53018. };
  53019. }
  53020. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  53021. import { Nullable } from "babylonjs/types";
  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/displayPass.fragment";
  53026. /**
  53027. * DisplayPassPostProcess which produces an output the same as it's input
  53028. */
  53029. export class DisplayPassPostProcess extends PostProcess {
  53030. /**
  53031. * Creates the DisplayPassPostProcess
  53032. * @param name The name of the effect.
  53033. * @param options The required width/height ratio to downsize to before computing the render pass.
  53034. * @param camera The camera to apply the render pass to.
  53035. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53036. * @param engine The engine which the post process will be applied. (default: current engine)
  53037. * @param reusable If the post process can be reused on the same frame. (default: false)
  53038. */
  53039. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  53040. }
  53041. }
  53042. declare module "babylonjs/Shaders/filter.fragment" {
  53043. /** @hidden */
  53044. export var filterPixelShader: {
  53045. name: string;
  53046. shader: string;
  53047. };
  53048. }
  53049. declare module "babylonjs/PostProcesses/filterPostProcess" {
  53050. import { Nullable } from "babylonjs/types";
  53051. import { Matrix } from "babylonjs/Maths/math";
  53052. import { Camera } from "babylonjs/Cameras/camera";
  53053. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53054. import { Engine } from "babylonjs/Engines/engine";
  53055. import "babylonjs/Shaders/filter.fragment";
  53056. /**
  53057. * Applies a kernel filter to the image
  53058. */
  53059. export class FilterPostProcess extends PostProcess {
  53060. /** The matrix to be applied to the image */
  53061. kernelMatrix: Matrix;
  53062. /**
  53063. *
  53064. * @param name The name of the effect.
  53065. * @param kernelMatrix The matrix to be applied to the image
  53066. * @param options The required width/height ratio to downsize to before computing the render pass.
  53067. * @param camera The camera to apply the render pass to.
  53068. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53069. * @param engine The engine which the post process will be applied. (default: current engine)
  53070. * @param reusable If the post process can be reused on the same frame. (default: false)
  53071. */
  53072. constructor(name: string,
  53073. /** The matrix to be applied to the image */
  53074. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  53075. }
  53076. }
  53077. declare module "babylonjs/Shaders/fxaa.fragment" {
  53078. /** @hidden */
  53079. export var fxaaPixelShader: {
  53080. name: string;
  53081. shader: string;
  53082. };
  53083. }
  53084. declare module "babylonjs/Shaders/fxaa.vertex" {
  53085. /** @hidden */
  53086. export var fxaaVertexShader: {
  53087. name: string;
  53088. shader: string;
  53089. };
  53090. }
  53091. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  53092. import { Nullable } from "babylonjs/types";
  53093. import { Camera } from "babylonjs/Cameras/camera";
  53094. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53095. import { Engine } from "babylonjs/Engines/engine";
  53096. import "babylonjs/Shaders/fxaa.fragment";
  53097. import "babylonjs/Shaders/fxaa.vertex";
  53098. /**
  53099. * Fxaa post process
  53100. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  53101. */
  53102. export class FxaaPostProcess extends PostProcess {
  53103. /** @hidden */
  53104. texelWidth: number;
  53105. /** @hidden */
  53106. texelHeight: number;
  53107. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  53108. private _getDefines;
  53109. }
  53110. }
  53111. declare module "babylonjs/Shaders/grain.fragment" {
  53112. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  53113. /** @hidden */
  53114. export var grainPixelShader: {
  53115. name: string;
  53116. shader: string;
  53117. };
  53118. }
  53119. declare module "babylonjs/PostProcesses/grainPostProcess" {
  53120. import { Nullable } from "babylonjs/types";
  53121. import { Camera } from "babylonjs/Cameras/camera";
  53122. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53123. import { Engine } from "babylonjs/Engines/engine";
  53124. import "babylonjs/Shaders/grain.fragment";
  53125. /**
  53126. * The GrainPostProcess adds noise to the image at mid luminance levels
  53127. */
  53128. export class GrainPostProcess extends PostProcess {
  53129. /**
  53130. * The intensity of the grain added (default: 30)
  53131. */
  53132. intensity: number;
  53133. /**
  53134. * If the grain should be randomized on every frame
  53135. */
  53136. animated: boolean;
  53137. /**
  53138. * Creates a new instance of @see GrainPostProcess
  53139. * @param name The name of the effect.
  53140. * @param options The required width/height ratio to downsize to before computing the render pass.
  53141. * @param camera The camera to apply the render pass to.
  53142. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53143. * @param engine The engine which the post process will be applied. (default: current engine)
  53144. * @param reusable If the post process can be reused on the same frame. (default: false)
  53145. * @param textureType Type of textures used when performing the post process. (default: 0)
  53146. * @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)
  53147. */
  53148. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  53149. }
  53150. }
  53151. declare module "babylonjs/Shaders/highlights.fragment" {
  53152. /** @hidden */
  53153. export var highlightsPixelShader: {
  53154. name: string;
  53155. shader: string;
  53156. };
  53157. }
  53158. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  53159. import { Nullable } from "babylonjs/types";
  53160. import { Camera } from "babylonjs/Cameras/camera";
  53161. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53162. import { Engine } from "babylonjs/Engines/engine";
  53163. import "babylonjs/Shaders/highlights.fragment";
  53164. /**
  53165. * Extracts highlights from the image
  53166. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  53167. */
  53168. export class HighlightsPostProcess extends PostProcess {
  53169. /**
  53170. * Extracts highlights from the image
  53171. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  53172. * @param name The name of the effect.
  53173. * @param options The required width/height ratio to downsize to before computing the render pass.
  53174. * @param camera The camera to apply the render pass to.
  53175. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53176. * @param engine The engine which the post process will be applied. (default: current engine)
  53177. * @param reusable If the post process can be reused on the same frame. (default: false)
  53178. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  53179. */
  53180. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  53181. }
  53182. }
  53183. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  53184. /** @hidden */
  53185. export var mrtFragmentDeclaration: {
  53186. name: string;
  53187. shader: string;
  53188. };
  53189. }
  53190. declare module "babylonjs/Shaders/geometry.fragment" {
  53191. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  53192. /** @hidden */
  53193. export var geometryPixelShader: {
  53194. name: string;
  53195. shader: string;
  53196. };
  53197. }
  53198. declare module "babylonjs/Shaders/geometry.vertex" {
  53199. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  53200. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  53201. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  53202. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  53203. /** @hidden */
  53204. export var geometryVertexShader: {
  53205. name: string;
  53206. shader: string;
  53207. };
  53208. }
  53209. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  53210. import { Matrix } from "babylonjs/Maths/math";
  53211. import { SubMesh } from "babylonjs/Meshes/subMesh";
  53212. import { Mesh } from "babylonjs/Meshes/mesh";
  53213. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  53214. import { Effect } from "babylonjs/Materials/effect";
  53215. import { Scene } from "babylonjs/scene";
  53216. import "babylonjs/Shaders/geometry.fragment";
  53217. import "babylonjs/Shaders/geometry.vertex";
  53218. /**
  53219. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  53220. */
  53221. export class GeometryBufferRenderer {
  53222. /**
  53223. * Constant used to retrieve the position texture index in the G-Buffer textures array
  53224. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  53225. */
  53226. static readonly POSITION_TEXTURE_TYPE: number;
  53227. /**
  53228. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  53229. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  53230. */
  53231. static readonly VELOCITY_TEXTURE_TYPE: number;
  53232. /**
  53233. * Dictionary used to store the previous transformation matrices of each rendered mesh
  53234. * in order to compute objects velocities when enableVelocity is set to "true"
  53235. * @hidden
  53236. */
  53237. _previousTransformationMatrices: {
  53238. [index: number]: Matrix;
  53239. };
  53240. private _scene;
  53241. private _multiRenderTarget;
  53242. private _ratio;
  53243. private _enablePosition;
  53244. private _enableVelocity;
  53245. private _positionIndex;
  53246. private _velocityIndex;
  53247. protected _effect: Effect;
  53248. protected _cachedDefines: string;
  53249. /**
  53250. * Set the render list (meshes to be rendered) used in the G buffer.
  53251. */
  53252. renderList: Mesh[];
  53253. /**
  53254. * Gets wether or not G buffer are supported by the running hardware.
  53255. * This requires draw buffer supports
  53256. */
  53257. readonly isSupported: boolean;
  53258. /**
  53259. * Returns the index of the given texture type in the G-Buffer textures array
  53260. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  53261. * @returns the index of the given texture type in the G-Buffer textures array
  53262. */
  53263. getTextureIndex(textureType: number): number;
  53264. /**
  53265. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  53266. */
  53267. /**
  53268. * Sets whether or not objects positions are enabled for the G buffer.
  53269. */
  53270. enablePosition: boolean;
  53271. /**
  53272. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  53273. */
  53274. /**
  53275. * Sets wether or not objects velocities are enabled for the G buffer.
  53276. */
  53277. enableVelocity: boolean;
  53278. /**
  53279. * Gets the scene associated with the buffer.
  53280. */
  53281. readonly scene: Scene;
  53282. /**
  53283. * Gets the ratio used by the buffer during its creation.
  53284. * How big is the buffer related to the main canvas.
  53285. */
  53286. readonly ratio: number;
  53287. /** @hidden */
  53288. static _SceneComponentInitialization: (scene: Scene) => void;
  53289. /**
  53290. * Creates a new G Buffer for the scene
  53291. * @param scene The scene the buffer belongs to
  53292. * @param ratio How big is the buffer related to the main canvas.
  53293. */
  53294. constructor(scene: Scene, ratio?: number);
  53295. /**
  53296. * Checks wether everything is ready to render a submesh to the G buffer.
  53297. * @param subMesh the submesh to check readiness for
  53298. * @param useInstances is the mesh drawn using instance or not
  53299. * @returns true if ready otherwise false
  53300. */
  53301. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  53302. /**
  53303. * Gets the current underlying G Buffer.
  53304. * @returns the buffer
  53305. */
  53306. getGBuffer(): MultiRenderTarget;
  53307. /**
  53308. * Gets the number of samples used to render the buffer (anti aliasing).
  53309. */
  53310. /**
  53311. * Sets the number of samples used to render the buffer (anti aliasing).
  53312. */
  53313. samples: number;
  53314. /**
  53315. * Disposes the renderer and frees up associated resources.
  53316. */
  53317. dispose(): void;
  53318. protected _createRenderTargets(): void;
  53319. }
  53320. }
  53321. declare module "babylonjs/Shaders/motionBlur.fragment" {
  53322. /** @hidden */
  53323. export var motionBlurPixelShader: {
  53324. name: string;
  53325. shader: string;
  53326. };
  53327. }
  53328. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  53329. import { Nullable } from "babylonjs/types";
  53330. import { Camera } from "babylonjs/Cameras/camera";
  53331. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53332. import { Scene } from "babylonjs/scene";
  53333. import "babylonjs/Shaders/motionBlur.fragment";
  53334. import { Engine } from "babylonjs/Engines/engine";
  53335. /**
  53336. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  53337. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  53338. * As an example, all you have to do is to create the post-process:
  53339. * var mb = new BABYLON.MotionBlurPostProcess(
  53340. * 'mb', // The name of the effect.
  53341. * scene, // The scene containing the objects to blur according to their velocity.
  53342. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  53343. * camera // The camera to apply the render pass to.
  53344. * );
  53345. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  53346. */
  53347. export class MotionBlurPostProcess extends PostProcess {
  53348. /**
  53349. * Defines how much the image is blurred by the movement. Default value is equal to 1
  53350. */
  53351. motionStrength: number;
  53352. /**
  53353. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  53354. */
  53355. /**
  53356. * Sets the number of iterations to be used for motion blur quality
  53357. */
  53358. motionBlurSamples: number;
  53359. private _motionBlurSamples;
  53360. private _geometryBufferRenderer;
  53361. /**
  53362. * Creates a new instance MotionBlurPostProcess
  53363. * @param name The name of the effect.
  53364. * @param scene The scene containing the objects to blur according to their velocity.
  53365. * @param options The required width/height ratio to downsize to before computing the render pass.
  53366. * @param camera The camera to apply the render pass to.
  53367. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53368. * @param engine The engine which the post process will be applied. (default: current engine)
  53369. * @param reusable If the post process can be reused on the same frame. (default: false)
  53370. * @param textureType Type of textures used when performing the post process. (default: 0)
  53371. * @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)
  53372. */
  53373. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  53374. /**
  53375. * Disposes the post process.
  53376. * @param camera The camera to dispose the post process on.
  53377. */
  53378. dispose(camera?: Camera): void;
  53379. }
  53380. }
  53381. declare module "babylonjs/Shaders/refraction.fragment" {
  53382. /** @hidden */
  53383. export var refractionPixelShader: {
  53384. name: string;
  53385. shader: string;
  53386. };
  53387. }
  53388. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  53389. import { Color3 } from "babylonjs/Maths/math";
  53390. import { Camera } from "babylonjs/Cameras/camera";
  53391. import { Texture } from "babylonjs/Materials/Textures/texture";
  53392. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53393. import { Engine } from "babylonjs/Engines/engine";
  53394. import "babylonjs/Shaders/refraction.fragment";
  53395. /**
  53396. * Post process which applies a refractin texture
  53397. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  53398. */
  53399. export class RefractionPostProcess extends PostProcess {
  53400. /** the base color of the refraction (used to taint the rendering) */
  53401. color: Color3;
  53402. /** simulated refraction depth */
  53403. depth: number;
  53404. /** the coefficient of the base color (0 to remove base color tainting) */
  53405. colorLevel: number;
  53406. private _refTexture;
  53407. private _ownRefractionTexture;
  53408. /**
  53409. * Gets or sets the refraction texture
  53410. * Please note that you are responsible for disposing the texture if you set it manually
  53411. */
  53412. refractionTexture: Texture;
  53413. /**
  53414. * Initializes the RefractionPostProcess
  53415. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  53416. * @param name The name of the effect.
  53417. * @param refractionTextureUrl Url of the refraction texture to use
  53418. * @param color the base color of the refraction (used to taint the rendering)
  53419. * @param depth simulated refraction depth
  53420. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  53421. * @param camera The camera to apply the render pass to.
  53422. * @param options The required width/height ratio to downsize to before computing the render pass.
  53423. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53424. * @param engine The engine which the post process will be applied. (default: current engine)
  53425. * @param reusable If the post process can be reused on the same frame. (default: false)
  53426. */
  53427. constructor(name: string, refractionTextureUrl: string,
  53428. /** the base color of the refraction (used to taint the rendering) */
  53429. color: Color3,
  53430. /** simulated refraction depth */
  53431. depth: number,
  53432. /** the coefficient of the base color (0 to remove base color tainting) */
  53433. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  53434. /**
  53435. * Disposes of the post process
  53436. * @param camera Camera to dispose post process on
  53437. */
  53438. dispose(camera: Camera): void;
  53439. }
  53440. }
  53441. declare module "babylonjs/Shaders/sharpen.fragment" {
  53442. /** @hidden */
  53443. export var sharpenPixelShader: {
  53444. name: string;
  53445. shader: string;
  53446. };
  53447. }
  53448. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  53449. import { Nullable } from "babylonjs/types";
  53450. import { Camera } from "babylonjs/Cameras/camera";
  53451. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53452. import "babylonjs/Shaders/sharpen.fragment";
  53453. import { Engine } from "babylonjs/Engines/engine";
  53454. /**
  53455. * The SharpenPostProcess applies a sharpen kernel to every pixel
  53456. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  53457. */
  53458. export class SharpenPostProcess extends PostProcess {
  53459. /**
  53460. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  53461. */
  53462. colorAmount: number;
  53463. /**
  53464. * How much sharpness should be applied (default: 0.3)
  53465. */
  53466. edgeAmount: number;
  53467. /**
  53468. * Creates a new instance ConvolutionPostProcess
  53469. * @param name The name of the effect.
  53470. * @param options The required width/height ratio to downsize to before computing the render pass.
  53471. * @param camera The camera to apply the render pass to.
  53472. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53473. * @param engine The engine which the post process will be applied. (default: current engine)
  53474. * @param reusable If the post process can be reused on the same frame. (default: false)
  53475. * @param textureType Type of textures used when performing the post process. (default: 0)
  53476. * @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)
  53477. */
  53478. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  53479. }
  53480. }
  53481. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  53482. import { Nullable } from "babylonjs/types";
  53483. import { Camera } from "babylonjs/Cameras/camera";
  53484. import { Engine } from "babylonjs/Engines/engine";
  53485. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  53486. /**
  53487. * PostProcessRenderPipeline
  53488. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  53489. */
  53490. export class PostProcessRenderPipeline {
  53491. private engine;
  53492. private _renderEffects;
  53493. private _renderEffectsForIsolatedPass;
  53494. /**
  53495. * @hidden
  53496. */
  53497. protected _cameras: Camera[];
  53498. /** @hidden */
  53499. _name: string;
  53500. /**
  53501. * Gets pipeline name
  53502. */
  53503. readonly name: string;
  53504. /**
  53505. * Initializes a PostProcessRenderPipeline
  53506. * @param engine engine to add the pipeline to
  53507. * @param name name of the pipeline
  53508. */
  53509. constructor(engine: Engine, name: string);
  53510. /**
  53511. * Gets the class name
  53512. * @returns "PostProcessRenderPipeline"
  53513. */
  53514. getClassName(): string;
  53515. /**
  53516. * If all the render effects in the pipeline are supported
  53517. */
  53518. readonly isSupported: boolean;
  53519. /**
  53520. * Adds an effect to the pipeline
  53521. * @param renderEffect the effect to add
  53522. */
  53523. addEffect(renderEffect: PostProcessRenderEffect): void;
  53524. /** @hidden */
  53525. _rebuild(): void;
  53526. /** @hidden */
  53527. _enableEffect(renderEffectName: string, cameras: Camera): void;
  53528. /** @hidden */
  53529. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  53530. /** @hidden */
  53531. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  53532. /** @hidden */
  53533. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  53534. /** @hidden */
  53535. _attachCameras(cameras: Camera, unique: boolean): void;
  53536. /** @hidden */
  53537. _attachCameras(cameras: Camera[], unique: boolean): void;
  53538. /** @hidden */
  53539. _detachCameras(cameras: Camera): void;
  53540. /** @hidden */
  53541. _detachCameras(cameras: Nullable<Camera[]>): void;
  53542. /** @hidden */
  53543. _update(): void;
  53544. /** @hidden */
  53545. _reset(): void;
  53546. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  53547. /**
  53548. * Disposes of the pipeline
  53549. */
  53550. dispose(): void;
  53551. }
  53552. }
  53553. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  53554. import { IAnimatable } from "babylonjs/Misc/tools";
  53555. import { Camera } from "babylonjs/Cameras/camera";
  53556. import { IDisposable } from "babylonjs/scene";
  53557. import { Scene } from "babylonjs/scene";
  53558. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  53559. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  53560. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  53561. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  53562. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  53563. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  53564. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  53565. import { Animation } from "babylonjs/Animations/animation";
  53566. /**
  53567. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  53568. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  53569. */
  53570. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  53571. private _scene;
  53572. private _camerasToBeAttached;
  53573. /**
  53574. * ID of the sharpen post process,
  53575. */
  53576. private readonly SharpenPostProcessId;
  53577. /**
  53578. * @ignore
  53579. * ID of the image processing post process;
  53580. */
  53581. readonly ImageProcessingPostProcessId: string;
  53582. /**
  53583. * @ignore
  53584. * ID of the Fast Approximate Anti-Aliasing post process;
  53585. */
  53586. readonly FxaaPostProcessId: string;
  53587. /**
  53588. * ID of the chromatic aberration post process,
  53589. */
  53590. private readonly ChromaticAberrationPostProcessId;
  53591. /**
  53592. * ID of the grain post process
  53593. */
  53594. private readonly GrainPostProcessId;
  53595. /**
  53596. * Sharpen post process which will apply a sharpen convolution to enhance edges
  53597. */
  53598. sharpen: SharpenPostProcess;
  53599. private _sharpenEffect;
  53600. private bloom;
  53601. /**
  53602. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  53603. */
  53604. depthOfField: DepthOfFieldEffect;
  53605. /**
  53606. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  53607. */
  53608. fxaa: FxaaPostProcess;
  53609. /**
  53610. * Image post processing pass used to perform operations such as tone mapping or color grading.
  53611. */
  53612. imageProcessing: ImageProcessingPostProcess;
  53613. /**
  53614. * Chromatic aberration post process which will shift rgb colors in the image
  53615. */
  53616. chromaticAberration: ChromaticAberrationPostProcess;
  53617. private _chromaticAberrationEffect;
  53618. /**
  53619. * Grain post process which add noise to the image
  53620. */
  53621. grain: GrainPostProcess;
  53622. private _grainEffect;
  53623. /**
  53624. * Glow post process which adds a glow to emissive areas of the image
  53625. */
  53626. private _glowLayer;
  53627. /**
  53628. * Animations which can be used to tweak settings over a period of time
  53629. */
  53630. animations: Animation[];
  53631. private _imageProcessingConfigurationObserver;
  53632. private _sharpenEnabled;
  53633. private _bloomEnabled;
  53634. private _depthOfFieldEnabled;
  53635. private _depthOfFieldBlurLevel;
  53636. private _fxaaEnabled;
  53637. private _imageProcessingEnabled;
  53638. private _defaultPipelineTextureType;
  53639. private _bloomScale;
  53640. private _chromaticAberrationEnabled;
  53641. private _grainEnabled;
  53642. private _buildAllowed;
  53643. /**
  53644. * Gets active scene
  53645. */
  53646. readonly scene: Scene;
  53647. /**
  53648. * Enable or disable the sharpen process from the pipeline
  53649. */
  53650. sharpenEnabled: boolean;
  53651. private _resizeObserver;
  53652. private _hardwareScaleLevel;
  53653. private _bloomKernel;
  53654. /**
  53655. * Specifies the size of the bloom blur kernel, relative to the final output size
  53656. */
  53657. bloomKernel: number;
  53658. /**
  53659. * Specifies the weight of the bloom in the final rendering
  53660. */
  53661. private _bloomWeight;
  53662. /**
  53663. * Specifies the luma threshold for the area that will be blurred by the bloom
  53664. */
  53665. private _bloomThreshold;
  53666. private _hdr;
  53667. /**
  53668. * The strength of the bloom.
  53669. */
  53670. bloomWeight: number;
  53671. /**
  53672. * The strength of the bloom.
  53673. */
  53674. bloomThreshold: number;
  53675. /**
  53676. * The scale of the bloom, lower value will provide better performance.
  53677. */
  53678. bloomScale: number;
  53679. /**
  53680. * Enable or disable the bloom from the pipeline
  53681. */
  53682. bloomEnabled: boolean;
  53683. private _rebuildBloom;
  53684. /**
  53685. * If the depth of field is enabled.
  53686. */
  53687. depthOfFieldEnabled: boolean;
  53688. /**
  53689. * Blur level of the depth of field effect. (Higher blur will effect performance)
  53690. */
  53691. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  53692. /**
  53693. * If the anti aliasing is enabled.
  53694. */
  53695. fxaaEnabled: boolean;
  53696. private _samples;
  53697. /**
  53698. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  53699. */
  53700. samples: number;
  53701. /**
  53702. * If image processing is enabled.
  53703. */
  53704. imageProcessingEnabled: boolean;
  53705. /**
  53706. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  53707. */
  53708. glowLayerEnabled: boolean;
  53709. /**
  53710. * Enable or disable the chromaticAberration process from the pipeline
  53711. */
  53712. chromaticAberrationEnabled: boolean;
  53713. /**
  53714. * Enable or disable the grain process from the pipeline
  53715. */
  53716. grainEnabled: boolean;
  53717. /**
  53718. * @constructor
  53719. * @param name - The rendering pipeline name (default: "")
  53720. * @param hdr - If high dynamic range textures should be used (default: true)
  53721. * @param scene - The scene linked to this pipeline (default: the last created scene)
  53722. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  53723. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  53724. */
  53725. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  53726. /**
  53727. * Get the class name
  53728. * @returns "DefaultRenderingPipeline"
  53729. */
  53730. getClassName(): string;
  53731. /**
  53732. * Force the compilation of the entire pipeline.
  53733. */
  53734. prepare(): void;
  53735. private _hasCleared;
  53736. private _prevPostProcess;
  53737. private _prevPrevPostProcess;
  53738. private _setAutoClearAndTextureSharing;
  53739. private _depthOfFieldSceneObserver;
  53740. private _buildPipeline;
  53741. private _disposePostProcesses;
  53742. /**
  53743. * Adds a camera to the pipeline
  53744. * @param camera the camera to be added
  53745. */
  53746. addCamera(camera: Camera): void;
  53747. /**
  53748. * Removes a camera from the pipeline
  53749. * @param camera the camera to remove
  53750. */
  53751. removeCamera(camera: Camera): void;
  53752. /**
  53753. * Dispose of the pipeline and stop all post processes
  53754. */
  53755. dispose(): void;
  53756. /**
  53757. * Serialize the rendering pipeline (Used when exporting)
  53758. * @returns the serialized object
  53759. */
  53760. serialize(): any;
  53761. /**
  53762. * Parse the serialized pipeline
  53763. * @param source Source pipeline.
  53764. * @param scene The scene to load the pipeline to.
  53765. * @param rootUrl The URL of the serialized pipeline.
  53766. * @returns An instantiated pipeline from the serialized object.
  53767. */
  53768. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  53769. }
  53770. }
  53771. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  53772. /** @hidden */
  53773. export var lensHighlightsPixelShader: {
  53774. name: string;
  53775. shader: string;
  53776. };
  53777. }
  53778. declare module "babylonjs/Shaders/depthOfField.fragment" {
  53779. /** @hidden */
  53780. export var depthOfFieldPixelShader: {
  53781. name: string;
  53782. shader: string;
  53783. };
  53784. }
  53785. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  53786. import { Camera } from "babylonjs/Cameras/camera";
  53787. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  53788. import { Scene } from "babylonjs/scene";
  53789. import "babylonjs/Shaders/chromaticAberration.fragment";
  53790. import "babylonjs/Shaders/lensHighlights.fragment";
  53791. import "babylonjs/Shaders/depthOfField.fragment";
  53792. /**
  53793. * BABYLON.JS Chromatic Aberration GLSL Shader
  53794. * Author: Olivier Guyot
  53795. * Separates very slightly R, G and B colors on the edges of the screen
  53796. * Inspired by Francois Tarlier & Martins Upitis
  53797. */
  53798. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  53799. /**
  53800. * @ignore
  53801. * The chromatic aberration PostProcess id in the pipeline
  53802. */
  53803. LensChromaticAberrationEffect: string;
  53804. /**
  53805. * @ignore
  53806. * The highlights enhancing PostProcess id in the pipeline
  53807. */
  53808. HighlightsEnhancingEffect: string;
  53809. /**
  53810. * @ignore
  53811. * The depth-of-field PostProcess id in the pipeline
  53812. */
  53813. LensDepthOfFieldEffect: string;
  53814. private _scene;
  53815. private _depthTexture;
  53816. private _grainTexture;
  53817. private _chromaticAberrationPostProcess;
  53818. private _highlightsPostProcess;
  53819. private _depthOfFieldPostProcess;
  53820. private _edgeBlur;
  53821. private _grainAmount;
  53822. private _chromaticAberration;
  53823. private _distortion;
  53824. private _highlightsGain;
  53825. private _highlightsThreshold;
  53826. private _dofDistance;
  53827. private _dofAperture;
  53828. private _dofDarken;
  53829. private _dofPentagon;
  53830. private _blurNoise;
  53831. /**
  53832. * @constructor
  53833. *
  53834. * Effect parameters are as follow:
  53835. * {
  53836. * chromatic_aberration: number; // from 0 to x (1 for realism)
  53837. * edge_blur: number; // from 0 to x (1 for realism)
  53838. * distortion: number; // from 0 to x (1 for realism)
  53839. * grain_amount: number; // from 0 to 1
  53840. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  53841. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  53842. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  53843. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  53844. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  53845. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  53846. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  53847. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  53848. * }
  53849. * Note: if an effect parameter is unset, effect is disabled
  53850. *
  53851. * @param name The rendering pipeline name
  53852. * @param parameters - An object containing all parameters (see above)
  53853. * @param scene The scene linked to this pipeline
  53854. * @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)
  53855. * @param cameras The array of cameras that the rendering pipeline will be attached to
  53856. */
  53857. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  53858. /**
  53859. * Sets the amount of blur at the edges
  53860. * @param amount blur amount
  53861. */
  53862. setEdgeBlur(amount: number): void;
  53863. /**
  53864. * Sets edge blur to 0
  53865. */
  53866. disableEdgeBlur(): void;
  53867. /**
  53868. * Sets the amout of grain
  53869. * @param amount Amount of grain
  53870. */
  53871. setGrainAmount(amount: number): void;
  53872. /**
  53873. * Set grain amount to 0
  53874. */
  53875. disableGrain(): void;
  53876. /**
  53877. * Sets the chromatic aberration amount
  53878. * @param amount amount of chromatic aberration
  53879. */
  53880. setChromaticAberration(amount: number): void;
  53881. /**
  53882. * Sets chromatic aberration amount to 0
  53883. */
  53884. disableChromaticAberration(): void;
  53885. /**
  53886. * Sets the EdgeDistortion amount
  53887. * @param amount amount of EdgeDistortion
  53888. */
  53889. setEdgeDistortion(amount: number): void;
  53890. /**
  53891. * Sets edge distortion to 0
  53892. */
  53893. disableEdgeDistortion(): void;
  53894. /**
  53895. * Sets the FocusDistance amount
  53896. * @param amount amount of FocusDistance
  53897. */
  53898. setFocusDistance(amount: number): void;
  53899. /**
  53900. * Disables depth of field
  53901. */
  53902. disableDepthOfField(): void;
  53903. /**
  53904. * Sets the Aperture amount
  53905. * @param amount amount of Aperture
  53906. */
  53907. setAperture(amount: number): void;
  53908. /**
  53909. * Sets the DarkenOutOfFocus amount
  53910. * @param amount amount of DarkenOutOfFocus
  53911. */
  53912. setDarkenOutOfFocus(amount: number): void;
  53913. /**
  53914. * Creates a pentagon bokeh effect
  53915. */
  53916. enablePentagonBokeh(): void;
  53917. /**
  53918. * Disables the pentagon bokeh effect
  53919. */
  53920. disablePentagonBokeh(): void;
  53921. /**
  53922. * Enables noise blur
  53923. */
  53924. enableNoiseBlur(): void;
  53925. /**
  53926. * Disables noise blur
  53927. */
  53928. disableNoiseBlur(): void;
  53929. /**
  53930. * Sets the HighlightsGain amount
  53931. * @param amount amount of HighlightsGain
  53932. */
  53933. setHighlightsGain(amount: number): void;
  53934. /**
  53935. * Sets the HighlightsThreshold amount
  53936. * @param amount amount of HighlightsThreshold
  53937. */
  53938. setHighlightsThreshold(amount: number): void;
  53939. /**
  53940. * Disables highlights
  53941. */
  53942. disableHighlights(): void;
  53943. /**
  53944. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  53945. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  53946. */
  53947. dispose(disableDepthRender?: boolean): void;
  53948. private _createChromaticAberrationPostProcess;
  53949. private _createHighlightsPostProcess;
  53950. private _createDepthOfFieldPostProcess;
  53951. private _createGrainTexture;
  53952. }
  53953. }
  53954. declare module "babylonjs/Shaders/ssao2.fragment" {
  53955. /** @hidden */
  53956. export var ssao2PixelShader: {
  53957. name: string;
  53958. shader: string;
  53959. };
  53960. }
  53961. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  53962. /** @hidden */
  53963. export var ssaoCombinePixelShader: {
  53964. name: string;
  53965. shader: string;
  53966. };
  53967. }
  53968. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  53969. import { Camera } from "babylonjs/Cameras/camera";
  53970. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  53971. import { Scene } from "babylonjs/scene";
  53972. import "babylonjs/Shaders/ssao2.fragment";
  53973. import "babylonjs/Shaders/ssaoCombine.fragment";
  53974. /**
  53975. * Render pipeline to produce ssao effect
  53976. */
  53977. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  53978. /**
  53979. * @ignore
  53980. * The PassPostProcess id in the pipeline that contains the original scene color
  53981. */
  53982. SSAOOriginalSceneColorEffect: string;
  53983. /**
  53984. * @ignore
  53985. * The SSAO PostProcess id in the pipeline
  53986. */
  53987. SSAORenderEffect: string;
  53988. /**
  53989. * @ignore
  53990. * The horizontal blur PostProcess id in the pipeline
  53991. */
  53992. SSAOBlurHRenderEffect: string;
  53993. /**
  53994. * @ignore
  53995. * The vertical blur PostProcess id in the pipeline
  53996. */
  53997. SSAOBlurVRenderEffect: string;
  53998. /**
  53999. * @ignore
  54000. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  54001. */
  54002. SSAOCombineRenderEffect: string;
  54003. /**
  54004. * The output strength of the SSAO post-process. Default value is 1.0.
  54005. */
  54006. totalStrength: number;
  54007. /**
  54008. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  54009. */
  54010. maxZ: number;
  54011. /**
  54012. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  54013. */
  54014. minZAspect: number;
  54015. private _samples;
  54016. /**
  54017. * Number of samples used for the SSAO calculations. Default value is 8
  54018. */
  54019. samples: number;
  54020. private _textureSamples;
  54021. /**
  54022. * Number of samples to use for antialiasing
  54023. */
  54024. textureSamples: number;
  54025. /**
  54026. * Ratio object used for SSAO ratio and blur ratio
  54027. */
  54028. private _ratio;
  54029. /**
  54030. * Dynamically generated sphere sampler.
  54031. */
  54032. private _sampleSphere;
  54033. /**
  54034. * Blur filter offsets
  54035. */
  54036. private _samplerOffsets;
  54037. private _expensiveBlur;
  54038. /**
  54039. * If bilateral blur should be used
  54040. */
  54041. expensiveBlur: boolean;
  54042. /**
  54043. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  54044. */
  54045. radius: number;
  54046. /**
  54047. * The base color of the SSAO post-process
  54048. * The final result is "base + ssao" between [0, 1]
  54049. */
  54050. base: number;
  54051. /**
  54052. * Support test.
  54053. */
  54054. static readonly IsSupported: boolean;
  54055. private _scene;
  54056. private _depthTexture;
  54057. private _normalTexture;
  54058. private _randomTexture;
  54059. private _originalColorPostProcess;
  54060. private _ssaoPostProcess;
  54061. private _blurHPostProcess;
  54062. private _blurVPostProcess;
  54063. private _ssaoCombinePostProcess;
  54064. private _firstUpdate;
  54065. /**
  54066. * Gets active scene
  54067. */
  54068. readonly scene: Scene;
  54069. /**
  54070. * @constructor
  54071. * @param name The rendering pipeline name
  54072. * @param scene The scene linked to this pipeline
  54073. * @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 }
  54074. * @param cameras The array of cameras that the rendering pipeline will be attached to
  54075. */
  54076. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  54077. /**
  54078. * Get the class name
  54079. * @returns "SSAO2RenderingPipeline"
  54080. */
  54081. getClassName(): string;
  54082. /**
  54083. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  54084. */
  54085. dispose(disableGeometryBufferRenderer?: boolean): void;
  54086. private _createBlurPostProcess;
  54087. /** @hidden */
  54088. _rebuild(): void;
  54089. private _bits;
  54090. private _radicalInverse_VdC;
  54091. private _hammersley;
  54092. private _hemisphereSample_uniform;
  54093. private _generateHemisphere;
  54094. private _createSSAOPostProcess;
  54095. private _createSSAOCombinePostProcess;
  54096. private _createRandomTexture;
  54097. /**
  54098. * Serialize the rendering pipeline (Used when exporting)
  54099. * @returns the serialized object
  54100. */
  54101. serialize(): any;
  54102. /**
  54103. * Parse the serialized pipeline
  54104. * @param source Source pipeline.
  54105. * @param scene The scene to load the pipeline to.
  54106. * @param rootUrl The URL of the serialized pipeline.
  54107. * @returns An instantiated pipeline from the serialized object.
  54108. */
  54109. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  54110. }
  54111. }
  54112. declare module "babylonjs/Shaders/ssao.fragment" {
  54113. /** @hidden */
  54114. export var ssaoPixelShader: {
  54115. name: string;
  54116. shader: string;
  54117. };
  54118. }
  54119. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  54120. import { Camera } from "babylonjs/Cameras/camera";
  54121. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  54122. import { Scene } from "babylonjs/scene";
  54123. import "babylonjs/Shaders/ssao.fragment";
  54124. import "babylonjs/Shaders/ssaoCombine.fragment";
  54125. /**
  54126. * Render pipeline to produce ssao effect
  54127. */
  54128. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  54129. /**
  54130. * @ignore
  54131. * The PassPostProcess id in the pipeline that contains the original scene color
  54132. */
  54133. SSAOOriginalSceneColorEffect: string;
  54134. /**
  54135. * @ignore
  54136. * The SSAO PostProcess id in the pipeline
  54137. */
  54138. SSAORenderEffect: string;
  54139. /**
  54140. * @ignore
  54141. * The horizontal blur PostProcess id in the pipeline
  54142. */
  54143. SSAOBlurHRenderEffect: string;
  54144. /**
  54145. * @ignore
  54146. * The vertical blur PostProcess id in the pipeline
  54147. */
  54148. SSAOBlurVRenderEffect: string;
  54149. /**
  54150. * @ignore
  54151. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  54152. */
  54153. SSAOCombineRenderEffect: string;
  54154. /**
  54155. * The output strength of the SSAO post-process. Default value is 1.0.
  54156. */
  54157. totalStrength: number;
  54158. /**
  54159. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  54160. */
  54161. radius: number;
  54162. /**
  54163. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  54164. * Must not be equal to fallOff and superior to fallOff.
  54165. * Default value is 0.0075
  54166. */
  54167. area: number;
  54168. /**
  54169. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  54170. * Must not be equal to area and inferior to area.
  54171. * Default value is 0.000001
  54172. */
  54173. fallOff: number;
  54174. /**
  54175. * The base color of the SSAO post-process
  54176. * The final result is "base + ssao" between [0, 1]
  54177. */
  54178. base: number;
  54179. private _scene;
  54180. private _depthTexture;
  54181. private _randomTexture;
  54182. private _originalColorPostProcess;
  54183. private _ssaoPostProcess;
  54184. private _blurHPostProcess;
  54185. private _blurVPostProcess;
  54186. private _ssaoCombinePostProcess;
  54187. private _firstUpdate;
  54188. /**
  54189. * Gets active scene
  54190. */
  54191. readonly scene: Scene;
  54192. /**
  54193. * @constructor
  54194. * @param name - The rendering pipeline name
  54195. * @param scene - The scene linked to this pipeline
  54196. * @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 }
  54197. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  54198. */
  54199. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  54200. /**
  54201. * Get the class name
  54202. * @returns "SSAORenderingPipeline"
  54203. */
  54204. getClassName(): string;
  54205. /**
  54206. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  54207. */
  54208. dispose(disableDepthRender?: boolean): void;
  54209. private _createBlurPostProcess;
  54210. /** @hidden */
  54211. _rebuild(): void;
  54212. private _createSSAOPostProcess;
  54213. private _createSSAOCombinePostProcess;
  54214. private _createRandomTexture;
  54215. }
  54216. }
  54217. declare module "babylonjs/Shaders/standard.fragment" {
  54218. /** @hidden */
  54219. export var standardPixelShader: {
  54220. name: string;
  54221. shader: string;
  54222. };
  54223. }
  54224. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  54225. import { Nullable } from "babylonjs/types";
  54226. import { IAnimatable } from "babylonjs/Misc/tools";
  54227. import { Camera } from "babylonjs/Cameras/camera";
  54228. import { Texture } from "babylonjs/Materials/Textures/texture";
  54229. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  54230. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  54231. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  54232. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  54233. import { IDisposable } from "babylonjs/scene";
  54234. import { SpotLight } from "babylonjs/Lights/spotLight";
  54235. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  54236. import { Scene } from "babylonjs/scene";
  54237. import { Animation } from "babylonjs/Animations/animation";
  54238. import "babylonjs/Shaders/standard.fragment";
  54239. /**
  54240. * Standard rendering pipeline
  54241. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  54242. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  54243. */
  54244. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  54245. /**
  54246. * Public members
  54247. */
  54248. /**
  54249. * Post-process which contains the original scene color before the pipeline applies all the effects
  54250. */
  54251. originalPostProcess: Nullable<PostProcess>;
  54252. /**
  54253. * Post-process used to down scale an image x4
  54254. */
  54255. downSampleX4PostProcess: Nullable<PostProcess>;
  54256. /**
  54257. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  54258. */
  54259. brightPassPostProcess: Nullable<PostProcess>;
  54260. /**
  54261. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  54262. */
  54263. blurHPostProcesses: PostProcess[];
  54264. /**
  54265. * Post-process array storing all the vertical blur post-processes used by the pipeline
  54266. */
  54267. blurVPostProcesses: PostProcess[];
  54268. /**
  54269. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  54270. */
  54271. textureAdderPostProcess: Nullable<PostProcess>;
  54272. /**
  54273. * Post-process used to create volumetric lighting effect
  54274. */
  54275. volumetricLightPostProcess: Nullable<PostProcess>;
  54276. /**
  54277. * Post-process used to smooth the previous volumetric light post-process on the X axis
  54278. */
  54279. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  54280. /**
  54281. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  54282. */
  54283. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  54284. /**
  54285. * Post-process used to merge the volumetric light effect and the real scene color
  54286. */
  54287. volumetricLightMergePostProces: Nullable<PostProcess>;
  54288. /**
  54289. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  54290. */
  54291. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  54292. /**
  54293. * Base post-process used to calculate the average luminance of the final image for HDR
  54294. */
  54295. luminancePostProcess: Nullable<PostProcess>;
  54296. /**
  54297. * Post-processes used to create down sample post-processes in order to get
  54298. * the average luminance of the final image for HDR
  54299. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  54300. */
  54301. luminanceDownSamplePostProcesses: PostProcess[];
  54302. /**
  54303. * Post-process used to create a HDR effect (light adaptation)
  54304. */
  54305. hdrPostProcess: Nullable<PostProcess>;
  54306. /**
  54307. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  54308. */
  54309. textureAdderFinalPostProcess: Nullable<PostProcess>;
  54310. /**
  54311. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  54312. */
  54313. lensFlareFinalPostProcess: Nullable<PostProcess>;
  54314. /**
  54315. * Post-process used to merge the final HDR post-process and the real scene color
  54316. */
  54317. hdrFinalPostProcess: Nullable<PostProcess>;
  54318. /**
  54319. * Post-process used to create a lens flare effect
  54320. */
  54321. lensFlarePostProcess: Nullable<PostProcess>;
  54322. /**
  54323. * Post-process that merges the result of the lens flare post-process and the real scene color
  54324. */
  54325. lensFlareComposePostProcess: Nullable<PostProcess>;
  54326. /**
  54327. * Post-process used to create a motion blur effect
  54328. */
  54329. motionBlurPostProcess: Nullable<PostProcess>;
  54330. /**
  54331. * Post-process used to create a depth of field effect
  54332. */
  54333. depthOfFieldPostProcess: Nullable<PostProcess>;
  54334. /**
  54335. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  54336. */
  54337. fxaaPostProcess: Nullable<FxaaPostProcess>;
  54338. /**
  54339. * Represents the brightness threshold in order to configure the illuminated surfaces
  54340. */
  54341. brightThreshold: number;
  54342. /**
  54343. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  54344. */
  54345. blurWidth: number;
  54346. /**
  54347. * Sets if the blur for highlighted surfaces must be only horizontal
  54348. */
  54349. horizontalBlur: boolean;
  54350. /**
  54351. * Sets the overall exposure used by the pipeline
  54352. */
  54353. exposure: number;
  54354. /**
  54355. * Texture used typically to simulate "dirty" on camera lens
  54356. */
  54357. lensTexture: Nullable<Texture>;
  54358. /**
  54359. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  54360. */
  54361. volumetricLightCoefficient: number;
  54362. /**
  54363. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  54364. */
  54365. volumetricLightPower: number;
  54366. /**
  54367. * Used the set the blur intensity to smooth the volumetric lights
  54368. */
  54369. volumetricLightBlurScale: number;
  54370. /**
  54371. * Light (spot or directional) used to generate the volumetric lights rays
  54372. * The source light must have a shadow generate so the pipeline can get its
  54373. * depth map
  54374. */
  54375. sourceLight: Nullable<SpotLight | DirectionalLight>;
  54376. /**
  54377. * For eye adaptation, represents the minimum luminance the eye can see
  54378. */
  54379. hdrMinimumLuminance: number;
  54380. /**
  54381. * For eye adaptation, represents the decrease luminance speed
  54382. */
  54383. hdrDecreaseRate: number;
  54384. /**
  54385. * For eye adaptation, represents the increase luminance speed
  54386. */
  54387. hdrIncreaseRate: number;
  54388. /**
  54389. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  54390. */
  54391. lensColorTexture: Nullable<Texture>;
  54392. /**
  54393. * The overall strengh for the lens flare effect
  54394. */
  54395. lensFlareStrength: number;
  54396. /**
  54397. * Dispersion coefficient for lens flare ghosts
  54398. */
  54399. lensFlareGhostDispersal: number;
  54400. /**
  54401. * Main lens flare halo width
  54402. */
  54403. lensFlareHaloWidth: number;
  54404. /**
  54405. * Based on the lens distortion effect, defines how much the lens flare result
  54406. * is distorted
  54407. */
  54408. lensFlareDistortionStrength: number;
  54409. /**
  54410. * Lens star texture must be used to simulate rays on the flares and is available
  54411. * in the documentation
  54412. */
  54413. lensStarTexture: Nullable<Texture>;
  54414. /**
  54415. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  54416. * flare effect by taking account of the dirt texture
  54417. */
  54418. lensFlareDirtTexture: Nullable<Texture>;
  54419. /**
  54420. * Represents the focal length for the depth of field effect
  54421. */
  54422. depthOfFieldDistance: number;
  54423. /**
  54424. * Represents the blur intensity for the blurred part of the depth of field effect
  54425. */
  54426. depthOfFieldBlurWidth: number;
  54427. /**
  54428. * For motion blur, defines how much the image is blurred by the movement
  54429. */
  54430. motionStrength: number;
  54431. /**
  54432. * List of animations for the pipeline (IAnimatable implementation)
  54433. */
  54434. animations: Animation[];
  54435. /**
  54436. * Private members
  54437. */
  54438. private _scene;
  54439. private _currentDepthOfFieldSource;
  54440. private _basePostProcess;
  54441. private _hdrCurrentLuminance;
  54442. private _floatTextureType;
  54443. private _ratio;
  54444. private _bloomEnabled;
  54445. private _depthOfFieldEnabled;
  54446. private _vlsEnabled;
  54447. private _lensFlareEnabled;
  54448. private _hdrEnabled;
  54449. private _motionBlurEnabled;
  54450. private _fxaaEnabled;
  54451. private _motionBlurSamples;
  54452. private _volumetricLightStepsCount;
  54453. private _samples;
  54454. /**
  54455. * @ignore
  54456. * Specifies if the bloom pipeline is enabled
  54457. */
  54458. BloomEnabled: boolean;
  54459. /**
  54460. * @ignore
  54461. * Specifies if the depth of field pipeline is enabed
  54462. */
  54463. DepthOfFieldEnabled: boolean;
  54464. /**
  54465. * @ignore
  54466. * Specifies if the lens flare pipeline is enabed
  54467. */
  54468. LensFlareEnabled: boolean;
  54469. /**
  54470. * @ignore
  54471. * Specifies if the HDR pipeline is enabled
  54472. */
  54473. HDREnabled: boolean;
  54474. /**
  54475. * @ignore
  54476. * Specifies if the volumetric lights scattering effect is enabled
  54477. */
  54478. VLSEnabled: boolean;
  54479. /**
  54480. * @ignore
  54481. * Specifies if the motion blur effect is enabled
  54482. */
  54483. MotionBlurEnabled: boolean;
  54484. /**
  54485. * Specifies if anti-aliasing is enabled
  54486. */
  54487. fxaaEnabled: boolean;
  54488. /**
  54489. * Specifies the number of steps used to calculate the volumetric lights
  54490. * Typically in interval [50, 200]
  54491. */
  54492. volumetricLightStepsCount: number;
  54493. /**
  54494. * Specifies the number of samples used for the motion blur effect
  54495. * Typically in interval [16, 64]
  54496. */
  54497. motionBlurSamples: number;
  54498. /**
  54499. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  54500. */
  54501. samples: number;
  54502. /**
  54503. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  54504. * @constructor
  54505. * @param name The rendering pipeline name
  54506. * @param scene The scene linked to this pipeline
  54507. * @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)
  54508. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  54509. * @param cameras The array of cameras that the rendering pipeline will be attached to
  54510. */
  54511. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  54512. private _buildPipeline;
  54513. private _createDownSampleX4PostProcess;
  54514. private _createBrightPassPostProcess;
  54515. private _createBlurPostProcesses;
  54516. private _createTextureAdderPostProcess;
  54517. private _createVolumetricLightPostProcess;
  54518. private _createLuminancePostProcesses;
  54519. private _createHdrPostProcess;
  54520. private _createLensFlarePostProcess;
  54521. private _createDepthOfFieldPostProcess;
  54522. private _createMotionBlurPostProcess;
  54523. private _getDepthTexture;
  54524. private _disposePostProcesses;
  54525. /**
  54526. * Dispose of the pipeline and stop all post processes
  54527. */
  54528. dispose(): void;
  54529. /**
  54530. * Serialize the rendering pipeline (Used when exporting)
  54531. * @returns the serialized object
  54532. */
  54533. serialize(): any;
  54534. /**
  54535. * Parse the serialized pipeline
  54536. * @param source Source pipeline.
  54537. * @param scene The scene to load the pipeline to.
  54538. * @param rootUrl The URL of the serialized pipeline.
  54539. * @returns An instantiated pipeline from the serialized object.
  54540. */
  54541. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  54542. /**
  54543. * Luminance steps
  54544. */
  54545. static LuminanceSteps: number;
  54546. }
  54547. }
  54548. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  54549. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  54550. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  54551. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  54552. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  54553. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  54554. }
  54555. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  54556. import { Camera } from "babylonjs/Cameras/camera";
  54557. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  54558. /**
  54559. * PostProcessRenderPipelineManager class
  54560. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  54561. */
  54562. export class PostProcessRenderPipelineManager {
  54563. private _renderPipelines;
  54564. /**
  54565. * Initializes a PostProcessRenderPipelineManager
  54566. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  54567. */
  54568. constructor();
  54569. /**
  54570. * Gets the list of supported render pipelines
  54571. */
  54572. readonly supportedPipelines: PostProcessRenderPipeline[];
  54573. /**
  54574. * Adds a pipeline to the manager
  54575. * @param renderPipeline The pipeline to add
  54576. */
  54577. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  54578. /**
  54579. * Attaches a camera to the pipeline
  54580. * @param renderPipelineName The name of the pipeline to attach to
  54581. * @param cameras the camera to attach
  54582. * @param unique if the camera can be attached multiple times to the pipeline
  54583. */
  54584. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  54585. /**
  54586. * Detaches a camera from the pipeline
  54587. * @param renderPipelineName The name of the pipeline to detach from
  54588. * @param cameras the camera to detach
  54589. */
  54590. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  54591. /**
  54592. * Enables an effect by name on a pipeline
  54593. * @param renderPipelineName the name of the pipeline to enable the effect in
  54594. * @param renderEffectName the name of the effect to enable
  54595. * @param cameras the cameras that the effect should be enabled on
  54596. */
  54597. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  54598. /**
  54599. * Disables an effect by name on a pipeline
  54600. * @param renderPipelineName the name of the pipeline to disable the effect in
  54601. * @param renderEffectName the name of the effect to disable
  54602. * @param cameras the cameras that the effect should be disabled on
  54603. */
  54604. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  54605. /**
  54606. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  54607. */
  54608. update(): void;
  54609. /** @hidden */
  54610. _rebuild(): void;
  54611. /**
  54612. * Disposes of the manager and pipelines
  54613. */
  54614. dispose(): void;
  54615. }
  54616. }
  54617. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  54618. import { ISceneComponent } from "babylonjs/sceneComponent";
  54619. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  54620. import { Scene } from "babylonjs/scene";
  54621. module "babylonjs/scene" {
  54622. interface Scene {
  54623. /** @hidden (Backing field) */
  54624. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  54625. /**
  54626. * Gets the postprocess render pipeline manager
  54627. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  54628. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  54629. */
  54630. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  54631. }
  54632. }
  54633. /**
  54634. * Defines the Render Pipeline scene component responsible to rendering pipelines
  54635. */
  54636. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  54637. /**
  54638. * The component name helpfull to identify the component in the list of scene components.
  54639. */
  54640. readonly name: string;
  54641. /**
  54642. * The scene the component belongs to.
  54643. */
  54644. scene: Scene;
  54645. /**
  54646. * Creates a new instance of the component for the given scene
  54647. * @param scene Defines the scene to register the component in
  54648. */
  54649. constructor(scene: Scene);
  54650. /**
  54651. * Registers the component in a given scene
  54652. */
  54653. register(): void;
  54654. /**
  54655. * Rebuilds the elements related to this component in case of
  54656. * context lost for instance.
  54657. */
  54658. rebuild(): void;
  54659. /**
  54660. * Disposes the component and the associated ressources
  54661. */
  54662. dispose(): void;
  54663. private _gatherRenderTargets;
  54664. }
  54665. }
  54666. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  54667. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  54668. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  54669. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  54670. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  54671. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  54672. }
  54673. declare module "babylonjs/Shaders/tonemap.fragment" {
  54674. /** @hidden */
  54675. export var tonemapPixelShader: {
  54676. name: string;
  54677. shader: string;
  54678. };
  54679. }
  54680. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  54681. import { Camera } from "babylonjs/Cameras/camera";
  54682. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  54683. import "babylonjs/Shaders/tonemap.fragment";
  54684. import { Engine } from "babylonjs/Engines/engine";
  54685. /** Defines operator used for tonemapping */
  54686. export enum TonemappingOperator {
  54687. /** Hable */
  54688. Hable = 0,
  54689. /** Reinhard */
  54690. Reinhard = 1,
  54691. /** HejiDawson */
  54692. HejiDawson = 2,
  54693. /** Photographic */
  54694. Photographic = 3
  54695. }
  54696. /**
  54697. * Defines a post process to apply tone mapping
  54698. */
  54699. export class TonemapPostProcess extends PostProcess {
  54700. private _operator;
  54701. /** Defines the required exposure adjustement */
  54702. exposureAdjustment: number;
  54703. /**
  54704. * Creates a new TonemapPostProcess
  54705. * @param name defines the name of the postprocess
  54706. * @param _operator defines the operator to use
  54707. * @param exposureAdjustment defines the required exposure adjustement
  54708. * @param camera defines the camera to use (can be null)
  54709. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  54710. * @param engine defines the hosting engine (can be ignore if camera is set)
  54711. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  54712. */
  54713. constructor(name: string, _operator: TonemappingOperator,
  54714. /** Defines the required exposure adjustement */
  54715. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  54716. }
  54717. }
  54718. declare module "babylonjs/Shaders/depth.vertex" {
  54719. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  54720. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  54721. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  54722. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  54723. /** @hidden */
  54724. export var depthVertexShader: {
  54725. name: string;
  54726. shader: string;
  54727. };
  54728. }
  54729. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  54730. /** @hidden */
  54731. export var volumetricLightScatteringPixelShader: {
  54732. name: string;
  54733. shader: string;
  54734. };
  54735. }
  54736. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  54737. /** @hidden */
  54738. export var volumetricLightScatteringPassPixelShader: {
  54739. name: string;
  54740. shader: string;
  54741. };
  54742. }
  54743. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  54744. import { Vector3 } from "babylonjs/Maths/math";
  54745. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54746. import { Mesh } from "babylonjs/Meshes/mesh";
  54747. import { Camera } from "babylonjs/Cameras/camera";
  54748. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  54749. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  54750. import { Scene } from "babylonjs/scene";
  54751. import "babylonjs/Meshes/Builders/planeBuilder";
  54752. import "babylonjs/Shaders/depth.vertex";
  54753. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  54754. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  54755. import { Engine } from "babylonjs/Engines/engine";
  54756. /**
  54757. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  54758. */
  54759. export class VolumetricLightScatteringPostProcess extends PostProcess {
  54760. private _volumetricLightScatteringPass;
  54761. private _volumetricLightScatteringRTT;
  54762. private _viewPort;
  54763. private _screenCoordinates;
  54764. private _cachedDefines;
  54765. /**
  54766. * If not undefined, the mesh position is computed from the attached node position
  54767. */
  54768. attachedNode: {
  54769. position: Vector3;
  54770. };
  54771. /**
  54772. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  54773. */
  54774. customMeshPosition: Vector3;
  54775. /**
  54776. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  54777. */
  54778. useCustomMeshPosition: boolean;
  54779. /**
  54780. * If the post-process should inverse the light scattering direction
  54781. */
  54782. invert: boolean;
  54783. /**
  54784. * The internal mesh used by the post-process
  54785. */
  54786. mesh: Mesh;
  54787. /**
  54788. * @hidden
  54789. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  54790. */
  54791. useDiffuseColor: boolean;
  54792. /**
  54793. * Array containing the excluded meshes not rendered in the internal pass
  54794. */
  54795. excludedMeshes: AbstractMesh[];
  54796. /**
  54797. * Controls the overall intensity of the post-process
  54798. */
  54799. exposure: number;
  54800. /**
  54801. * Dissipates each sample's contribution in range [0, 1]
  54802. */
  54803. decay: number;
  54804. /**
  54805. * Controls the overall intensity of each sample
  54806. */
  54807. weight: number;
  54808. /**
  54809. * Controls the density of each sample
  54810. */
  54811. density: number;
  54812. /**
  54813. * @constructor
  54814. * @param name The post-process name
  54815. * @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)
  54816. * @param camera The camera that the post-process will be attached to
  54817. * @param mesh The mesh used to create the light scattering
  54818. * @param samples The post-process quality, default 100
  54819. * @param samplingModeThe post-process filtering mode
  54820. * @param engine The babylon engine
  54821. * @param reusable If the post-process is reusable
  54822. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  54823. */
  54824. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  54825. /**
  54826. * Returns the string "VolumetricLightScatteringPostProcess"
  54827. * @returns "VolumetricLightScatteringPostProcess"
  54828. */
  54829. getClassName(): string;
  54830. private _isReady;
  54831. /**
  54832. * Sets the new light position for light scattering effect
  54833. * @param position The new custom light position
  54834. */
  54835. setCustomMeshPosition(position: Vector3): void;
  54836. /**
  54837. * Returns the light position for light scattering effect
  54838. * @return Vector3 The custom light position
  54839. */
  54840. getCustomMeshPosition(): Vector3;
  54841. /**
  54842. * Disposes the internal assets and detaches the post-process from the camera
  54843. */
  54844. dispose(camera: Camera): void;
  54845. /**
  54846. * Returns the render target texture used by the post-process
  54847. * @return the render target texture used by the post-process
  54848. */
  54849. getPass(): RenderTargetTexture;
  54850. private _meshExcluded;
  54851. private _createPass;
  54852. private _updateMeshScreenCoordinates;
  54853. /**
  54854. * Creates a default mesh for the Volumeric Light Scattering post-process
  54855. * @param name The mesh name
  54856. * @param scene The scene where to create the mesh
  54857. * @return the default mesh
  54858. */
  54859. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  54860. }
  54861. }
  54862. declare module "babylonjs/PostProcesses/index" {
  54863. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  54864. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  54865. export * from "babylonjs/PostProcesses/bloomEffect";
  54866. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  54867. export * from "babylonjs/PostProcesses/blurPostProcess";
  54868. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  54869. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  54870. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  54871. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  54872. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  54873. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  54874. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  54875. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  54876. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  54877. export * from "babylonjs/PostProcesses/filterPostProcess";
  54878. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  54879. export * from "babylonjs/PostProcesses/grainPostProcess";
  54880. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  54881. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  54882. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  54883. export * from "babylonjs/PostProcesses/passPostProcess";
  54884. export * from "babylonjs/PostProcesses/postProcess";
  54885. export * from "babylonjs/PostProcesses/postProcessManager";
  54886. export * from "babylonjs/PostProcesses/refractionPostProcess";
  54887. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  54888. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  54889. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  54890. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  54891. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  54892. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  54893. }
  54894. declare module "babylonjs/Probes/index" {
  54895. export * from "babylonjs/Probes/reflectionProbe";
  54896. }
  54897. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  54898. import { Scene } from "babylonjs/scene";
  54899. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54900. import { Color3 } from "babylonjs/Maths/math";
  54901. import { SmartArray } from "babylonjs/Misc/smartArray";
  54902. import { ISceneComponent } from "babylonjs/sceneComponent";
  54903. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  54904. import "babylonjs/Meshes/Builders/boxBuilder";
  54905. import "babylonjs/Shaders/color.fragment";
  54906. import "babylonjs/Shaders/color.vertex";
  54907. module "babylonjs/scene" {
  54908. interface Scene {
  54909. /** @hidden (Backing field) */
  54910. _boundingBoxRenderer: BoundingBoxRenderer;
  54911. /** @hidden (Backing field) */
  54912. _forceShowBoundingBoxes: boolean;
  54913. /**
  54914. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  54915. */
  54916. forceShowBoundingBoxes: boolean;
  54917. /**
  54918. * Gets the bounding box renderer associated with the scene
  54919. * @returns a BoundingBoxRenderer
  54920. */
  54921. getBoundingBoxRenderer(): BoundingBoxRenderer;
  54922. }
  54923. }
  54924. module "babylonjs/Meshes/abstractMesh" {
  54925. interface AbstractMesh {
  54926. /** @hidden (Backing field) */
  54927. _showBoundingBox: boolean;
  54928. /**
  54929. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  54930. */
  54931. showBoundingBox: boolean;
  54932. }
  54933. }
  54934. /**
  54935. * Component responsible of rendering the bounding box of the meshes in a scene.
  54936. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  54937. */
  54938. export class BoundingBoxRenderer implements ISceneComponent {
  54939. /**
  54940. * The component name helpfull to identify the component in the list of scene components.
  54941. */
  54942. readonly name: string;
  54943. /**
  54944. * The scene the component belongs to.
  54945. */
  54946. scene: Scene;
  54947. /**
  54948. * Color of the bounding box lines placed in front of an object
  54949. */
  54950. frontColor: Color3;
  54951. /**
  54952. * Color of the bounding box lines placed behind an object
  54953. */
  54954. backColor: Color3;
  54955. /**
  54956. * Defines if the renderer should show the back lines or not
  54957. */
  54958. showBackLines: boolean;
  54959. /**
  54960. * @hidden
  54961. */
  54962. renderList: SmartArray<BoundingBox>;
  54963. private _colorShader;
  54964. private _vertexBuffers;
  54965. private _indexBuffer;
  54966. /**
  54967. * Instantiates a new bounding box renderer in a scene.
  54968. * @param scene the scene the renderer renders in
  54969. */
  54970. constructor(scene: Scene);
  54971. /**
  54972. * Registers the component in a given scene
  54973. */
  54974. register(): void;
  54975. private _evaluateSubMesh;
  54976. private _activeMesh;
  54977. private _prepareRessources;
  54978. private _createIndexBuffer;
  54979. /**
  54980. * Rebuilds the elements related to this component in case of
  54981. * context lost for instance.
  54982. */
  54983. rebuild(): void;
  54984. /**
  54985. * @hidden
  54986. */
  54987. reset(): void;
  54988. /**
  54989. * Render the bounding boxes of a specific rendering group
  54990. * @param renderingGroupId defines the rendering group to render
  54991. */
  54992. render(renderingGroupId: number): void;
  54993. /**
  54994. * In case of occlusion queries, we can render the occlusion bounding box through this method
  54995. * @param mesh Define the mesh to render the occlusion bounding box for
  54996. */
  54997. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  54998. /**
  54999. * Dispose and release the resources attached to this renderer.
  55000. */
  55001. dispose(): void;
  55002. }
  55003. }
  55004. declare module "babylonjs/Shaders/depth.fragment" {
  55005. /** @hidden */
  55006. export var depthPixelShader: {
  55007. name: string;
  55008. shader: string;
  55009. };
  55010. }
  55011. declare module "babylonjs/Rendering/depthRenderer" {
  55012. import { Nullable } from "babylonjs/types";
  55013. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55014. import { Scene } from "babylonjs/scene";
  55015. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  55016. import { Camera } from "babylonjs/Cameras/camera";
  55017. import "babylonjs/Shaders/depth.fragment";
  55018. import "babylonjs/Shaders/depth.vertex";
  55019. /**
  55020. * This represents a depth renderer in Babylon.
  55021. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  55022. */
  55023. export class DepthRenderer {
  55024. private _scene;
  55025. private _depthMap;
  55026. private _effect;
  55027. private _cachedDefines;
  55028. private _camera;
  55029. /**
  55030. * Specifiess that the depth renderer will only be used within
  55031. * the camera it is created for.
  55032. * This can help forcing its rendering during the camera processing.
  55033. */
  55034. useOnlyInActiveCamera: boolean;
  55035. /** @hidden */
  55036. static _SceneComponentInitialization: (scene: Scene) => void;
  55037. /**
  55038. * Instantiates a depth renderer
  55039. * @param scene The scene the renderer belongs to
  55040. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  55041. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  55042. */
  55043. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  55044. /**
  55045. * Creates the depth rendering effect and checks if the effect is ready.
  55046. * @param subMesh The submesh to be used to render the depth map of
  55047. * @param useInstances If multiple world instances should be used
  55048. * @returns if the depth renderer is ready to render the depth map
  55049. */
  55050. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  55051. /**
  55052. * Gets the texture which the depth map will be written to.
  55053. * @returns The depth map texture
  55054. */
  55055. getDepthMap(): RenderTargetTexture;
  55056. /**
  55057. * Disposes of the depth renderer.
  55058. */
  55059. dispose(): void;
  55060. }
  55061. }
  55062. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  55063. import { Nullable } from "babylonjs/types";
  55064. import { Scene } from "babylonjs/scene";
  55065. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  55066. import { Camera } from "babylonjs/Cameras/camera";
  55067. import { ISceneComponent } from "babylonjs/sceneComponent";
  55068. module "babylonjs/scene" {
  55069. interface Scene {
  55070. /** @hidden (Backing field) */
  55071. _depthRenderer: {
  55072. [id: string]: DepthRenderer;
  55073. };
  55074. /**
  55075. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  55076. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  55077. * @returns the created depth renderer
  55078. */
  55079. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  55080. /**
  55081. * Disables a depth renderer for a given camera
  55082. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  55083. */
  55084. disableDepthRenderer(camera?: Nullable<Camera>): void;
  55085. }
  55086. }
  55087. /**
  55088. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  55089. * in several rendering techniques.
  55090. */
  55091. export class DepthRendererSceneComponent implements ISceneComponent {
  55092. /**
  55093. * The component name helpfull to identify the component in the list of scene components.
  55094. */
  55095. readonly name: string;
  55096. /**
  55097. * The scene the component belongs to.
  55098. */
  55099. scene: Scene;
  55100. /**
  55101. * Creates a new instance of the component for the given scene
  55102. * @param scene Defines the scene to register the component in
  55103. */
  55104. constructor(scene: Scene);
  55105. /**
  55106. * Registers the component in a given scene
  55107. */
  55108. register(): void;
  55109. /**
  55110. * Rebuilds the elements related to this component in case of
  55111. * context lost for instance.
  55112. */
  55113. rebuild(): void;
  55114. /**
  55115. * Disposes the component and the associated ressources
  55116. */
  55117. dispose(): void;
  55118. private _gatherRenderTargets;
  55119. private _gatherActiveCameraRenderTargets;
  55120. }
  55121. }
  55122. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  55123. import { Nullable } from "babylonjs/types";
  55124. import { Scene } from "babylonjs/scene";
  55125. import { ISceneComponent } from "babylonjs/sceneComponent";
  55126. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  55127. module "babylonjs/scene" {
  55128. interface Scene {
  55129. /** @hidden (Backing field) */
  55130. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  55131. /**
  55132. * Gets or Sets the current geometry buffer associated to the scene.
  55133. */
  55134. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  55135. /**
  55136. * Enables a GeometryBufferRender and associates it with the scene
  55137. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  55138. * @returns the GeometryBufferRenderer
  55139. */
  55140. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  55141. /**
  55142. * Disables the GeometryBufferRender associated with the scene
  55143. */
  55144. disableGeometryBufferRenderer(): void;
  55145. }
  55146. }
  55147. /**
  55148. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  55149. * in several rendering techniques.
  55150. */
  55151. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  55152. /**
  55153. * The component name helpful to identify the component in the list of scene components.
  55154. */
  55155. readonly name: string;
  55156. /**
  55157. * The scene the component belongs to.
  55158. */
  55159. scene: Scene;
  55160. /**
  55161. * Creates a new instance of the component for the given scene
  55162. * @param scene Defines the scene to register the component in
  55163. */
  55164. constructor(scene: Scene);
  55165. /**
  55166. * Registers the component in a given scene
  55167. */
  55168. register(): void;
  55169. /**
  55170. * Rebuilds the elements related to this component in case of
  55171. * context lost for instance.
  55172. */
  55173. rebuild(): void;
  55174. /**
  55175. * Disposes the component and the associated ressources
  55176. */
  55177. dispose(): void;
  55178. private _gatherRenderTargets;
  55179. }
  55180. }
  55181. declare module "babylonjs/Shaders/outline.fragment" {
  55182. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  55183. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  55184. /** @hidden */
  55185. export var outlinePixelShader: {
  55186. name: string;
  55187. shader: string;
  55188. };
  55189. }
  55190. declare module "babylonjs/Shaders/outline.vertex" {
  55191. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  55192. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  55193. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  55194. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  55195. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  55196. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  55197. /** @hidden */
  55198. export var outlineVertexShader: {
  55199. name: string;
  55200. shader: string;
  55201. };
  55202. }
  55203. declare module "babylonjs/Rendering/outlineRenderer" {
  55204. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55205. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  55206. import { Scene } from "babylonjs/scene";
  55207. import { ISceneComponent } from "babylonjs/sceneComponent";
  55208. import "babylonjs/Shaders/outline.fragment";
  55209. import "babylonjs/Shaders/outline.vertex";
  55210. module "babylonjs/scene" {
  55211. interface Scene {
  55212. /** @hidden */
  55213. _outlineRenderer: OutlineRenderer;
  55214. /**
  55215. * Gets the outline renderer associated with the scene
  55216. * @returns a OutlineRenderer
  55217. */
  55218. getOutlineRenderer(): OutlineRenderer;
  55219. }
  55220. }
  55221. module "babylonjs/Meshes/abstractMesh" {
  55222. interface AbstractMesh {
  55223. /** @hidden (Backing field) */
  55224. _renderOutline: boolean;
  55225. /**
  55226. * Gets or sets a boolean indicating if the outline must be rendered as well
  55227. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  55228. */
  55229. renderOutline: boolean;
  55230. /** @hidden (Backing field) */
  55231. _renderOverlay: boolean;
  55232. /**
  55233. * Gets or sets a boolean indicating if the overlay must be rendered as well
  55234. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  55235. */
  55236. renderOverlay: boolean;
  55237. }
  55238. }
  55239. /**
  55240. * This class is responsible to draw bothe outline/overlay of meshes.
  55241. * It should not be used directly but through the available method on mesh.
  55242. */
  55243. export class OutlineRenderer implements ISceneComponent {
  55244. /**
  55245. * The name of the component. Each component must have a unique name.
  55246. */
  55247. name: string;
  55248. /**
  55249. * The scene the component belongs to.
  55250. */
  55251. scene: Scene;
  55252. /**
  55253. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  55254. */
  55255. zOffset: number;
  55256. private _engine;
  55257. private _effect;
  55258. private _cachedDefines;
  55259. private _savedDepthWrite;
  55260. /**
  55261. * Instantiates a new outline renderer. (There could be only one per scene).
  55262. * @param scene Defines the scene it belongs to
  55263. */
  55264. constructor(scene: Scene);
  55265. /**
  55266. * Register the component to one instance of a scene.
  55267. */
  55268. register(): void;
  55269. /**
  55270. * Rebuilds the elements related to this component in case of
  55271. * context lost for instance.
  55272. */
  55273. rebuild(): void;
  55274. /**
  55275. * Disposes the component and the associated ressources.
  55276. */
  55277. dispose(): void;
  55278. /**
  55279. * Renders the outline in the canvas.
  55280. * @param subMesh Defines the sumesh to render
  55281. * @param batch Defines the batch of meshes in case of instances
  55282. * @param useOverlay Defines if the rendering is for the overlay or the outline
  55283. */
  55284. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  55285. /**
  55286. * Returns whether or not the outline renderer is ready for a given submesh.
  55287. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  55288. * @param subMesh Defines the submesh to check readyness for
  55289. * @param useInstances Defines wheter wee are trying to render instances or not
  55290. * @returns true if ready otherwise false
  55291. */
  55292. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  55293. private _beforeRenderingMesh;
  55294. private _afterRenderingMesh;
  55295. }
  55296. }
  55297. declare module "babylonjs/Rendering/index" {
  55298. export * from "babylonjs/Rendering/boundingBoxRenderer";
  55299. export * from "babylonjs/Rendering/depthRenderer";
  55300. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  55301. export * from "babylonjs/Rendering/edgesRenderer";
  55302. export * from "babylonjs/Rendering/geometryBufferRenderer";
  55303. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  55304. export * from "babylonjs/Rendering/outlineRenderer";
  55305. export * from "babylonjs/Rendering/renderingGroup";
  55306. export * from "babylonjs/Rendering/renderingManager";
  55307. export * from "babylonjs/Rendering/utilityLayerRenderer";
  55308. }
  55309. declare module "babylonjs/Sprites/index" {
  55310. export * from "babylonjs/Sprites/sprite";
  55311. export * from "babylonjs/Sprites/spriteManager";
  55312. export * from "babylonjs/Sprites/spriteSceneComponent";
  55313. }
  55314. declare module "babylonjs/Misc/assetsManager" {
  55315. import { Scene } from "babylonjs/scene";
  55316. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55317. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  55318. import { Skeleton } from "babylonjs/Bones/skeleton";
  55319. import { Observable } from "babylonjs/Misc/observable";
  55320. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55321. import { Texture } from "babylonjs/Materials/Textures/texture";
  55322. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  55323. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  55324. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  55325. /**
  55326. * Defines the list of states available for a task inside a AssetsManager
  55327. */
  55328. export enum AssetTaskState {
  55329. /**
  55330. * Initialization
  55331. */
  55332. INIT = 0,
  55333. /**
  55334. * Running
  55335. */
  55336. RUNNING = 1,
  55337. /**
  55338. * Done
  55339. */
  55340. DONE = 2,
  55341. /**
  55342. * Error
  55343. */
  55344. ERROR = 3
  55345. }
  55346. /**
  55347. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  55348. */
  55349. export abstract class AbstractAssetTask {
  55350. /**
  55351. * Task name
  55352. */ name: string;
  55353. /**
  55354. * Callback called when the task is successful
  55355. */
  55356. onSuccess: (task: any) => void;
  55357. /**
  55358. * Callback called when the task is not successful
  55359. */
  55360. onError: (task: any, message?: string, exception?: any) => void;
  55361. /**
  55362. * Creates a new AssetsManager
  55363. * @param name defines the name of the task
  55364. */
  55365. constructor(
  55366. /**
  55367. * Task name
  55368. */ name: string);
  55369. private _isCompleted;
  55370. private _taskState;
  55371. private _errorObject;
  55372. /**
  55373. * Get if the task is completed
  55374. */
  55375. readonly isCompleted: boolean;
  55376. /**
  55377. * Gets the current state of the task
  55378. */
  55379. readonly taskState: AssetTaskState;
  55380. /**
  55381. * Gets the current error object (if task is in error)
  55382. */
  55383. readonly errorObject: {
  55384. message?: string;
  55385. exception?: any;
  55386. };
  55387. /**
  55388. * Internal only
  55389. * @hidden
  55390. */
  55391. _setErrorObject(message?: string, exception?: any): void;
  55392. /**
  55393. * Execute the current task
  55394. * @param scene defines the scene where you want your assets to be loaded
  55395. * @param onSuccess is a callback called when the task is successfully executed
  55396. * @param onError is a callback called if an error occurs
  55397. */
  55398. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55399. /**
  55400. * Execute the current task
  55401. * @param scene defines the scene where you want your assets to be loaded
  55402. * @param onSuccess is a callback called when the task is successfully executed
  55403. * @param onError is a callback called if an error occurs
  55404. */
  55405. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55406. /**
  55407. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  55408. * This can be used with failed tasks that have the reason for failure fixed.
  55409. */
  55410. reset(): void;
  55411. private onErrorCallback;
  55412. private onDoneCallback;
  55413. }
  55414. /**
  55415. * Define the interface used by progress events raised during assets loading
  55416. */
  55417. export interface IAssetsProgressEvent {
  55418. /**
  55419. * Defines the number of remaining tasks to process
  55420. */
  55421. remainingCount: number;
  55422. /**
  55423. * Defines the total number of tasks
  55424. */
  55425. totalCount: number;
  55426. /**
  55427. * Defines the task that was just processed
  55428. */
  55429. task: AbstractAssetTask;
  55430. }
  55431. /**
  55432. * Class used to share progress information about assets loading
  55433. */
  55434. export class AssetsProgressEvent implements IAssetsProgressEvent {
  55435. /**
  55436. * Defines the number of remaining tasks to process
  55437. */
  55438. remainingCount: number;
  55439. /**
  55440. * Defines the total number of tasks
  55441. */
  55442. totalCount: number;
  55443. /**
  55444. * Defines the task that was just processed
  55445. */
  55446. task: AbstractAssetTask;
  55447. /**
  55448. * Creates a AssetsProgressEvent
  55449. * @param remainingCount defines the number of remaining tasks to process
  55450. * @param totalCount defines the total number of tasks
  55451. * @param task defines the task that was just processed
  55452. */
  55453. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  55454. }
  55455. /**
  55456. * Define a task used by AssetsManager to load meshes
  55457. */
  55458. export class MeshAssetTask extends AbstractAssetTask {
  55459. /**
  55460. * Defines the name of the task
  55461. */
  55462. name: string;
  55463. /**
  55464. * Defines the list of mesh's names you want to load
  55465. */
  55466. meshesNames: any;
  55467. /**
  55468. * Defines the root url to use as a base to load your meshes and associated resources
  55469. */
  55470. rootUrl: string;
  55471. /**
  55472. * Defines the filename of the scene to load from
  55473. */
  55474. sceneFilename: string;
  55475. /**
  55476. * Gets the list of loaded meshes
  55477. */
  55478. loadedMeshes: Array<AbstractMesh>;
  55479. /**
  55480. * Gets the list of loaded particle systems
  55481. */
  55482. loadedParticleSystems: Array<IParticleSystem>;
  55483. /**
  55484. * Gets the list of loaded skeletons
  55485. */
  55486. loadedSkeletons: Array<Skeleton>;
  55487. /**
  55488. * Gets the list of loaded animation groups
  55489. */
  55490. loadedAnimationGroups: Array<AnimationGroup>;
  55491. /**
  55492. * Callback called when the task is successful
  55493. */
  55494. onSuccess: (task: MeshAssetTask) => void;
  55495. /**
  55496. * Callback called when the task is successful
  55497. */
  55498. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  55499. /**
  55500. * Creates a new MeshAssetTask
  55501. * @param name defines the name of the task
  55502. * @param meshesNames defines the list of mesh's names you want to load
  55503. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  55504. * @param sceneFilename defines the filename of the scene to load from
  55505. */
  55506. constructor(
  55507. /**
  55508. * Defines the name of the task
  55509. */
  55510. name: string,
  55511. /**
  55512. * Defines the list of mesh's names you want to load
  55513. */
  55514. meshesNames: any,
  55515. /**
  55516. * Defines the root url to use as a base to load your meshes and associated resources
  55517. */
  55518. rootUrl: string,
  55519. /**
  55520. * Defines the filename of the scene to load from
  55521. */
  55522. sceneFilename: string);
  55523. /**
  55524. * Execute the current task
  55525. * @param scene defines the scene where you want your assets to be loaded
  55526. * @param onSuccess is a callback called when the task is successfully executed
  55527. * @param onError is a callback called if an error occurs
  55528. */
  55529. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55530. }
  55531. /**
  55532. * Define a task used by AssetsManager to load text content
  55533. */
  55534. export class TextFileAssetTask extends AbstractAssetTask {
  55535. /**
  55536. * Defines the name of the task
  55537. */
  55538. name: string;
  55539. /**
  55540. * Defines the location of the file to load
  55541. */
  55542. url: string;
  55543. /**
  55544. * Gets the loaded text string
  55545. */
  55546. text: string;
  55547. /**
  55548. * Callback called when the task is successful
  55549. */
  55550. onSuccess: (task: TextFileAssetTask) => void;
  55551. /**
  55552. * Callback called when the task is successful
  55553. */
  55554. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  55555. /**
  55556. * Creates a new TextFileAssetTask object
  55557. * @param name defines the name of the task
  55558. * @param url defines the location of the file to load
  55559. */
  55560. constructor(
  55561. /**
  55562. * Defines the name of the task
  55563. */
  55564. name: string,
  55565. /**
  55566. * Defines the location of the file to load
  55567. */
  55568. url: string);
  55569. /**
  55570. * Execute the current task
  55571. * @param scene defines the scene where you want your assets to be loaded
  55572. * @param onSuccess is a callback called when the task is successfully executed
  55573. * @param onError is a callback called if an error occurs
  55574. */
  55575. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55576. }
  55577. /**
  55578. * Define a task used by AssetsManager to load binary data
  55579. */
  55580. export class BinaryFileAssetTask extends AbstractAssetTask {
  55581. /**
  55582. * Defines the name of the task
  55583. */
  55584. name: string;
  55585. /**
  55586. * Defines the location of the file to load
  55587. */
  55588. url: string;
  55589. /**
  55590. * Gets the lodaded data (as an array buffer)
  55591. */
  55592. data: ArrayBuffer;
  55593. /**
  55594. * Callback called when the task is successful
  55595. */
  55596. onSuccess: (task: BinaryFileAssetTask) => void;
  55597. /**
  55598. * Callback called when the task is successful
  55599. */
  55600. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  55601. /**
  55602. * Creates a new BinaryFileAssetTask object
  55603. * @param name defines the name of the new task
  55604. * @param url defines the location of the file to load
  55605. */
  55606. constructor(
  55607. /**
  55608. * Defines the name of the task
  55609. */
  55610. name: string,
  55611. /**
  55612. * Defines the location of the file to load
  55613. */
  55614. url: string);
  55615. /**
  55616. * Execute the current task
  55617. * @param scene defines the scene where you want your assets to be loaded
  55618. * @param onSuccess is a callback called when the task is successfully executed
  55619. * @param onError is a callback called if an error occurs
  55620. */
  55621. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55622. }
  55623. /**
  55624. * Define a task used by AssetsManager to load images
  55625. */
  55626. export class ImageAssetTask extends AbstractAssetTask {
  55627. /**
  55628. * Defines the name of the task
  55629. */
  55630. name: string;
  55631. /**
  55632. * Defines the location of the image to load
  55633. */
  55634. url: string;
  55635. /**
  55636. * Gets the loaded images
  55637. */
  55638. image: HTMLImageElement;
  55639. /**
  55640. * Callback called when the task is successful
  55641. */
  55642. onSuccess: (task: ImageAssetTask) => void;
  55643. /**
  55644. * Callback called when the task is successful
  55645. */
  55646. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  55647. /**
  55648. * Creates a new ImageAssetTask
  55649. * @param name defines the name of the task
  55650. * @param url defines the location of the image to load
  55651. */
  55652. constructor(
  55653. /**
  55654. * Defines the name of the task
  55655. */
  55656. name: string,
  55657. /**
  55658. * Defines the location of the image to load
  55659. */
  55660. url: string);
  55661. /**
  55662. * Execute the current task
  55663. * @param scene defines the scene where you want your assets to be loaded
  55664. * @param onSuccess is a callback called when the task is successfully executed
  55665. * @param onError is a callback called if an error occurs
  55666. */
  55667. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55668. }
  55669. /**
  55670. * Defines the interface used by texture loading tasks
  55671. */
  55672. export interface ITextureAssetTask<TEX extends BaseTexture> {
  55673. /**
  55674. * Gets the loaded texture
  55675. */
  55676. texture: TEX;
  55677. }
  55678. /**
  55679. * Define a task used by AssetsManager to load 2D textures
  55680. */
  55681. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  55682. /**
  55683. * Defines the name of the task
  55684. */
  55685. name: string;
  55686. /**
  55687. * Defines the location of the file to load
  55688. */
  55689. url: string;
  55690. /**
  55691. * Defines if mipmap should not be generated (default is false)
  55692. */
  55693. noMipmap?: boolean | undefined;
  55694. /**
  55695. * Defines if texture must be inverted on Y axis (default is false)
  55696. */
  55697. invertY?: boolean | undefined;
  55698. /**
  55699. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  55700. */
  55701. samplingMode: number;
  55702. /**
  55703. * Gets the loaded texture
  55704. */
  55705. texture: Texture;
  55706. /**
  55707. * Callback called when the task is successful
  55708. */
  55709. onSuccess: (task: TextureAssetTask) => void;
  55710. /**
  55711. * Callback called when the task is successful
  55712. */
  55713. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  55714. /**
  55715. * Creates a new TextureAssetTask object
  55716. * @param name defines the name of the task
  55717. * @param url defines the location of the file to load
  55718. * @param noMipmap defines if mipmap should not be generated (default is false)
  55719. * @param invertY defines if texture must be inverted on Y axis (default is false)
  55720. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  55721. */
  55722. constructor(
  55723. /**
  55724. * Defines the name of the task
  55725. */
  55726. name: string,
  55727. /**
  55728. * Defines the location of the file to load
  55729. */
  55730. url: string,
  55731. /**
  55732. * Defines if mipmap should not be generated (default is false)
  55733. */
  55734. noMipmap?: boolean | undefined,
  55735. /**
  55736. * Defines if texture must be inverted on Y axis (default is false)
  55737. */
  55738. invertY?: boolean | undefined,
  55739. /**
  55740. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  55741. */
  55742. samplingMode?: number);
  55743. /**
  55744. * Execute the current task
  55745. * @param scene defines the scene where you want your assets to be loaded
  55746. * @param onSuccess is a callback called when the task is successfully executed
  55747. * @param onError is a callback called if an error occurs
  55748. */
  55749. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55750. }
  55751. /**
  55752. * Define a task used by AssetsManager to load cube textures
  55753. */
  55754. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  55755. /**
  55756. * Defines the name of the task
  55757. */
  55758. name: string;
  55759. /**
  55760. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  55761. */
  55762. url: string;
  55763. /**
  55764. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  55765. */
  55766. extensions?: string[] | undefined;
  55767. /**
  55768. * Defines if mipmaps should not be generated (default is false)
  55769. */
  55770. noMipmap?: boolean | undefined;
  55771. /**
  55772. * Defines the explicit list of files (undefined by default)
  55773. */
  55774. files?: string[] | undefined;
  55775. /**
  55776. * Gets the loaded texture
  55777. */
  55778. texture: CubeTexture;
  55779. /**
  55780. * Callback called when the task is successful
  55781. */
  55782. onSuccess: (task: CubeTextureAssetTask) => void;
  55783. /**
  55784. * Callback called when the task is successful
  55785. */
  55786. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  55787. /**
  55788. * Creates a new CubeTextureAssetTask
  55789. * @param name defines the name of the task
  55790. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  55791. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  55792. * @param noMipmap defines if mipmaps should not be generated (default is false)
  55793. * @param files defines the explicit list of files (undefined by default)
  55794. */
  55795. constructor(
  55796. /**
  55797. * Defines the name of the task
  55798. */
  55799. name: string,
  55800. /**
  55801. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  55802. */
  55803. url: string,
  55804. /**
  55805. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  55806. */
  55807. extensions?: string[] | undefined,
  55808. /**
  55809. * Defines if mipmaps should not be generated (default is false)
  55810. */
  55811. noMipmap?: boolean | undefined,
  55812. /**
  55813. * Defines the explicit list of files (undefined by default)
  55814. */
  55815. files?: string[] | undefined);
  55816. /**
  55817. * Execute the current task
  55818. * @param scene defines the scene where you want your assets to be loaded
  55819. * @param onSuccess is a callback called when the task is successfully executed
  55820. * @param onError is a callback called if an error occurs
  55821. */
  55822. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55823. }
  55824. /**
  55825. * Define a task used by AssetsManager to load HDR cube textures
  55826. */
  55827. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  55828. /**
  55829. * Defines the name of the task
  55830. */
  55831. name: string;
  55832. /**
  55833. * Defines the location of the file to load
  55834. */
  55835. url: string;
  55836. /**
  55837. * Defines the desired size (the more it increases the longer the generation will be)
  55838. */
  55839. size: number;
  55840. /**
  55841. * Defines if mipmaps should not be generated (default is false)
  55842. */
  55843. noMipmap: boolean;
  55844. /**
  55845. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  55846. */
  55847. generateHarmonics: boolean;
  55848. /**
  55849. * 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)
  55850. */
  55851. gammaSpace: boolean;
  55852. /**
  55853. * Internal Use Only
  55854. */
  55855. reserved: boolean;
  55856. /**
  55857. * Gets the loaded texture
  55858. */
  55859. texture: HDRCubeTexture;
  55860. /**
  55861. * Callback called when the task is successful
  55862. */
  55863. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  55864. /**
  55865. * Callback called when the task is successful
  55866. */
  55867. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  55868. /**
  55869. * Creates a new HDRCubeTextureAssetTask object
  55870. * @param name defines the name of the task
  55871. * @param url defines the location of the file to load
  55872. * @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.
  55873. * @param noMipmap defines if mipmaps should not be generated (default is false)
  55874. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  55875. * @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)
  55876. * @param reserved Internal use only
  55877. */
  55878. constructor(
  55879. /**
  55880. * Defines the name of the task
  55881. */
  55882. name: string,
  55883. /**
  55884. * Defines the location of the file to load
  55885. */
  55886. url: string,
  55887. /**
  55888. * Defines the desired size (the more it increases the longer the generation will be)
  55889. */
  55890. size: number,
  55891. /**
  55892. * Defines if mipmaps should not be generated (default is false)
  55893. */
  55894. noMipmap?: boolean,
  55895. /**
  55896. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  55897. */
  55898. generateHarmonics?: boolean,
  55899. /**
  55900. * 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)
  55901. */
  55902. gammaSpace?: boolean,
  55903. /**
  55904. * Internal Use Only
  55905. */
  55906. reserved?: boolean);
  55907. /**
  55908. * Execute the current task
  55909. * @param scene defines the scene where you want your assets to be loaded
  55910. * @param onSuccess is a callback called when the task is successfully executed
  55911. * @param onError is a callback called if an error occurs
  55912. */
  55913. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55914. }
  55915. /**
  55916. * This class can be used to easily import assets into a scene
  55917. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  55918. */
  55919. export class AssetsManager {
  55920. private _scene;
  55921. private _isLoading;
  55922. protected _tasks: AbstractAssetTask[];
  55923. protected _waitingTasksCount: number;
  55924. protected _totalTasksCount: number;
  55925. /**
  55926. * Callback called when all tasks are processed
  55927. */
  55928. onFinish: (tasks: AbstractAssetTask[]) => void;
  55929. /**
  55930. * Callback called when a task is successful
  55931. */
  55932. onTaskSuccess: (task: AbstractAssetTask) => void;
  55933. /**
  55934. * Callback called when a task had an error
  55935. */
  55936. onTaskError: (task: AbstractAssetTask) => void;
  55937. /**
  55938. * Callback called when a task is done (whatever the result is)
  55939. */
  55940. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  55941. /**
  55942. * Observable called when all tasks are processed
  55943. */
  55944. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  55945. /**
  55946. * Observable called when a task had an error
  55947. */
  55948. onTaskErrorObservable: Observable<AbstractAssetTask>;
  55949. /**
  55950. * Observable called when a task is successful
  55951. */
  55952. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  55953. /**
  55954. * Observable called when a task is done (whatever the result is)
  55955. */
  55956. onProgressObservable: Observable<IAssetsProgressEvent>;
  55957. /**
  55958. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  55959. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  55960. */
  55961. useDefaultLoadingScreen: boolean;
  55962. /**
  55963. * Creates a new AssetsManager
  55964. * @param scene defines the scene to work on
  55965. */
  55966. constructor(scene: Scene);
  55967. /**
  55968. * Add a MeshAssetTask to the list of active tasks
  55969. * @param taskName defines the name of the new task
  55970. * @param meshesNames defines the name of meshes to load
  55971. * @param rootUrl defines the root url to use to locate files
  55972. * @param sceneFilename defines the filename of the scene file
  55973. * @returns a new MeshAssetTask object
  55974. */
  55975. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  55976. /**
  55977. * Add a TextFileAssetTask to the list of active tasks
  55978. * @param taskName defines the name of the new task
  55979. * @param url defines the url of the file to load
  55980. * @returns a new TextFileAssetTask object
  55981. */
  55982. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  55983. /**
  55984. * Add a BinaryFileAssetTask to the list of active tasks
  55985. * @param taskName defines the name of the new task
  55986. * @param url defines the url of the file to load
  55987. * @returns a new BinaryFileAssetTask object
  55988. */
  55989. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  55990. /**
  55991. * Add a ImageAssetTask to the list of active tasks
  55992. * @param taskName defines the name of the new task
  55993. * @param url defines the url of the file to load
  55994. * @returns a new ImageAssetTask object
  55995. */
  55996. addImageTask(taskName: string, url: string): ImageAssetTask;
  55997. /**
  55998. * Add a TextureAssetTask to the list of active tasks
  55999. * @param taskName defines the name of the new task
  56000. * @param url defines the url of the file to load
  56001. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  56002. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  56003. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  56004. * @returns a new TextureAssetTask object
  56005. */
  56006. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  56007. /**
  56008. * Add a CubeTextureAssetTask to the list of active tasks
  56009. * @param taskName defines the name of the new task
  56010. * @param url defines the url of the file to load
  56011. * @param extensions defines the extension to use to load the cube map (can be null)
  56012. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  56013. * @param files defines the list of files to load (can be null)
  56014. * @returns a new CubeTextureAssetTask object
  56015. */
  56016. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  56017. /**
  56018. *
  56019. * Add a HDRCubeTextureAssetTask to the list of active tasks
  56020. * @param taskName defines the name of the new task
  56021. * @param url defines the url of the file to load
  56022. * @param size defines the size you want for the cubemap (can be null)
  56023. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  56024. * @param generateHarmonics defines if you want to automatically generate (true by default)
  56025. * @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)
  56026. * @param reserved Internal use only
  56027. * @returns a new HDRCubeTextureAssetTask object
  56028. */
  56029. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  56030. /**
  56031. * Remove a task from the assets manager.
  56032. * @param task the task to remove
  56033. */
  56034. removeTask(task: AbstractAssetTask): void;
  56035. private _decreaseWaitingTasksCount;
  56036. private _runTask;
  56037. /**
  56038. * Reset the AssetsManager and remove all tasks
  56039. * @return the current instance of the AssetsManager
  56040. */
  56041. reset(): AssetsManager;
  56042. /**
  56043. * Start the loading process
  56044. * @return the current instance of the AssetsManager
  56045. */
  56046. load(): AssetsManager;
  56047. }
  56048. }
  56049. declare module "babylonjs/Misc/deferred" {
  56050. /**
  56051. * Wrapper class for promise with external resolve and reject.
  56052. */
  56053. export class Deferred<T> {
  56054. /**
  56055. * The promise associated with this deferred object.
  56056. */
  56057. readonly promise: Promise<T>;
  56058. private _resolve;
  56059. private _reject;
  56060. /**
  56061. * The resolve method of the promise associated with this deferred object.
  56062. */
  56063. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  56064. /**
  56065. * The reject method of the promise associated with this deferred object.
  56066. */
  56067. readonly reject: (reason?: any) => void;
  56068. /**
  56069. * Constructor for this deferred object.
  56070. */
  56071. constructor();
  56072. }
  56073. }
  56074. declare module "babylonjs/Misc/filesInput" {
  56075. import { Engine } from "babylonjs/Engines/engine";
  56076. import { Scene } from "babylonjs/scene";
  56077. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  56078. /**
  56079. * Class used to help managing file picking and drag'n'drop
  56080. */
  56081. export class FilesInput {
  56082. /**
  56083. * List of files ready to be loaded
  56084. */
  56085. static readonly FilesToLoad: {
  56086. [key: string]: File;
  56087. };
  56088. /**
  56089. * Callback called when a file is processed
  56090. */
  56091. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  56092. private _engine;
  56093. private _currentScene;
  56094. private _sceneLoadedCallback;
  56095. private _progressCallback;
  56096. private _additionalRenderLoopLogicCallback;
  56097. private _textureLoadingCallback;
  56098. private _startingProcessingFilesCallback;
  56099. private _onReloadCallback;
  56100. private _errorCallback;
  56101. private _elementToMonitor;
  56102. private _sceneFileToLoad;
  56103. private _filesToLoad;
  56104. /**
  56105. * Creates a new FilesInput
  56106. * @param engine defines the rendering engine
  56107. * @param scene defines the hosting scene
  56108. * @param sceneLoadedCallback callback called when scene is loaded
  56109. * @param progressCallback callback called to track progress
  56110. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  56111. * @param textureLoadingCallback callback called when a texture is loading
  56112. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  56113. * @param onReloadCallback callback called when a reload is requested
  56114. * @param errorCallback callback call if an error occurs
  56115. */
  56116. 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);
  56117. private _dragEnterHandler;
  56118. private _dragOverHandler;
  56119. private _dropHandler;
  56120. /**
  56121. * Calls this function to listen to drag'n'drop events on a specific DOM element
  56122. * @param elementToMonitor defines the DOM element to track
  56123. */
  56124. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  56125. /**
  56126. * Release all associated resources
  56127. */
  56128. dispose(): void;
  56129. private renderFunction;
  56130. private drag;
  56131. private drop;
  56132. private _traverseFolder;
  56133. private _processFiles;
  56134. /**
  56135. * Load files from a drop event
  56136. * @param event defines the drop event to use as source
  56137. */
  56138. loadFiles(event: any): void;
  56139. private _processReload;
  56140. /**
  56141. * Reload the current scene from the loaded files
  56142. */
  56143. reload(): void;
  56144. }
  56145. }
  56146. declare module "babylonjs/Misc/HighDynamicRange/index" {
  56147. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  56148. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  56149. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  56150. }
  56151. declare module "babylonjs/Misc/sceneOptimizer" {
  56152. import { Scene, IDisposable } from "babylonjs/scene";
  56153. import { Observable } from "babylonjs/Misc/observable";
  56154. /**
  56155. * Defines the root class used to create scene optimization to use with SceneOptimizer
  56156. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56157. */
  56158. export class SceneOptimization {
  56159. /**
  56160. * Defines the priority of this optimization (0 by default which means first in the list)
  56161. */
  56162. priority: number;
  56163. /**
  56164. * Gets a string describing the action executed by the current optimization
  56165. * @returns description string
  56166. */
  56167. getDescription(): string;
  56168. /**
  56169. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56170. * @param scene defines the current scene where to apply this optimization
  56171. * @param optimizer defines the current optimizer
  56172. * @returns true if everything that can be done was applied
  56173. */
  56174. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56175. /**
  56176. * Creates the SceneOptimization object
  56177. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  56178. * @param desc defines the description associated with the optimization
  56179. */
  56180. constructor(
  56181. /**
  56182. * Defines the priority of this optimization (0 by default which means first in the list)
  56183. */
  56184. priority?: number);
  56185. }
  56186. /**
  56187. * Defines an optimization used to reduce the size of render target textures
  56188. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56189. */
  56190. export class TextureOptimization extends SceneOptimization {
  56191. /**
  56192. * Defines the priority of this optimization (0 by default which means first in the list)
  56193. */
  56194. priority: number;
  56195. /**
  56196. * 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
  56197. */
  56198. maximumSize: number;
  56199. /**
  56200. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  56201. */
  56202. step: number;
  56203. /**
  56204. * Gets a string describing the action executed by the current optimization
  56205. * @returns description string
  56206. */
  56207. getDescription(): string;
  56208. /**
  56209. * Creates the TextureOptimization object
  56210. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  56211. * @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
  56212. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  56213. */
  56214. constructor(
  56215. /**
  56216. * Defines the priority of this optimization (0 by default which means first in the list)
  56217. */
  56218. priority?: number,
  56219. /**
  56220. * 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
  56221. */
  56222. maximumSize?: number,
  56223. /**
  56224. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  56225. */
  56226. step?: number);
  56227. /**
  56228. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56229. * @param scene defines the current scene where to apply this optimization
  56230. * @param optimizer defines the current optimizer
  56231. * @returns true if everything that can be done was applied
  56232. */
  56233. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56234. }
  56235. /**
  56236. * Defines an optimization used to increase or decrease the rendering resolution
  56237. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56238. */
  56239. export class HardwareScalingOptimization extends SceneOptimization {
  56240. /**
  56241. * Defines the priority of this optimization (0 by default which means first in the list)
  56242. */
  56243. priority: number;
  56244. /**
  56245. * Defines the maximum scale to use (2 by default)
  56246. */
  56247. maximumScale: number;
  56248. /**
  56249. * Defines the step to use between two passes (0.5 by default)
  56250. */
  56251. step: number;
  56252. private _currentScale;
  56253. private _directionOffset;
  56254. /**
  56255. * Gets a string describing the action executed by the current optimization
  56256. * @return description string
  56257. */
  56258. getDescription(): string;
  56259. /**
  56260. * Creates the HardwareScalingOptimization object
  56261. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  56262. * @param maximumScale defines the maximum scale to use (2 by default)
  56263. * @param step defines the step to use between two passes (0.5 by default)
  56264. */
  56265. constructor(
  56266. /**
  56267. * Defines the priority of this optimization (0 by default which means first in the list)
  56268. */
  56269. priority?: number,
  56270. /**
  56271. * Defines the maximum scale to use (2 by default)
  56272. */
  56273. maximumScale?: number,
  56274. /**
  56275. * Defines the step to use between two passes (0.5 by default)
  56276. */
  56277. step?: number);
  56278. /**
  56279. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56280. * @param scene defines the current scene where to apply this optimization
  56281. * @param optimizer defines the current optimizer
  56282. * @returns true if everything that can be done was applied
  56283. */
  56284. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56285. }
  56286. /**
  56287. * Defines an optimization used to remove shadows
  56288. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56289. */
  56290. export class ShadowsOptimization extends SceneOptimization {
  56291. /**
  56292. * Gets a string describing the action executed by the current optimization
  56293. * @return description string
  56294. */
  56295. getDescription(): string;
  56296. /**
  56297. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56298. * @param scene defines the current scene where to apply this optimization
  56299. * @param optimizer defines the current optimizer
  56300. * @returns true if everything that can be done was applied
  56301. */
  56302. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56303. }
  56304. /**
  56305. * Defines an optimization used to turn post-processes off
  56306. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56307. */
  56308. export class PostProcessesOptimization extends SceneOptimization {
  56309. /**
  56310. * Gets a string describing the action executed by the current optimization
  56311. * @return description string
  56312. */
  56313. getDescription(): string;
  56314. /**
  56315. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56316. * @param scene defines the current scene where to apply this optimization
  56317. * @param optimizer defines the current optimizer
  56318. * @returns true if everything that can be done was applied
  56319. */
  56320. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56321. }
  56322. /**
  56323. * Defines an optimization used to turn lens flares off
  56324. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56325. */
  56326. export class LensFlaresOptimization extends SceneOptimization {
  56327. /**
  56328. * Gets a string describing the action executed by the current optimization
  56329. * @return description string
  56330. */
  56331. getDescription(): string;
  56332. /**
  56333. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56334. * @param scene defines the current scene where to apply this optimization
  56335. * @param optimizer defines the current optimizer
  56336. * @returns true if everything that can be done was applied
  56337. */
  56338. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56339. }
  56340. /**
  56341. * Defines an optimization based on user defined callback.
  56342. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56343. */
  56344. export class CustomOptimization extends SceneOptimization {
  56345. /**
  56346. * Callback called to apply the custom optimization.
  56347. */
  56348. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  56349. /**
  56350. * Callback called to get custom description
  56351. */
  56352. onGetDescription: () => string;
  56353. /**
  56354. * Gets a string describing the action executed by the current optimization
  56355. * @returns description string
  56356. */
  56357. getDescription(): string;
  56358. /**
  56359. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56360. * @param scene defines the current scene where to apply this optimization
  56361. * @param optimizer defines the current optimizer
  56362. * @returns true if everything that can be done was applied
  56363. */
  56364. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56365. }
  56366. /**
  56367. * Defines an optimization used to turn particles off
  56368. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56369. */
  56370. export class ParticlesOptimization extends SceneOptimization {
  56371. /**
  56372. * Gets a string describing the action executed by the current optimization
  56373. * @return description string
  56374. */
  56375. getDescription(): string;
  56376. /**
  56377. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56378. * @param scene defines the current scene where to apply this optimization
  56379. * @param optimizer defines the current optimizer
  56380. * @returns true if everything that can be done was applied
  56381. */
  56382. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56383. }
  56384. /**
  56385. * Defines an optimization used to turn render targets off
  56386. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56387. */
  56388. export class RenderTargetsOptimization extends SceneOptimization {
  56389. /**
  56390. * Gets a string describing the action executed by the current optimization
  56391. * @return description string
  56392. */
  56393. getDescription(): string;
  56394. /**
  56395. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56396. * @param scene defines the current scene where to apply this optimization
  56397. * @param optimizer defines the current optimizer
  56398. * @returns true if everything that can be done was applied
  56399. */
  56400. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56401. }
  56402. /**
  56403. * Defines an optimization used to merge meshes with compatible materials
  56404. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56405. */
  56406. export class MergeMeshesOptimization extends SceneOptimization {
  56407. private static _UpdateSelectionTree;
  56408. /**
  56409. * Gets or sets a boolean which defines if optimization octree has to be updated
  56410. */
  56411. /**
  56412. * Gets or sets a boolean which defines if optimization octree has to be updated
  56413. */
  56414. static UpdateSelectionTree: boolean;
  56415. /**
  56416. * Gets a string describing the action executed by the current optimization
  56417. * @return description string
  56418. */
  56419. getDescription(): string;
  56420. private _canBeMerged;
  56421. /**
  56422. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56423. * @param scene defines the current scene where to apply this optimization
  56424. * @param optimizer defines the current optimizer
  56425. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  56426. * @returns true if everything that can be done was applied
  56427. */
  56428. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  56429. }
  56430. /**
  56431. * Defines a list of options used by SceneOptimizer
  56432. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56433. */
  56434. export class SceneOptimizerOptions {
  56435. /**
  56436. * Defines the target frame rate to reach (60 by default)
  56437. */
  56438. targetFrameRate: number;
  56439. /**
  56440. * Defines the interval between two checkes (2000ms by default)
  56441. */
  56442. trackerDuration: number;
  56443. /**
  56444. * Gets the list of optimizations to apply
  56445. */
  56446. optimizations: SceneOptimization[];
  56447. /**
  56448. * Creates a new list of options used by SceneOptimizer
  56449. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  56450. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  56451. */
  56452. constructor(
  56453. /**
  56454. * Defines the target frame rate to reach (60 by default)
  56455. */
  56456. targetFrameRate?: number,
  56457. /**
  56458. * Defines the interval between two checkes (2000ms by default)
  56459. */
  56460. trackerDuration?: number);
  56461. /**
  56462. * Add a new optimization
  56463. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  56464. * @returns the current SceneOptimizerOptions
  56465. */
  56466. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  56467. /**
  56468. * Add a new custom optimization
  56469. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  56470. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  56471. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  56472. * @returns the current SceneOptimizerOptions
  56473. */
  56474. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  56475. /**
  56476. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  56477. * @param targetFrameRate defines the target frame rate (60 by default)
  56478. * @returns a SceneOptimizerOptions object
  56479. */
  56480. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  56481. /**
  56482. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  56483. * @param targetFrameRate defines the target frame rate (60 by default)
  56484. * @returns a SceneOptimizerOptions object
  56485. */
  56486. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  56487. /**
  56488. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  56489. * @param targetFrameRate defines the target frame rate (60 by default)
  56490. * @returns a SceneOptimizerOptions object
  56491. */
  56492. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  56493. }
  56494. /**
  56495. * Class used to run optimizations in order to reach a target frame rate
  56496. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56497. */
  56498. export class SceneOptimizer implements IDisposable {
  56499. private _isRunning;
  56500. private _options;
  56501. private _scene;
  56502. private _currentPriorityLevel;
  56503. private _targetFrameRate;
  56504. private _trackerDuration;
  56505. private _currentFrameRate;
  56506. private _sceneDisposeObserver;
  56507. private _improvementMode;
  56508. /**
  56509. * Defines an observable called when the optimizer reaches the target frame rate
  56510. */
  56511. onSuccessObservable: Observable<SceneOptimizer>;
  56512. /**
  56513. * Defines an observable called when the optimizer enables an optimization
  56514. */
  56515. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  56516. /**
  56517. * Defines an observable called when the optimizer is not able to reach the target frame rate
  56518. */
  56519. onFailureObservable: Observable<SceneOptimizer>;
  56520. /**
  56521. * Gets a boolean indicating if the optimizer is in improvement mode
  56522. */
  56523. readonly isInImprovementMode: boolean;
  56524. /**
  56525. * Gets the current priority level (0 at start)
  56526. */
  56527. readonly currentPriorityLevel: number;
  56528. /**
  56529. * Gets the current frame rate checked by the SceneOptimizer
  56530. */
  56531. readonly currentFrameRate: number;
  56532. /**
  56533. * Gets or sets the current target frame rate (60 by default)
  56534. */
  56535. /**
  56536. * Gets or sets the current target frame rate (60 by default)
  56537. */
  56538. targetFrameRate: number;
  56539. /**
  56540. * Gets or sets the current interval between two checks (every 2000ms by default)
  56541. */
  56542. /**
  56543. * Gets or sets the current interval between two checks (every 2000ms by default)
  56544. */
  56545. trackerDuration: number;
  56546. /**
  56547. * Gets the list of active optimizations
  56548. */
  56549. readonly optimizations: SceneOptimization[];
  56550. /**
  56551. * Creates a new SceneOptimizer
  56552. * @param scene defines the scene to work on
  56553. * @param options defines the options to use with the SceneOptimizer
  56554. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  56555. * @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)
  56556. */
  56557. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  56558. /**
  56559. * Stops the current optimizer
  56560. */
  56561. stop(): void;
  56562. /**
  56563. * Reset the optimizer to initial step (current priority level = 0)
  56564. */
  56565. reset(): void;
  56566. /**
  56567. * Start the optimizer. By default it will try to reach a specific framerate
  56568. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  56569. */
  56570. start(): void;
  56571. private _checkCurrentState;
  56572. /**
  56573. * Release all resources
  56574. */
  56575. dispose(): void;
  56576. /**
  56577. * Helper function to create a SceneOptimizer with one single line of code
  56578. * @param scene defines the scene to work on
  56579. * @param options defines the options to use with the SceneOptimizer
  56580. * @param onSuccess defines a callback to call on success
  56581. * @param onFailure defines a callback to call on failure
  56582. * @returns the new SceneOptimizer object
  56583. */
  56584. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  56585. }
  56586. }
  56587. declare module "babylonjs/Misc/sceneSerializer" {
  56588. import { Scene } from "babylonjs/scene";
  56589. /**
  56590. * Class used to serialize a scene into a string
  56591. */
  56592. export class SceneSerializer {
  56593. /**
  56594. * Clear cache used by a previous serialization
  56595. */
  56596. static ClearCache(): void;
  56597. /**
  56598. * Serialize a scene into a JSON compatible object
  56599. * @param scene defines the scene to serialize
  56600. * @returns a JSON compatible object
  56601. */
  56602. static Serialize(scene: Scene): any;
  56603. /**
  56604. * Serialize a mesh into a JSON compatible object
  56605. * @param toSerialize defines the mesh to serialize
  56606. * @param withParents defines if parents must be serialized as well
  56607. * @param withChildren defines if children must be serialized as well
  56608. * @returns a JSON compatible object
  56609. */
  56610. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  56611. }
  56612. }
  56613. declare module "babylonjs/Misc/videoRecorder" {
  56614. import { Nullable } from "babylonjs/types";
  56615. import { Engine } from "babylonjs/Engines/engine";
  56616. /**
  56617. * This represents the different options avilable for the video capture.
  56618. */
  56619. export interface VideoRecorderOptions {
  56620. /** Defines the mime type of the video */
  56621. mimeType: string;
  56622. /** Defines the video the video should be recorded at */
  56623. fps: number;
  56624. /** Defines the chunk size for the recording data */
  56625. recordChunckSize: number;
  56626. /** The audio tracks to attach to the record */
  56627. audioTracks?: MediaStreamTrack[];
  56628. }
  56629. /**
  56630. * This can helps recording videos from BabylonJS.
  56631. * This is based on the available WebRTC functionalities of the browser.
  56632. *
  56633. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  56634. */
  56635. export class VideoRecorder {
  56636. private static readonly _defaultOptions;
  56637. /**
  56638. * Returns wehther or not the VideoRecorder is available in your browser.
  56639. * @param engine Defines the Babylon Engine to check the support for
  56640. * @returns true if supported otherwise false
  56641. */
  56642. static IsSupported(engine: Engine): boolean;
  56643. private readonly _options;
  56644. private _canvas;
  56645. private _mediaRecorder;
  56646. private _recordedChunks;
  56647. private _fileName;
  56648. private _resolve;
  56649. private _reject;
  56650. /**
  56651. * True wether a recording is already in progress.
  56652. */
  56653. readonly isRecording: boolean;
  56654. /**
  56655. * Create a new VideoCapture object which can help converting what you see in Babylon to
  56656. * a video file.
  56657. * @param engine Defines the BabylonJS Engine you wish to record
  56658. * @param options Defines options that can be used to customized the capture
  56659. */
  56660. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  56661. /**
  56662. * Stops the current recording before the default capture timeout passed in the startRecording
  56663. * functions.
  56664. */
  56665. stopRecording(): void;
  56666. /**
  56667. * Starts recording the canvas for a max duration specified in parameters.
  56668. * @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.
  56669. * @param maxDuration Defines the maximum recording time in seconds.
  56670. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  56671. * @return a promise callback at the end of the recording with the video data in Blob.
  56672. */
  56673. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  56674. /**
  56675. * Releases internal resources used during the recording.
  56676. */
  56677. dispose(): void;
  56678. private _handleDataAvailable;
  56679. private _handleError;
  56680. private _handleStop;
  56681. }
  56682. }
  56683. declare module "babylonjs/Misc/workerPool" {
  56684. import { IDisposable } from "babylonjs/scene";
  56685. /**
  56686. * Helper class to push actions to a pool of workers.
  56687. */
  56688. export class WorkerPool implements IDisposable {
  56689. private _workerInfos;
  56690. private _pendingActions;
  56691. /**
  56692. * Constructor
  56693. * @param workers Array of workers to use for actions
  56694. */
  56695. constructor(workers: Array<Worker>);
  56696. /**
  56697. * Terminates all workers and clears any pending actions.
  56698. */
  56699. dispose(): void;
  56700. /**
  56701. * Pushes an action to the worker pool. If all the workers are active, the action will be
  56702. * pended until a worker has completed its action.
  56703. * @param action The action to perform. Call onComplete when the action is complete.
  56704. */
  56705. push(action: (worker: Worker, onComplete: () => void) => void): void;
  56706. private _execute;
  56707. }
  56708. }
  56709. declare module "babylonjs/Misc/screenshotTools" {
  56710. import { Camera } from "babylonjs/Cameras/camera";
  56711. import { Engine } from "babylonjs/Engines/engine";
  56712. /**
  56713. * Class containing a set of static utilities functions for screenshots
  56714. */
  56715. export class ScreenshotTools {
  56716. /**
  56717. * Captures a screenshot of the current rendering
  56718. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  56719. * @param engine defines the rendering engine
  56720. * @param camera defines the source camera
  56721. * @param size This parameter can be set to a single number or to an object with the
  56722. * following (optional) properties: precision, width, height. If a single number is passed,
  56723. * it will be used for both width and height. If an object is passed, the screenshot size
  56724. * will be derived from the parameters. The precision property is a multiplier allowing
  56725. * rendering at a higher or lower resolution
  56726. * @param successCallback defines the callback receives a single parameter which contains the
  56727. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  56728. * src parameter of an <img> to display it
  56729. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  56730. * Check your browser for supported MIME types
  56731. */
  56732. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  56733. /**
  56734. * Generates an image screenshot from the specified camera.
  56735. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  56736. * @param engine The engine to use for rendering
  56737. * @param camera The camera to use for rendering
  56738. * @param size This parameter can be set to a single number or to an object with the
  56739. * following (optional) properties: precision, width, height. If a single number is passed,
  56740. * it will be used for both width and height. If an object is passed, the screenshot size
  56741. * will be derived from the parameters. The precision property is a multiplier allowing
  56742. * rendering at a higher or lower resolution
  56743. * @param successCallback The callback receives a single parameter which contains the
  56744. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  56745. * src parameter of an <img> to display it
  56746. * @param mimeType The MIME type of the screenshot image (default: image/png).
  56747. * Check your browser for supported MIME types
  56748. * @param samples Texture samples (default: 1)
  56749. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  56750. * @param fileName A name for for the downloaded file.
  56751. */
  56752. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  56753. }
  56754. }
  56755. declare module "babylonjs/Misc/index" {
  56756. export * from "babylonjs/Misc/andOrNotEvaluator";
  56757. export * from "babylonjs/Misc/assetsManager";
  56758. export * from "babylonjs/Misc/dds";
  56759. export * from "babylonjs/Misc/decorators";
  56760. export * from "babylonjs/Misc/deferred";
  56761. export * from "babylonjs/Misc/environmentTextureTools";
  56762. export * from "babylonjs/Misc/filesInput";
  56763. export * from "babylonjs/Misc/HighDynamicRange/index";
  56764. export * from "babylonjs/Misc/khronosTextureContainer";
  56765. export * from "babylonjs/Misc/observable";
  56766. export * from "babylonjs/Misc/performanceMonitor";
  56767. export * from "babylonjs/Misc/promise";
  56768. export * from "babylonjs/Misc/sceneOptimizer";
  56769. export * from "babylonjs/Misc/sceneSerializer";
  56770. export * from "babylonjs/Misc/smartArray";
  56771. export * from "babylonjs/Misc/stringDictionary";
  56772. export * from "babylonjs/Misc/tags";
  56773. export * from "babylonjs/Misc/textureTools";
  56774. export * from "babylonjs/Misc/tga";
  56775. export * from "babylonjs/Misc/tools";
  56776. export * from "babylonjs/Misc/videoRecorder";
  56777. export * from "babylonjs/Misc/virtualJoystick";
  56778. export * from "babylonjs/Misc/workerPool";
  56779. export * from "babylonjs/Misc/logger";
  56780. export * from "babylonjs/Misc/typeStore";
  56781. export * from "babylonjs/Misc/filesInputStore";
  56782. export * from "babylonjs/Misc/deepCopier";
  56783. export * from "babylonjs/Misc/pivotTools";
  56784. export * from "babylonjs/Misc/precisionDate";
  56785. export * from "babylonjs/Misc/screenshotTools";
  56786. export * from "babylonjs/Misc/typeStore";
  56787. }
  56788. declare module "babylonjs/index" {
  56789. export * from "babylonjs/abstractScene";
  56790. export * from "babylonjs/Actions/index";
  56791. export * from "babylonjs/Animations/index";
  56792. export * from "babylonjs/assetContainer";
  56793. export * from "babylonjs/Audio/index";
  56794. export * from "babylonjs/Behaviors/index";
  56795. export * from "babylonjs/Bones/index";
  56796. export * from "babylonjs/Cameras/index";
  56797. export * from "babylonjs/Collisions/index";
  56798. export * from "babylonjs/Culling/index";
  56799. export * from "babylonjs/Debug/index";
  56800. export * from "babylonjs/Engines/index";
  56801. export * from "babylonjs/Events/index";
  56802. export * from "babylonjs/Gamepads/index";
  56803. export * from "babylonjs/Gizmos/index";
  56804. export * from "babylonjs/Helpers/index";
  56805. export * from "babylonjs/Instrumentation/index";
  56806. export * from "babylonjs/Layers/index";
  56807. export * from "babylonjs/LensFlares/index";
  56808. export * from "babylonjs/Lights/index";
  56809. export * from "babylonjs/Loading/index";
  56810. export * from "babylonjs/Materials/index";
  56811. export * from "babylonjs/Maths/index";
  56812. export * from "babylonjs/Meshes/index";
  56813. export * from "babylonjs/Morph/index";
  56814. export * from "babylonjs/node";
  56815. export * from "babylonjs/Offline/index";
  56816. export * from "babylonjs/Particles/index";
  56817. export * from "babylonjs/Physics/index";
  56818. export * from "babylonjs/PostProcesses/index";
  56819. export * from "babylonjs/Probes/index";
  56820. export * from "babylonjs/Rendering/index";
  56821. export * from "babylonjs/scene";
  56822. export * from "babylonjs/sceneComponent";
  56823. export * from "babylonjs/Sprites/index";
  56824. export * from "babylonjs/States/index";
  56825. export * from "babylonjs/Misc/index";
  56826. export * from "babylonjs/types";
  56827. }
  56828. declare module "babylonjs/Animations/pathCursor" {
  56829. import { Path2, Vector3 } from "babylonjs/Maths/math";
  56830. /**
  56831. * A cursor which tracks a point on a path
  56832. */
  56833. export class PathCursor {
  56834. private path;
  56835. /**
  56836. * Stores path cursor callbacks for when an onchange event is triggered
  56837. */
  56838. private _onchange;
  56839. /**
  56840. * The value of the path cursor
  56841. */
  56842. value: number;
  56843. /**
  56844. * The animation array of the path cursor
  56845. */
  56846. animations: Animation[];
  56847. /**
  56848. * Initializes the path cursor
  56849. * @param path The path to track
  56850. */
  56851. constructor(path: Path2);
  56852. /**
  56853. * Gets the cursor point on the path
  56854. * @returns A point on the path cursor at the cursor location
  56855. */
  56856. getPoint(): Vector3;
  56857. /**
  56858. * Moves the cursor ahead by the step amount
  56859. * @param step The amount to move the cursor forward
  56860. * @returns This path cursor
  56861. */
  56862. moveAhead(step?: number): PathCursor;
  56863. /**
  56864. * Moves the cursor behind by the step amount
  56865. * @param step The amount to move the cursor back
  56866. * @returns This path cursor
  56867. */
  56868. moveBack(step?: number): PathCursor;
  56869. /**
  56870. * Moves the cursor by the step amount
  56871. * If the step amount is greater than one, an exception is thrown
  56872. * @param step The amount to move the cursor
  56873. * @returns This path cursor
  56874. */
  56875. move(step: number): PathCursor;
  56876. /**
  56877. * Ensures that the value is limited between zero and one
  56878. * @returns This path cursor
  56879. */
  56880. private ensureLimits;
  56881. /**
  56882. * Runs onchange callbacks on change (used by the animation engine)
  56883. * @returns This path cursor
  56884. */
  56885. private raiseOnChange;
  56886. /**
  56887. * Executes a function on change
  56888. * @param f A path cursor onchange callback
  56889. * @returns This path cursor
  56890. */
  56891. onchange(f: (cursor: PathCursor) => void): PathCursor;
  56892. }
  56893. }
  56894. declare module "babylonjs/Legacy/legacy" {
  56895. import * as Babylon from "babylonjs/index";
  56896. export * from "babylonjs/index";
  56897. }
  56898. declare module "babylonjs/Shaders/blur.fragment" {
  56899. /** @hidden */
  56900. export var blurPixelShader: {
  56901. name: string;
  56902. shader: string;
  56903. };
  56904. }
  56905. declare module "babylonjs/Shaders/ShadersInclude/bones300Declaration" {
  56906. /** @hidden */
  56907. export var bones300Declaration: {
  56908. name: string;
  56909. shader: string;
  56910. };
  56911. }
  56912. declare module "babylonjs/Shaders/ShadersInclude/instances300Declaration" {
  56913. /** @hidden */
  56914. export var instances300Declaration: {
  56915. name: string;
  56916. shader: string;
  56917. };
  56918. }
  56919. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  56920. /** @hidden */
  56921. export var pointCloudVertexDeclaration: {
  56922. name: string;
  56923. shader: string;
  56924. };
  56925. }
  56926. // Mixins
  56927. interface Window {
  56928. mozIndexedDB: IDBFactory;
  56929. webkitIndexedDB: IDBFactory;
  56930. msIndexedDB: IDBFactory;
  56931. webkitURL: typeof URL;
  56932. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  56933. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  56934. WebGLRenderingContext: WebGLRenderingContext;
  56935. MSGesture: MSGesture;
  56936. CANNON: any;
  56937. AudioContext: AudioContext;
  56938. webkitAudioContext: AudioContext;
  56939. PointerEvent: any;
  56940. Math: Math;
  56941. Uint8Array: Uint8ArrayConstructor;
  56942. Float32Array: Float32ArrayConstructor;
  56943. mozURL: typeof URL;
  56944. msURL: typeof URL;
  56945. VRFrameData: any; // WebVR, from specs 1.1
  56946. DracoDecoderModule: any;
  56947. setImmediate(handler: (...args: any[]) => void): number;
  56948. }
  56949. interface Document {
  56950. mozCancelFullScreen(): void;
  56951. msCancelFullScreen(): void;
  56952. webkitCancelFullScreen(): void;
  56953. requestPointerLock(): void;
  56954. exitPointerLock(): void;
  56955. mozFullScreen: boolean;
  56956. msIsFullScreen: boolean;
  56957. readonly webkitIsFullScreen: boolean;
  56958. readonly pointerLockElement: Element;
  56959. mozPointerLockElement: HTMLElement;
  56960. msPointerLockElement: HTMLElement;
  56961. webkitPointerLockElement: HTMLElement;
  56962. }
  56963. interface HTMLCanvasElement {
  56964. requestPointerLock(): void;
  56965. msRequestPointerLock?(): void;
  56966. mozRequestPointerLock?(): void;
  56967. webkitRequestPointerLock?(): void;
  56968. /** Track wether a record is in progress */
  56969. isRecording: boolean;
  56970. /** Capture Stream method defined by some browsers */
  56971. captureStream(fps?: number): MediaStream;
  56972. }
  56973. interface CanvasRenderingContext2D {
  56974. msImageSmoothingEnabled: boolean;
  56975. }
  56976. interface MouseEvent {
  56977. mozMovementX: number;
  56978. mozMovementY: number;
  56979. webkitMovementX: number;
  56980. webkitMovementY: number;
  56981. msMovementX: number;
  56982. msMovementY: number;
  56983. }
  56984. interface Navigator {
  56985. mozGetVRDevices: (any: any) => any;
  56986. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  56987. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  56988. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  56989. webkitGetGamepads(): Gamepad[];
  56990. msGetGamepads(): Gamepad[];
  56991. webkitGamepads(): Gamepad[];
  56992. }
  56993. interface HTMLVideoElement {
  56994. mozSrcObject: any;
  56995. }
  56996. interface Math {
  56997. fround(x: number): number;
  56998. imul(a: number, b: number): number;
  56999. }
  57000. interface WebGLProgram {
  57001. context?: WebGLRenderingContext;
  57002. vertexShader?: WebGLShader;
  57003. fragmentShader?: WebGLShader;
  57004. isParallelCompiled: boolean;
  57005. onCompiled?: () => void;
  57006. }
  57007. interface WebGLRenderingContext {
  57008. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  57009. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  57010. vertexAttribDivisor(index: number, divisor: number): void;
  57011. createVertexArray(): any;
  57012. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  57013. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  57014. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  57015. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  57016. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  57017. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  57018. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  57019. // Queries
  57020. createQuery(): WebGLQuery;
  57021. deleteQuery(query: WebGLQuery): void;
  57022. beginQuery(target: number, query: WebGLQuery): void;
  57023. endQuery(target: number): void;
  57024. getQueryParameter(query: WebGLQuery, pname: number): any;
  57025. getQuery(target: number, pname: number): any;
  57026. MAX_SAMPLES: number;
  57027. RGBA8: number;
  57028. READ_FRAMEBUFFER: number;
  57029. DRAW_FRAMEBUFFER: number;
  57030. UNIFORM_BUFFER: number;
  57031. HALF_FLOAT_OES: number;
  57032. RGBA16F: number;
  57033. RGBA32F: number;
  57034. R32F: number;
  57035. RG32F: number;
  57036. RGB32F: number;
  57037. R16F: number;
  57038. RG16F: number;
  57039. RGB16F: number;
  57040. RED: number;
  57041. RG: number;
  57042. R8: number;
  57043. RG8: number;
  57044. UNSIGNED_INT_24_8: number;
  57045. DEPTH24_STENCIL8: number;
  57046. /* Multiple Render Targets */
  57047. drawBuffers(buffers: number[]): void;
  57048. readBuffer(src: number): void;
  57049. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  57050. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  57051. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  57052. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  57053. // Occlusion Query
  57054. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  57055. ANY_SAMPLES_PASSED: number;
  57056. QUERY_RESULT_AVAILABLE: number;
  57057. QUERY_RESULT: number;
  57058. }
  57059. interface WebGLBuffer {
  57060. references: number;
  57061. capacity: number;
  57062. is32Bits: boolean;
  57063. }
  57064. interface WebGLProgram {
  57065. transformFeedback?: WebGLTransformFeedback | null;
  57066. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  57067. }
  57068. interface EXT_disjoint_timer_query {
  57069. QUERY_COUNTER_BITS_EXT: number;
  57070. TIME_ELAPSED_EXT: number;
  57071. TIMESTAMP_EXT: number;
  57072. GPU_DISJOINT_EXT: number;
  57073. QUERY_RESULT_EXT: number;
  57074. QUERY_RESULT_AVAILABLE_EXT: number;
  57075. queryCounterEXT(query: WebGLQuery, target: number): void;
  57076. createQueryEXT(): WebGLQuery;
  57077. beginQueryEXT(target: number, query: WebGLQuery): void;
  57078. endQueryEXT(target: number): void;
  57079. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  57080. deleteQueryEXT(query: WebGLQuery): void;
  57081. }
  57082. interface WebGLUniformLocation {
  57083. _currentState: any;
  57084. }
  57085. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  57086. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  57087. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  57088. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  57089. interface WebGLRenderingContext {
  57090. readonly RASTERIZER_DISCARD: number;
  57091. readonly DEPTH_COMPONENT24: number;
  57092. readonly TEXTURE_3D: number;
  57093. readonly TEXTURE_2D_ARRAY: number;
  57094. readonly TEXTURE_COMPARE_FUNC: number;
  57095. readonly TEXTURE_COMPARE_MODE: number;
  57096. readonly COMPARE_REF_TO_TEXTURE: number;
  57097. readonly TEXTURE_WRAP_R: number;
  57098. readonly HALF_FLOAT: number;
  57099. readonly RGB8: number;
  57100. readonly RED_INTEGER: number;
  57101. readonly RG_INTEGER: number;
  57102. readonly RGB_INTEGER: number;
  57103. readonly RGBA_INTEGER: number;
  57104. readonly R8_SNORM: number;
  57105. readonly RG8_SNORM: number;
  57106. readonly RGB8_SNORM: number;
  57107. readonly RGBA8_SNORM: number;
  57108. readonly R8I: number;
  57109. readonly RG8I: number;
  57110. readonly RGB8I: number;
  57111. readonly RGBA8I: number;
  57112. readonly R8UI: number;
  57113. readonly RG8UI: number;
  57114. readonly RGB8UI: number;
  57115. readonly RGBA8UI: number;
  57116. readonly R16I: number;
  57117. readonly RG16I: number;
  57118. readonly RGB16I: number;
  57119. readonly RGBA16I: number;
  57120. readonly R16UI: number;
  57121. readonly RG16UI: number;
  57122. readonly RGB16UI: number;
  57123. readonly RGBA16UI: number;
  57124. readonly R32I: number;
  57125. readonly RG32I: number;
  57126. readonly RGB32I: number;
  57127. readonly RGBA32I: number;
  57128. readonly R32UI: number;
  57129. readonly RG32UI: number;
  57130. readonly RGB32UI: number;
  57131. readonly RGBA32UI: number;
  57132. readonly RGB10_A2UI: number;
  57133. readonly R11F_G11F_B10F: number;
  57134. readonly RGB9_E5: number;
  57135. readonly RGB10_A2: number;
  57136. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  57137. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  57138. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  57139. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  57140. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  57141. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  57142. 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;
  57143. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  57144. readonly TRANSFORM_FEEDBACK: number;
  57145. readonly INTERLEAVED_ATTRIBS: number;
  57146. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  57147. createTransformFeedback(): WebGLTransformFeedback;
  57148. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  57149. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  57150. beginTransformFeedback(primitiveMode: number): void;
  57151. endTransformFeedback(): void;
  57152. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  57153. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  57154. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  57155. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  57156. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  57157. }
  57158. interface ImageBitmap {
  57159. readonly width: number;
  57160. readonly height: number;
  57161. close(): void;
  57162. }
  57163. interface WebGLQuery extends WebGLObject {
  57164. }
  57165. declare var WebGLQuery: {
  57166. prototype: WebGLQuery;
  57167. new(): WebGLQuery;
  57168. };
  57169. interface WebGLSampler extends WebGLObject {
  57170. }
  57171. declare var WebGLSampler: {
  57172. prototype: WebGLSampler;
  57173. new(): WebGLSampler;
  57174. };
  57175. interface WebGLSync extends WebGLObject {
  57176. }
  57177. declare var WebGLSync: {
  57178. prototype: WebGLSync;
  57179. new(): WebGLSync;
  57180. };
  57181. interface WebGLTransformFeedback extends WebGLObject {
  57182. }
  57183. declare var WebGLTransformFeedback: {
  57184. prototype: WebGLTransformFeedback;
  57185. new(): WebGLTransformFeedback;
  57186. };
  57187. interface WebGLVertexArrayObject extends WebGLObject {
  57188. }
  57189. declare var WebGLVertexArrayObject: {
  57190. prototype: WebGLVertexArrayObject;
  57191. new(): WebGLVertexArrayObject;
  57192. };
  57193. // Type definitions for WebVR API
  57194. // Project: https://w3c.github.io/webvr/
  57195. // Definitions by: six a <https://github.com/lostfictions>
  57196. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  57197. interface VRDisplay extends EventTarget {
  57198. /**
  57199. * Dictionary of capabilities describing the VRDisplay.
  57200. */
  57201. readonly capabilities: VRDisplayCapabilities;
  57202. /**
  57203. * z-depth defining the far plane of the eye view frustum
  57204. * enables mapping of values in the render target depth
  57205. * attachment to scene coordinates. Initially set to 10000.0.
  57206. */
  57207. depthFar: number;
  57208. /**
  57209. * z-depth defining the near plane of the eye view frustum
  57210. * enables mapping of values in the render target depth
  57211. * attachment to scene coordinates. Initially set to 0.01.
  57212. */
  57213. depthNear: number;
  57214. /**
  57215. * An identifier for this distinct VRDisplay. Used as an
  57216. * association point in the Gamepad API.
  57217. */
  57218. readonly displayId: number;
  57219. /**
  57220. * A display name, a user-readable name identifying it.
  57221. */
  57222. readonly displayName: string;
  57223. readonly isConnected: boolean;
  57224. readonly isPresenting: boolean;
  57225. /**
  57226. * If this VRDisplay supports room-scale experiences, the optional
  57227. * stage attribute contains details on the room-scale parameters.
  57228. */
  57229. readonly stageParameters: VRStageParameters | null;
  57230. /**
  57231. * Passing the value returned by `requestAnimationFrame` to
  57232. * `cancelAnimationFrame` will unregister the callback.
  57233. * @param handle Define the hanle of the request to cancel
  57234. */
  57235. cancelAnimationFrame(handle: number): void;
  57236. /**
  57237. * Stops presenting to the VRDisplay.
  57238. * @returns a promise to know when it stopped
  57239. */
  57240. exitPresent(): Promise<void>;
  57241. /**
  57242. * Return the current VREyeParameters for the given eye.
  57243. * @param whichEye Define the eye we want the parameter for
  57244. * @returns the eye parameters
  57245. */
  57246. getEyeParameters(whichEye: string): VREyeParameters;
  57247. /**
  57248. * Populates the passed VRFrameData with the information required to render
  57249. * the current frame.
  57250. * @param frameData Define the data structure to populate
  57251. * @returns true if ok otherwise false
  57252. */
  57253. getFrameData(frameData: VRFrameData): boolean;
  57254. /**
  57255. * Get the layers currently being presented.
  57256. * @returns the list of VR layers
  57257. */
  57258. getLayers(): VRLayer[];
  57259. /**
  57260. * Return a VRPose containing the future predicted pose of the VRDisplay
  57261. * when the current frame will be presented. The value returned will not
  57262. * change until JavaScript has returned control to the browser.
  57263. *
  57264. * The VRPose will contain the position, orientation, velocity,
  57265. * and acceleration of each of these properties.
  57266. * @returns the pose object
  57267. */
  57268. getPose(): VRPose;
  57269. /**
  57270. * Return the current instantaneous pose of the VRDisplay, with no
  57271. * prediction applied.
  57272. * @returns the current instantaneous pose
  57273. */
  57274. getImmediatePose(): VRPose;
  57275. /**
  57276. * The callback passed to `requestAnimationFrame` will be called
  57277. * any time a new frame should be rendered. When the VRDisplay is
  57278. * presenting the callback will be called at the native refresh
  57279. * rate of the HMD. When not presenting this function acts
  57280. * identically to how window.requestAnimationFrame acts. Content should
  57281. * make no assumptions of frame rate or vsync behavior as the HMD runs
  57282. * asynchronously from other displays and at differing refresh rates.
  57283. * @param callback Define the eaction to run next frame
  57284. * @returns the request handle it
  57285. */
  57286. requestAnimationFrame(callback: FrameRequestCallback): number;
  57287. /**
  57288. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  57289. * Repeat calls while already presenting will update the VRLayers being displayed.
  57290. * @param layers Define the list of layer to present
  57291. * @returns a promise to know when the request has been fulfilled
  57292. */
  57293. requestPresent(layers: VRLayer[]): Promise<void>;
  57294. /**
  57295. * Reset the pose for this display, treating its current position and
  57296. * orientation as the "origin/zero" values. VRPose.position,
  57297. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  57298. * updated when calling resetPose(). This should be called in only
  57299. * sitting-space experiences.
  57300. */
  57301. resetPose(): void;
  57302. /**
  57303. * The VRLayer provided to the VRDisplay will be captured and presented
  57304. * in the HMD. Calling this function has the same effect on the source
  57305. * canvas as any other operation that uses its source image, and canvases
  57306. * created without preserveDrawingBuffer set to true will be cleared.
  57307. * @param pose Define the pose to submit
  57308. */
  57309. submitFrame(pose?: VRPose): void;
  57310. }
  57311. declare var VRDisplay: {
  57312. prototype: VRDisplay;
  57313. new(): VRDisplay;
  57314. };
  57315. interface VRLayer {
  57316. leftBounds?: number[] | Float32Array | null;
  57317. rightBounds?: number[] | Float32Array | null;
  57318. source?: HTMLCanvasElement | null;
  57319. }
  57320. interface VRDisplayCapabilities {
  57321. readonly canPresent: boolean;
  57322. readonly hasExternalDisplay: boolean;
  57323. readonly hasOrientation: boolean;
  57324. readonly hasPosition: boolean;
  57325. readonly maxLayers: number;
  57326. }
  57327. interface VREyeParameters {
  57328. /** @deprecated */
  57329. readonly fieldOfView: VRFieldOfView;
  57330. readonly offset: Float32Array;
  57331. readonly renderHeight: number;
  57332. readonly renderWidth: number;
  57333. }
  57334. interface VRFieldOfView {
  57335. readonly downDegrees: number;
  57336. readonly leftDegrees: number;
  57337. readonly rightDegrees: number;
  57338. readonly upDegrees: number;
  57339. }
  57340. interface VRFrameData {
  57341. readonly leftProjectionMatrix: Float32Array;
  57342. readonly leftViewMatrix: Float32Array;
  57343. readonly pose: VRPose;
  57344. readonly rightProjectionMatrix: Float32Array;
  57345. readonly rightViewMatrix: Float32Array;
  57346. readonly timestamp: number;
  57347. }
  57348. interface VRPose {
  57349. readonly angularAcceleration: Float32Array | null;
  57350. readonly angularVelocity: Float32Array | null;
  57351. readonly linearAcceleration: Float32Array | null;
  57352. readonly linearVelocity: Float32Array | null;
  57353. readonly orientation: Float32Array | null;
  57354. readonly position: Float32Array | null;
  57355. readonly timestamp: number;
  57356. }
  57357. interface VRStageParameters {
  57358. sittingToStandingTransform?: Float32Array;
  57359. sizeX?: number;
  57360. sizeY?: number;
  57361. }
  57362. interface Navigator {
  57363. getVRDisplays(): Promise<VRDisplay[]>;
  57364. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  57365. }
  57366. interface Window {
  57367. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  57368. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  57369. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  57370. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  57371. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  57372. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  57373. }
  57374. interface Gamepad {
  57375. readonly displayId: number;
  57376. }
  57377. interface XRDevice {
  57378. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  57379. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  57380. }
  57381. interface XRSession {
  57382. getInputSources(): Array<any>;
  57383. baseLayer: XRWebGLLayer;
  57384. requestFrameOfReference(type: string): Promise<void>;
  57385. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  57386. end(): Promise<void>;
  57387. requestAnimationFrame: Function;
  57388. addEventListener: Function;
  57389. }
  57390. interface XRSessionCreationOptions {
  57391. outputContext?: WebGLRenderingContext | null;
  57392. immersive?: boolean;
  57393. environmentIntegration?: boolean;
  57394. }
  57395. interface XRLayer {
  57396. getViewport: Function;
  57397. framebufferWidth: number;
  57398. framebufferHeight: number;
  57399. }
  57400. interface XRView {
  57401. projectionMatrix: Float32Array;
  57402. }
  57403. interface XRFrame {
  57404. getDevicePose: Function;
  57405. getInputPose: Function;
  57406. views: Array<XRView>;
  57407. baseLayer: XRLayer;
  57408. }
  57409. interface XRFrameOfReference {
  57410. }
  57411. interface XRWebGLLayer extends XRLayer {
  57412. framebuffer: WebGLFramebuffer;
  57413. }
  57414. declare var XRWebGLLayer: {
  57415. prototype: XRWebGLLayer;
  57416. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  57417. };
  57418. declare module "babylonjs" {
  57419. export * from "babylonjs/Legacy/legacy";
  57420. }
  57421. declare module BABYLON {
  57422. /** Alias type for value that can be null */
  57423. export type Nullable<T> = T | null;
  57424. /**
  57425. * Alias type for number that are floats
  57426. * @ignorenaming
  57427. */
  57428. export type float = number;
  57429. /**
  57430. * Alias type for number that are doubles.
  57431. * @ignorenaming
  57432. */
  57433. export type double = number;
  57434. /**
  57435. * Alias type for number that are integer
  57436. * @ignorenaming
  57437. */
  57438. export type int = number;
  57439. /** Alias type for number array or Float32Array */
  57440. export type FloatArray = number[] | Float32Array;
  57441. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  57442. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  57443. /**
  57444. * Alias for types that can be used by a Buffer or VertexBuffer.
  57445. */
  57446. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  57447. /**
  57448. * Alias type for primitive types
  57449. * @ignorenaming
  57450. */
  57451. type Primitive = undefined | null | boolean | string | number | Function;
  57452. /**
  57453. * Type modifier to make all the properties of an object Readonly
  57454. */
  57455. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  57456. /**
  57457. * Type modifier to make all the properties of an object Readonly recursively
  57458. */
  57459. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  57460. /** @hidden */
  57461. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  57462. }
  57463. /** @hidden */
  57464. /** @hidden */
  57465. type DeepImmutableObject<T> = {
  57466. readonly [K in keyof T]: DeepImmutable<T[K]>;
  57467. };
  57468. }
  57469. declare module BABYLON {
  57470. /**
  57471. * Class containing a set of static utilities functions for arrays.
  57472. */
  57473. export class ArrayTools {
  57474. /**
  57475. * Returns an array of the given size filled with element built from the given constructor and the paramters
  57476. * @param size the number of element to construct and put in the array
  57477. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  57478. * @returns a new array filled with new objects
  57479. */
  57480. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  57481. }
  57482. }
  57483. declare module BABYLON {
  57484. /**
  57485. * Scalar computation library
  57486. */
  57487. export class Scalar {
  57488. /**
  57489. * Two pi constants convenient for computation.
  57490. */
  57491. static TwoPi: number;
  57492. /**
  57493. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  57494. * @param a number
  57495. * @param b number
  57496. * @param epsilon (default = 1.401298E-45)
  57497. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  57498. */
  57499. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  57500. /**
  57501. * Returns a string : the upper case translation of the number i to hexadecimal.
  57502. * @param i number
  57503. * @returns the upper case translation of the number i to hexadecimal.
  57504. */
  57505. static ToHex(i: number): string;
  57506. /**
  57507. * Returns -1 if value is negative and +1 is value is positive.
  57508. * @param value the value
  57509. * @returns the value itself if it's equal to zero.
  57510. */
  57511. static Sign(value: number): number;
  57512. /**
  57513. * Returns the value itself if it's between min and max.
  57514. * Returns min if the value is lower than min.
  57515. * Returns max if the value is greater than max.
  57516. * @param value the value to clmap
  57517. * @param min the min value to clamp to (default: 0)
  57518. * @param max the max value to clamp to (default: 1)
  57519. * @returns the clamped value
  57520. */
  57521. static Clamp(value: number, min?: number, max?: number): number;
  57522. /**
  57523. * the log2 of value.
  57524. * @param value the value to compute log2 of
  57525. * @returns the log2 of value.
  57526. */
  57527. static Log2(value: number): number;
  57528. /**
  57529. * Loops the value, so that it is never larger than length and never smaller than 0.
  57530. *
  57531. * This is similar to the modulo operator but it works with floating point numbers.
  57532. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  57533. * With t = 5 and length = 2.5, the result would be 0.0.
  57534. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  57535. * @param value the value
  57536. * @param length the length
  57537. * @returns the looped value
  57538. */
  57539. static Repeat(value: number, length: number): number;
  57540. /**
  57541. * Normalize the value between 0.0 and 1.0 using min and max values
  57542. * @param value value to normalize
  57543. * @param min max to normalize between
  57544. * @param max min to normalize between
  57545. * @returns the normalized value
  57546. */
  57547. static Normalize(value: number, min: number, max: number): number;
  57548. /**
  57549. * Denormalize the value from 0.0 and 1.0 using min and max values
  57550. * @param normalized value to denormalize
  57551. * @param min max to denormalize between
  57552. * @param max min to denormalize between
  57553. * @returns the denormalized value
  57554. */
  57555. static Denormalize(normalized: number, min: number, max: number): number;
  57556. /**
  57557. * Calculates the shortest difference between two given angles given in degrees.
  57558. * @param current current angle in degrees
  57559. * @param target target angle in degrees
  57560. * @returns the delta
  57561. */
  57562. static DeltaAngle(current: number, target: number): number;
  57563. /**
  57564. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  57565. * @param tx value
  57566. * @param length length
  57567. * @returns The returned value will move back and forth between 0 and length
  57568. */
  57569. static PingPong(tx: number, length: number): number;
  57570. /**
  57571. * Interpolates between min and max with smoothing at the limits.
  57572. *
  57573. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  57574. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  57575. * @param from from
  57576. * @param to to
  57577. * @param tx value
  57578. * @returns the smooth stepped value
  57579. */
  57580. static SmoothStep(from: number, to: number, tx: number): number;
  57581. /**
  57582. * Moves a value current towards target.
  57583. *
  57584. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  57585. * Negative values of maxDelta pushes the value away from target.
  57586. * @param current current value
  57587. * @param target target value
  57588. * @param maxDelta max distance to move
  57589. * @returns resulting value
  57590. */
  57591. static MoveTowards(current: number, target: number, maxDelta: number): number;
  57592. /**
  57593. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  57594. *
  57595. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  57596. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  57597. * @param current current value
  57598. * @param target target value
  57599. * @param maxDelta max distance to move
  57600. * @returns resulting angle
  57601. */
  57602. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  57603. /**
  57604. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  57605. * @param start start value
  57606. * @param end target value
  57607. * @param amount amount to lerp between
  57608. * @returns the lerped value
  57609. */
  57610. static Lerp(start: number, end: number, amount: number): number;
  57611. /**
  57612. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  57613. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  57614. * @param start start value
  57615. * @param end target value
  57616. * @param amount amount to lerp between
  57617. * @returns the lerped value
  57618. */
  57619. static LerpAngle(start: number, end: number, amount: number): number;
  57620. /**
  57621. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  57622. * @param a start value
  57623. * @param b target value
  57624. * @param value value between a and b
  57625. * @returns the inverseLerp value
  57626. */
  57627. static InverseLerp(a: number, b: number, value: number): number;
  57628. /**
  57629. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  57630. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  57631. * @param value1 spline value
  57632. * @param tangent1 spline value
  57633. * @param value2 spline value
  57634. * @param tangent2 spline value
  57635. * @param amount input value
  57636. * @returns hermite result
  57637. */
  57638. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  57639. /**
  57640. * Returns a random float number between and min and max values
  57641. * @param min min value of random
  57642. * @param max max value of random
  57643. * @returns random value
  57644. */
  57645. static RandomRange(min: number, max: number): number;
  57646. /**
  57647. * This function returns percentage of a number in a given range.
  57648. *
  57649. * RangeToPercent(40,20,60) will return 0.5 (50%)
  57650. * RangeToPercent(34,0,100) will return 0.34 (34%)
  57651. * @param number to convert to percentage
  57652. * @param min min range
  57653. * @param max max range
  57654. * @returns the percentage
  57655. */
  57656. static RangeToPercent(number: number, min: number, max: number): number;
  57657. /**
  57658. * This function returns number that corresponds to the percentage in a given range.
  57659. *
  57660. * PercentToRange(0.34,0,100) will return 34.
  57661. * @param percent to convert to number
  57662. * @param min min range
  57663. * @param max max range
  57664. * @returns the number
  57665. */
  57666. static PercentToRange(percent: number, min: number, max: number): number;
  57667. /**
  57668. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  57669. * @param angle The angle to normalize in radian.
  57670. * @return The converted angle.
  57671. */
  57672. static NormalizeRadians(angle: number): number;
  57673. }
  57674. }
  57675. declare module BABYLON {
  57676. /**
  57677. * Constant used to convert a value to gamma space
  57678. * @ignorenaming
  57679. */
  57680. export const ToGammaSpace: number;
  57681. /**
  57682. * Constant used to convert a value to linear space
  57683. * @ignorenaming
  57684. */
  57685. export const ToLinearSpace = 2.2;
  57686. /**
  57687. * Constant used to define the minimal number value in Babylon.js
  57688. * @ignorenaming
  57689. */
  57690. export const Epsilon = 0.001;
  57691. /**
  57692. * Class used to hold a RBG color
  57693. */
  57694. export class Color3 {
  57695. /**
  57696. * Defines the red component (between 0 and 1, default is 0)
  57697. */
  57698. r: number;
  57699. /**
  57700. * Defines the green component (between 0 and 1, default is 0)
  57701. */
  57702. g: number;
  57703. /**
  57704. * Defines the blue component (between 0 and 1, default is 0)
  57705. */
  57706. b: number;
  57707. /**
  57708. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  57709. * @param r defines the red component (between 0 and 1, default is 0)
  57710. * @param g defines the green component (between 0 and 1, default is 0)
  57711. * @param b defines the blue component (between 0 and 1, default is 0)
  57712. */
  57713. constructor(
  57714. /**
  57715. * Defines the red component (between 0 and 1, default is 0)
  57716. */
  57717. r?: number,
  57718. /**
  57719. * Defines the green component (between 0 and 1, default is 0)
  57720. */
  57721. g?: number,
  57722. /**
  57723. * Defines the blue component (between 0 and 1, default is 0)
  57724. */
  57725. b?: number);
  57726. /**
  57727. * Creates a string with the Color3 current values
  57728. * @returns the string representation of the Color3 object
  57729. */
  57730. toString(): string;
  57731. /**
  57732. * Returns the string "Color3"
  57733. * @returns "Color3"
  57734. */
  57735. getClassName(): string;
  57736. /**
  57737. * Compute the Color3 hash code
  57738. * @returns an unique number that can be used to hash Color3 objects
  57739. */
  57740. getHashCode(): number;
  57741. /**
  57742. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  57743. * @param array defines the array where to store the r,g,b components
  57744. * @param index defines an optional index in the target array to define where to start storing values
  57745. * @returns the current Color3 object
  57746. */
  57747. toArray(array: FloatArray, index?: number): Color3;
  57748. /**
  57749. * Returns a new Color4 object from the current Color3 and the given alpha
  57750. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  57751. * @returns a new Color4 object
  57752. */
  57753. toColor4(alpha?: number): Color4;
  57754. /**
  57755. * Returns a new array populated with 3 numeric elements : red, green and blue values
  57756. * @returns the new array
  57757. */
  57758. asArray(): number[];
  57759. /**
  57760. * Returns the luminance value
  57761. * @returns a float value
  57762. */
  57763. toLuminance(): number;
  57764. /**
  57765. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  57766. * @param otherColor defines the second operand
  57767. * @returns the new Color3 object
  57768. */
  57769. multiply(otherColor: DeepImmutable<Color3>): Color3;
  57770. /**
  57771. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  57772. * @param otherColor defines the second operand
  57773. * @param result defines the Color3 object where to store the result
  57774. * @returns the current Color3
  57775. */
  57776. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  57777. /**
  57778. * Determines equality between Color3 objects
  57779. * @param otherColor defines the second operand
  57780. * @returns true if the rgb values are equal to the given ones
  57781. */
  57782. equals(otherColor: DeepImmutable<Color3>): boolean;
  57783. /**
  57784. * Determines equality between the current Color3 object and a set of r,b,g values
  57785. * @param r defines the red component to check
  57786. * @param g defines the green component to check
  57787. * @param b defines the blue component to check
  57788. * @returns true if the rgb values are equal to the given ones
  57789. */
  57790. equalsFloats(r: number, g: number, b: number): boolean;
  57791. /**
  57792. * Multiplies in place each rgb value by scale
  57793. * @param scale defines the scaling factor
  57794. * @returns the updated Color3
  57795. */
  57796. scale(scale: number): Color3;
  57797. /**
  57798. * Multiplies the rgb values by scale and stores the result into "result"
  57799. * @param scale defines the scaling factor
  57800. * @param result defines the Color3 object where to store the result
  57801. * @returns the unmodified current Color3
  57802. */
  57803. scaleToRef(scale: number, result: Color3): Color3;
  57804. /**
  57805. * Scale the current Color3 values by a factor and add the result to a given Color3
  57806. * @param scale defines the scale factor
  57807. * @param result defines color to store the result into
  57808. * @returns the unmodified current Color3
  57809. */
  57810. scaleAndAddToRef(scale: number, result: Color3): Color3;
  57811. /**
  57812. * Clamps the rgb values by the min and max values and stores the result into "result"
  57813. * @param min defines minimum clamping value (default is 0)
  57814. * @param max defines maximum clamping value (default is 1)
  57815. * @param result defines color to store the result into
  57816. * @returns the original Color3
  57817. */
  57818. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  57819. /**
  57820. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  57821. * @param otherColor defines the second operand
  57822. * @returns the new Color3
  57823. */
  57824. add(otherColor: DeepImmutable<Color3>): Color3;
  57825. /**
  57826. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  57827. * @param otherColor defines the second operand
  57828. * @param result defines Color3 object to store the result into
  57829. * @returns the unmodified current Color3
  57830. */
  57831. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  57832. /**
  57833. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  57834. * @param otherColor defines the second operand
  57835. * @returns the new Color3
  57836. */
  57837. subtract(otherColor: DeepImmutable<Color3>): Color3;
  57838. /**
  57839. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  57840. * @param otherColor defines the second operand
  57841. * @param result defines Color3 object to store the result into
  57842. * @returns the unmodified current Color3
  57843. */
  57844. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  57845. /**
  57846. * Copy the current object
  57847. * @returns a new Color3 copied the current one
  57848. */
  57849. clone(): Color3;
  57850. /**
  57851. * Copies the rgb values from the source in the current Color3
  57852. * @param source defines the source Color3 object
  57853. * @returns the updated Color3 object
  57854. */
  57855. copyFrom(source: DeepImmutable<Color3>): Color3;
  57856. /**
  57857. * Updates the Color3 rgb values from the given floats
  57858. * @param r defines the red component to read from
  57859. * @param g defines the green component to read from
  57860. * @param b defines the blue component to read from
  57861. * @returns the current Color3 object
  57862. */
  57863. copyFromFloats(r: number, g: number, b: number): Color3;
  57864. /**
  57865. * Updates the Color3 rgb values from the given floats
  57866. * @param r defines the red component to read from
  57867. * @param g defines the green component to read from
  57868. * @param b defines the blue component to read from
  57869. * @returns the current Color3 object
  57870. */
  57871. set(r: number, g: number, b: number): Color3;
  57872. /**
  57873. * Compute the Color3 hexadecimal code as a string
  57874. * @returns a string containing the hexadecimal representation of the Color3 object
  57875. */
  57876. toHexString(): string;
  57877. /**
  57878. * Computes a new Color3 converted from the current one to linear space
  57879. * @returns a new Color3 object
  57880. */
  57881. toLinearSpace(): Color3;
  57882. /**
  57883. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  57884. * @param convertedColor defines the Color3 object where to store the linear space version
  57885. * @returns the unmodified Color3
  57886. */
  57887. toLinearSpaceToRef(convertedColor: Color3): Color3;
  57888. /**
  57889. * Computes a new Color3 converted from the current one to gamma space
  57890. * @returns a new Color3 object
  57891. */
  57892. toGammaSpace(): Color3;
  57893. /**
  57894. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  57895. * @param convertedColor defines the Color3 object where to store the gamma space version
  57896. * @returns the unmodified Color3
  57897. */
  57898. toGammaSpaceToRef(convertedColor: Color3): Color3;
  57899. private static _BlackReadOnly;
  57900. /**
  57901. * Creates a new Color3 from the string containing valid hexadecimal values
  57902. * @param hex defines a string containing valid hexadecimal values
  57903. * @returns a new Color3 object
  57904. */
  57905. static FromHexString(hex: string): Color3;
  57906. /**
  57907. * Creates a new Vector3 from the starting index of the given array
  57908. * @param array defines the source array
  57909. * @param offset defines an offset in the source array
  57910. * @returns a new Color3 object
  57911. */
  57912. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  57913. /**
  57914. * Creates a new Color3 from integer values (< 256)
  57915. * @param r defines the red component to read from (value between 0 and 255)
  57916. * @param g defines the green component to read from (value between 0 and 255)
  57917. * @param b defines the blue component to read from (value between 0 and 255)
  57918. * @returns a new Color3 object
  57919. */
  57920. static FromInts(r: number, g: number, b: number): Color3;
  57921. /**
  57922. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  57923. * @param start defines the start Color3 value
  57924. * @param end defines the end Color3 value
  57925. * @param amount defines the gradient value between start and end
  57926. * @returns a new Color3 object
  57927. */
  57928. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  57929. /**
  57930. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  57931. * @param left defines the start value
  57932. * @param right defines the end value
  57933. * @param amount defines the gradient factor
  57934. * @param result defines the Color3 object where to store the result
  57935. */
  57936. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  57937. /**
  57938. * Returns a Color3 value containing a red color
  57939. * @returns a new Color3 object
  57940. */
  57941. static Red(): Color3;
  57942. /**
  57943. * Returns a Color3 value containing a green color
  57944. * @returns a new Color3 object
  57945. */
  57946. static Green(): Color3;
  57947. /**
  57948. * Returns a Color3 value containing a blue color
  57949. * @returns a new Color3 object
  57950. */
  57951. static Blue(): Color3;
  57952. /**
  57953. * Returns a Color3 value containing a black color
  57954. * @returns a new Color3 object
  57955. */
  57956. static Black(): Color3;
  57957. /**
  57958. * Gets a Color3 value containing a black color that must not be updated
  57959. */
  57960. static readonly BlackReadOnly: DeepImmutable<Color3>;
  57961. /**
  57962. * Returns a Color3 value containing a white color
  57963. * @returns a new Color3 object
  57964. */
  57965. static White(): Color3;
  57966. /**
  57967. * Returns a Color3 value containing a purple color
  57968. * @returns a new Color3 object
  57969. */
  57970. static Purple(): Color3;
  57971. /**
  57972. * Returns a Color3 value containing a magenta color
  57973. * @returns a new Color3 object
  57974. */
  57975. static Magenta(): Color3;
  57976. /**
  57977. * Returns a Color3 value containing a yellow color
  57978. * @returns a new Color3 object
  57979. */
  57980. static Yellow(): Color3;
  57981. /**
  57982. * Returns a Color3 value containing a gray color
  57983. * @returns a new Color3 object
  57984. */
  57985. static Gray(): Color3;
  57986. /**
  57987. * Returns a Color3 value containing a teal color
  57988. * @returns a new Color3 object
  57989. */
  57990. static Teal(): Color3;
  57991. /**
  57992. * Returns a Color3 value containing a random color
  57993. * @returns a new Color3 object
  57994. */
  57995. static Random(): Color3;
  57996. }
  57997. /**
  57998. * Class used to hold a RBGA color
  57999. */
  58000. export class Color4 {
  58001. /**
  58002. * Defines the red component (between 0 and 1, default is 0)
  58003. */
  58004. r: number;
  58005. /**
  58006. * Defines the green component (between 0 and 1, default is 0)
  58007. */
  58008. g: number;
  58009. /**
  58010. * Defines the blue component (between 0 and 1, default is 0)
  58011. */
  58012. b: number;
  58013. /**
  58014. * Defines the alpha component (between 0 and 1, default is 1)
  58015. */
  58016. a: number;
  58017. /**
  58018. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  58019. * @param r defines the red component (between 0 and 1, default is 0)
  58020. * @param g defines the green component (between 0 and 1, default is 0)
  58021. * @param b defines the blue component (between 0 and 1, default is 0)
  58022. * @param a defines the alpha component (between 0 and 1, default is 1)
  58023. */
  58024. constructor(
  58025. /**
  58026. * Defines the red component (between 0 and 1, default is 0)
  58027. */
  58028. r?: number,
  58029. /**
  58030. * Defines the green component (between 0 and 1, default is 0)
  58031. */
  58032. g?: number,
  58033. /**
  58034. * Defines the blue component (between 0 and 1, default is 0)
  58035. */
  58036. b?: number,
  58037. /**
  58038. * Defines the alpha component (between 0 and 1, default is 1)
  58039. */
  58040. a?: number);
  58041. /**
  58042. * Adds in place the given Color4 values to the current Color4 object
  58043. * @param right defines the second operand
  58044. * @returns the current updated Color4 object
  58045. */
  58046. addInPlace(right: DeepImmutable<Color4>): Color4;
  58047. /**
  58048. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  58049. * @returns the new array
  58050. */
  58051. asArray(): number[];
  58052. /**
  58053. * Stores from the starting index in the given array the Color4 successive values
  58054. * @param array defines the array where to store the r,g,b components
  58055. * @param index defines an optional index in the target array to define where to start storing values
  58056. * @returns the current Color4 object
  58057. */
  58058. toArray(array: number[], index?: number): Color4;
  58059. /**
  58060. * Determines equality between Color4 objects
  58061. * @param otherColor defines the second operand
  58062. * @returns true if the rgba values are equal to the given ones
  58063. */
  58064. equals(otherColor: DeepImmutable<Color4>): boolean;
  58065. /**
  58066. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  58067. * @param right defines the second operand
  58068. * @returns a new Color4 object
  58069. */
  58070. add(right: DeepImmutable<Color4>): Color4;
  58071. /**
  58072. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  58073. * @param right defines the second operand
  58074. * @returns a new Color4 object
  58075. */
  58076. subtract(right: DeepImmutable<Color4>): Color4;
  58077. /**
  58078. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  58079. * @param right defines the second operand
  58080. * @param result defines the Color4 object where to store the result
  58081. * @returns the current Color4 object
  58082. */
  58083. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  58084. /**
  58085. * Creates a new Color4 with the current Color4 values multiplied by scale
  58086. * @param scale defines the scaling factor to apply
  58087. * @returns a new Color4 object
  58088. */
  58089. scale(scale: number): Color4;
  58090. /**
  58091. * Multiplies the current Color4 values by scale and stores the result in "result"
  58092. * @param scale defines the scaling factor to apply
  58093. * @param result defines the Color4 object where to store the result
  58094. * @returns the current unmodified Color4
  58095. */
  58096. scaleToRef(scale: number, result: Color4): Color4;
  58097. /**
  58098. * Scale the current Color4 values by a factor and add the result to a given Color4
  58099. * @param scale defines the scale factor
  58100. * @param result defines the Color4 object where to store the result
  58101. * @returns the unmodified current Color4
  58102. */
  58103. scaleAndAddToRef(scale: number, result: Color4): Color4;
  58104. /**
  58105. * Clamps the rgb values by the min and max values and stores the result into "result"
  58106. * @param min defines minimum clamping value (default is 0)
  58107. * @param max defines maximum clamping value (default is 1)
  58108. * @param result defines color to store the result into.
  58109. * @returns the cuurent Color4
  58110. */
  58111. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  58112. /**
  58113. * Multipy an Color4 value by another and return a new Color4 object
  58114. * @param color defines the Color4 value to multiply by
  58115. * @returns a new Color4 object
  58116. */
  58117. multiply(color: Color4): Color4;
  58118. /**
  58119. * Multipy a Color4 value by another and push the result in a reference value
  58120. * @param color defines the Color4 value to multiply by
  58121. * @param result defines the Color4 to fill the result in
  58122. * @returns the result Color4
  58123. */
  58124. multiplyToRef(color: Color4, result: Color4): Color4;
  58125. /**
  58126. * Creates a string with the Color4 current values
  58127. * @returns the string representation of the Color4 object
  58128. */
  58129. toString(): string;
  58130. /**
  58131. * Returns the string "Color4"
  58132. * @returns "Color4"
  58133. */
  58134. getClassName(): string;
  58135. /**
  58136. * Compute the Color4 hash code
  58137. * @returns an unique number that can be used to hash Color4 objects
  58138. */
  58139. getHashCode(): number;
  58140. /**
  58141. * Creates a new Color4 copied from the current one
  58142. * @returns a new Color4 object
  58143. */
  58144. clone(): Color4;
  58145. /**
  58146. * Copies the given Color4 values into the current one
  58147. * @param source defines the source Color4 object
  58148. * @returns the current updated Color4 object
  58149. */
  58150. copyFrom(source: Color4): Color4;
  58151. /**
  58152. * Copies the given float values into the current one
  58153. * @param r defines the red component to read from
  58154. * @param g defines the green component to read from
  58155. * @param b defines the blue component to read from
  58156. * @param a defines the alpha component to read from
  58157. * @returns the current updated Color4 object
  58158. */
  58159. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  58160. /**
  58161. * Copies the given float values into the current one
  58162. * @param r defines the red component to read from
  58163. * @param g defines the green component to read from
  58164. * @param b defines the blue component to read from
  58165. * @param a defines the alpha component to read from
  58166. * @returns the current updated Color4 object
  58167. */
  58168. set(r: number, g: number, b: number, a: number): Color4;
  58169. /**
  58170. * Compute the Color4 hexadecimal code as a string
  58171. * @returns a string containing the hexadecimal representation of the Color4 object
  58172. */
  58173. toHexString(): string;
  58174. /**
  58175. * Computes a new Color4 converted from the current one to linear space
  58176. * @returns a new Color4 object
  58177. */
  58178. toLinearSpace(): Color4;
  58179. /**
  58180. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  58181. * @param convertedColor defines the Color4 object where to store the linear space version
  58182. * @returns the unmodified Color4
  58183. */
  58184. toLinearSpaceToRef(convertedColor: Color4): Color4;
  58185. /**
  58186. * Computes a new Color4 converted from the current one to gamma space
  58187. * @returns a new Color4 object
  58188. */
  58189. toGammaSpace(): Color4;
  58190. /**
  58191. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  58192. * @param convertedColor defines the Color4 object where to store the gamma space version
  58193. * @returns the unmodified Color4
  58194. */
  58195. toGammaSpaceToRef(convertedColor: Color4): Color4;
  58196. /**
  58197. * Creates a new Color4 from the string containing valid hexadecimal values
  58198. * @param hex defines a string containing valid hexadecimal values
  58199. * @returns a new Color4 object
  58200. */
  58201. static FromHexString(hex: string): Color4;
  58202. /**
  58203. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  58204. * @param left defines the start value
  58205. * @param right defines the end value
  58206. * @param amount defines the gradient factor
  58207. * @returns a new Color4 object
  58208. */
  58209. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  58210. /**
  58211. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  58212. * @param left defines the start value
  58213. * @param right defines the end value
  58214. * @param amount defines the gradient factor
  58215. * @param result defines the Color4 object where to store data
  58216. */
  58217. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  58218. /**
  58219. * Creates a new Color4 from a Color3 and an alpha value
  58220. * @param color3 defines the source Color3 to read from
  58221. * @param alpha defines the alpha component (1.0 by default)
  58222. * @returns a new Color4 object
  58223. */
  58224. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  58225. /**
  58226. * Creates a new Color4 from the starting index element of the given array
  58227. * @param array defines the source array to read from
  58228. * @param offset defines the offset in the source array
  58229. * @returns a new Color4 object
  58230. */
  58231. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  58232. /**
  58233. * Creates a new Color3 from integer values (< 256)
  58234. * @param r defines the red component to read from (value between 0 and 255)
  58235. * @param g defines the green component to read from (value between 0 and 255)
  58236. * @param b defines the blue component to read from (value between 0 and 255)
  58237. * @param a defines the alpha component to read from (value between 0 and 255)
  58238. * @returns a new Color3 object
  58239. */
  58240. static FromInts(r: number, g: number, b: number, a: number): Color4;
  58241. /**
  58242. * Check the content of a given array and convert it to an array containing RGBA data
  58243. * If the original array was already containing count * 4 values then it is returned directly
  58244. * @param colors defines the array to check
  58245. * @param count defines the number of RGBA data to expect
  58246. * @returns an array containing count * 4 values (RGBA)
  58247. */
  58248. static CheckColors4(colors: number[], count: number): number[];
  58249. }
  58250. /**
  58251. * Class representing a vector containing 2 coordinates
  58252. */
  58253. export class Vector2 {
  58254. /** defines the first coordinate */
  58255. x: number;
  58256. /** defines the second coordinate */
  58257. y: number;
  58258. /**
  58259. * Creates a new Vector2 from the given x and y coordinates
  58260. * @param x defines the first coordinate
  58261. * @param y defines the second coordinate
  58262. */
  58263. constructor(
  58264. /** defines the first coordinate */
  58265. x?: number,
  58266. /** defines the second coordinate */
  58267. y?: number);
  58268. /**
  58269. * Gets a string with the Vector2 coordinates
  58270. * @returns a string with the Vector2 coordinates
  58271. */
  58272. toString(): string;
  58273. /**
  58274. * Gets class name
  58275. * @returns the string "Vector2"
  58276. */
  58277. getClassName(): string;
  58278. /**
  58279. * Gets current vector hash code
  58280. * @returns the Vector2 hash code as a number
  58281. */
  58282. getHashCode(): number;
  58283. /**
  58284. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  58285. * @param array defines the source array
  58286. * @param index defines the offset in source array
  58287. * @returns the current Vector2
  58288. */
  58289. toArray(array: FloatArray, index?: number): Vector2;
  58290. /**
  58291. * Copy the current vector to an array
  58292. * @returns a new array with 2 elements: the Vector2 coordinates.
  58293. */
  58294. asArray(): number[];
  58295. /**
  58296. * Sets the Vector2 coordinates with the given Vector2 coordinates
  58297. * @param source defines the source Vector2
  58298. * @returns the current updated Vector2
  58299. */
  58300. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  58301. /**
  58302. * Sets the Vector2 coordinates with the given floats
  58303. * @param x defines the first coordinate
  58304. * @param y defines the second coordinate
  58305. * @returns the current updated Vector2
  58306. */
  58307. copyFromFloats(x: number, y: number): Vector2;
  58308. /**
  58309. * Sets the Vector2 coordinates with the given floats
  58310. * @param x defines the first coordinate
  58311. * @param y defines the second coordinate
  58312. * @returns the current updated Vector2
  58313. */
  58314. set(x: number, y: number): Vector2;
  58315. /**
  58316. * Add another vector with the current one
  58317. * @param otherVector defines the other vector
  58318. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  58319. */
  58320. add(otherVector: DeepImmutable<Vector2>): Vector2;
  58321. /**
  58322. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  58323. * @param otherVector defines the other vector
  58324. * @param result defines the target vector
  58325. * @returns the unmodified current Vector2
  58326. */
  58327. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  58328. /**
  58329. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  58330. * @param otherVector defines the other vector
  58331. * @returns the current updated Vector2
  58332. */
  58333. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  58334. /**
  58335. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  58336. * @param otherVector defines the other vector
  58337. * @returns a new Vector2
  58338. */
  58339. addVector3(otherVector: Vector3): Vector2;
  58340. /**
  58341. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  58342. * @param otherVector defines the other vector
  58343. * @returns a new Vector2
  58344. */
  58345. subtract(otherVector: Vector2): Vector2;
  58346. /**
  58347. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  58348. * @param otherVector defines the other vector
  58349. * @param result defines the target vector
  58350. * @returns the unmodified current Vector2
  58351. */
  58352. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  58353. /**
  58354. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  58355. * @param otherVector defines the other vector
  58356. * @returns the current updated Vector2
  58357. */
  58358. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  58359. /**
  58360. * Multiplies in place the current Vector2 coordinates by the given ones
  58361. * @param otherVector defines the other vector
  58362. * @returns the current updated Vector2
  58363. */
  58364. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  58365. /**
  58366. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  58367. * @param otherVector defines the other vector
  58368. * @returns a new Vector2
  58369. */
  58370. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  58371. /**
  58372. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  58373. * @param otherVector defines the other vector
  58374. * @param result defines the target vector
  58375. * @returns the unmodified current Vector2
  58376. */
  58377. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  58378. /**
  58379. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  58380. * @param x defines the first coordinate
  58381. * @param y defines the second coordinate
  58382. * @returns a new Vector2
  58383. */
  58384. multiplyByFloats(x: number, y: number): Vector2;
  58385. /**
  58386. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  58387. * @param otherVector defines the other vector
  58388. * @returns a new Vector2
  58389. */
  58390. divide(otherVector: Vector2): Vector2;
  58391. /**
  58392. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  58393. * @param otherVector defines the other vector
  58394. * @param result defines the target vector
  58395. * @returns the unmodified current Vector2
  58396. */
  58397. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  58398. /**
  58399. * Divides the current Vector2 coordinates by the given ones
  58400. * @param otherVector defines the other vector
  58401. * @returns the current updated Vector2
  58402. */
  58403. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  58404. /**
  58405. * Gets a new Vector2 with current Vector2 negated coordinates
  58406. * @returns a new Vector2
  58407. */
  58408. negate(): Vector2;
  58409. /**
  58410. * Multiply the Vector2 coordinates by scale
  58411. * @param scale defines the scaling factor
  58412. * @returns the current updated Vector2
  58413. */
  58414. scaleInPlace(scale: number): Vector2;
  58415. /**
  58416. * Returns a new Vector2 scaled by "scale" from the current Vector2
  58417. * @param scale defines the scaling factor
  58418. * @returns a new Vector2
  58419. */
  58420. scale(scale: number): Vector2;
  58421. /**
  58422. * Scale the current Vector2 values by a factor to a given Vector2
  58423. * @param scale defines the scale factor
  58424. * @param result defines the Vector2 object where to store the result
  58425. * @returns the unmodified current Vector2
  58426. */
  58427. scaleToRef(scale: number, result: Vector2): Vector2;
  58428. /**
  58429. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  58430. * @param scale defines the scale factor
  58431. * @param result defines the Vector2 object where to store the result
  58432. * @returns the unmodified current Vector2
  58433. */
  58434. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  58435. /**
  58436. * Gets a boolean if two vectors are equals
  58437. * @param otherVector defines the other vector
  58438. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  58439. */
  58440. equals(otherVector: DeepImmutable<Vector2>): boolean;
  58441. /**
  58442. * Gets a boolean if two vectors are equals (using an epsilon value)
  58443. * @param otherVector defines the other vector
  58444. * @param epsilon defines the minimal distance to consider equality
  58445. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  58446. */
  58447. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  58448. /**
  58449. * Gets a new Vector2 from current Vector2 floored values
  58450. * @returns a new Vector2
  58451. */
  58452. floor(): Vector2;
  58453. /**
  58454. * Gets a new Vector2 from current Vector2 floored values
  58455. * @returns a new Vector2
  58456. */
  58457. fract(): Vector2;
  58458. /**
  58459. * Gets the length of the vector
  58460. * @returns the vector length (float)
  58461. */
  58462. length(): number;
  58463. /**
  58464. * Gets the vector squared length
  58465. * @returns the vector squared length (float)
  58466. */
  58467. lengthSquared(): number;
  58468. /**
  58469. * Normalize the vector
  58470. * @returns the current updated Vector2
  58471. */
  58472. normalize(): Vector2;
  58473. /**
  58474. * Gets a new Vector2 copied from the Vector2
  58475. * @returns a new Vector2
  58476. */
  58477. clone(): Vector2;
  58478. /**
  58479. * Gets a new Vector2(0, 0)
  58480. * @returns a new Vector2
  58481. */
  58482. static Zero(): Vector2;
  58483. /**
  58484. * Gets a new Vector2(1, 1)
  58485. * @returns a new Vector2
  58486. */
  58487. static One(): Vector2;
  58488. /**
  58489. * Gets a new Vector2 set from the given index element of the given array
  58490. * @param array defines the data source
  58491. * @param offset defines the offset in the data source
  58492. * @returns a new Vector2
  58493. */
  58494. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  58495. /**
  58496. * Sets "result" from the given index element of the given array
  58497. * @param array defines the data source
  58498. * @param offset defines the offset in the data source
  58499. * @param result defines the target vector
  58500. */
  58501. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  58502. /**
  58503. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  58504. * @param value1 defines 1st point of control
  58505. * @param value2 defines 2nd point of control
  58506. * @param value3 defines 3rd point of control
  58507. * @param value4 defines 4th point of control
  58508. * @param amount defines the interpolation factor
  58509. * @returns a new Vector2
  58510. */
  58511. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  58512. /**
  58513. * 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".
  58514. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  58515. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  58516. * @param value defines the value to clamp
  58517. * @param min defines the lower limit
  58518. * @param max defines the upper limit
  58519. * @returns a new Vector2
  58520. */
  58521. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  58522. /**
  58523. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  58524. * @param value1 defines the 1st control point
  58525. * @param tangent1 defines the outgoing tangent
  58526. * @param value2 defines the 2nd control point
  58527. * @param tangent2 defines the incoming tangent
  58528. * @param amount defines the interpolation factor
  58529. * @returns a new Vector2
  58530. */
  58531. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  58532. /**
  58533. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  58534. * @param start defines the start vector
  58535. * @param end defines the end vector
  58536. * @param amount defines the interpolation factor
  58537. * @returns a new Vector2
  58538. */
  58539. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  58540. /**
  58541. * Gets the dot product of the vector "left" and the vector "right"
  58542. * @param left defines first vector
  58543. * @param right defines second vector
  58544. * @returns the dot product (float)
  58545. */
  58546. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  58547. /**
  58548. * Returns a new Vector2 equal to the normalized given vector
  58549. * @param vector defines the vector to normalize
  58550. * @returns a new Vector2
  58551. */
  58552. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  58553. /**
  58554. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  58555. * @param left defines 1st vector
  58556. * @param right defines 2nd vector
  58557. * @returns a new Vector2
  58558. */
  58559. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  58560. /**
  58561. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  58562. * @param left defines 1st vector
  58563. * @param right defines 2nd vector
  58564. * @returns a new Vector2
  58565. */
  58566. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  58567. /**
  58568. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  58569. * @param vector defines the vector to transform
  58570. * @param transformation defines the matrix to apply
  58571. * @returns a new Vector2
  58572. */
  58573. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  58574. /**
  58575. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  58576. * @param vector defines the vector to transform
  58577. * @param transformation defines the matrix to apply
  58578. * @param result defines the target vector
  58579. */
  58580. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  58581. /**
  58582. * Determines if a given vector is included in a triangle
  58583. * @param p defines the vector to test
  58584. * @param p0 defines 1st triangle point
  58585. * @param p1 defines 2nd triangle point
  58586. * @param p2 defines 3rd triangle point
  58587. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  58588. */
  58589. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  58590. /**
  58591. * Gets the distance between the vectors "value1" and "value2"
  58592. * @param value1 defines first vector
  58593. * @param value2 defines second vector
  58594. * @returns the distance between vectors
  58595. */
  58596. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  58597. /**
  58598. * Returns the squared distance between the vectors "value1" and "value2"
  58599. * @param value1 defines first vector
  58600. * @param value2 defines second vector
  58601. * @returns the squared distance between vectors
  58602. */
  58603. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  58604. /**
  58605. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  58606. * @param value1 defines first vector
  58607. * @param value2 defines second vector
  58608. * @returns a new Vector2
  58609. */
  58610. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  58611. /**
  58612. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  58613. * @param p defines the middle point
  58614. * @param segA defines one point of the segment
  58615. * @param segB defines the other point of the segment
  58616. * @returns the shortest distance
  58617. */
  58618. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  58619. }
  58620. /**
  58621. * Classed used to store (x,y,z) vector representation
  58622. * A Vector3 is the main object used in 3D geometry
  58623. * It can represent etiher the coordinates of a point the space, either a direction
  58624. * Reminder: js uses a left handed forward facing system
  58625. */
  58626. export class Vector3 {
  58627. /**
  58628. * Defines the first coordinates (on X axis)
  58629. */
  58630. x: number;
  58631. /**
  58632. * Defines the second coordinates (on Y axis)
  58633. */
  58634. y: number;
  58635. /**
  58636. * Defines the third coordinates (on Z axis)
  58637. */
  58638. z: number;
  58639. private static _UpReadOnly;
  58640. /**
  58641. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  58642. * @param x defines the first coordinates (on X axis)
  58643. * @param y defines the second coordinates (on Y axis)
  58644. * @param z defines the third coordinates (on Z axis)
  58645. */
  58646. constructor(
  58647. /**
  58648. * Defines the first coordinates (on X axis)
  58649. */
  58650. x?: number,
  58651. /**
  58652. * Defines the second coordinates (on Y axis)
  58653. */
  58654. y?: number,
  58655. /**
  58656. * Defines the third coordinates (on Z axis)
  58657. */
  58658. z?: number);
  58659. /**
  58660. * Creates a string representation of the Vector3
  58661. * @returns a string with the Vector3 coordinates.
  58662. */
  58663. toString(): string;
  58664. /**
  58665. * Gets the class name
  58666. * @returns the string "Vector3"
  58667. */
  58668. getClassName(): string;
  58669. /**
  58670. * Creates the Vector3 hash code
  58671. * @returns a number which tends to be unique between Vector3 instances
  58672. */
  58673. getHashCode(): number;
  58674. /**
  58675. * Creates an array containing three elements : the coordinates of the Vector3
  58676. * @returns a new array of numbers
  58677. */
  58678. asArray(): number[];
  58679. /**
  58680. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  58681. * @param array defines the destination array
  58682. * @param index defines the offset in the destination array
  58683. * @returns the current Vector3
  58684. */
  58685. toArray(array: FloatArray, index?: number): Vector3;
  58686. /**
  58687. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  58688. * @returns a new Quaternion object, computed from the Vector3 coordinates
  58689. */
  58690. toQuaternion(): Quaternion;
  58691. /**
  58692. * Adds the given vector to the current Vector3
  58693. * @param otherVector defines the second operand
  58694. * @returns the current updated Vector3
  58695. */
  58696. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  58697. /**
  58698. * Adds the given coordinates to the current Vector3
  58699. * @param x defines the x coordinate of the operand
  58700. * @param y defines the y coordinate of the operand
  58701. * @param z defines the z coordinate of the operand
  58702. * @returns the current updated Vector3
  58703. */
  58704. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  58705. /**
  58706. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  58707. * @param otherVector defines the second operand
  58708. * @returns the resulting Vector3
  58709. */
  58710. add(otherVector: DeepImmutable<Vector3>): Vector3;
  58711. /**
  58712. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  58713. * @param otherVector defines the second operand
  58714. * @param result defines the Vector3 object where to store the result
  58715. * @returns the current Vector3
  58716. */
  58717. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  58718. /**
  58719. * Subtract the given vector from the current Vector3
  58720. * @param otherVector defines the second operand
  58721. * @returns the current updated Vector3
  58722. */
  58723. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  58724. /**
  58725. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  58726. * @param otherVector defines the second operand
  58727. * @returns the resulting Vector3
  58728. */
  58729. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  58730. /**
  58731. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  58732. * @param otherVector defines the second operand
  58733. * @param result defines the Vector3 object where to store the result
  58734. * @returns the current Vector3
  58735. */
  58736. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  58737. /**
  58738. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  58739. * @param x defines the x coordinate of the operand
  58740. * @param y defines the y coordinate of the operand
  58741. * @param z defines the z coordinate of the operand
  58742. * @returns the resulting Vector3
  58743. */
  58744. subtractFromFloats(x: number, y: number, z: number): Vector3;
  58745. /**
  58746. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  58747. * @param x defines the x coordinate of the operand
  58748. * @param y defines the y coordinate of the operand
  58749. * @param z defines the z coordinate of the operand
  58750. * @param result defines the Vector3 object where to store the result
  58751. * @returns the current Vector3
  58752. */
  58753. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  58754. /**
  58755. * Gets a new Vector3 set with the current Vector3 negated coordinates
  58756. * @returns a new Vector3
  58757. */
  58758. negate(): Vector3;
  58759. /**
  58760. * Multiplies the Vector3 coordinates by the float "scale"
  58761. * @param scale defines the multiplier factor
  58762. * @returns the current updated Vector3
  58763. */
  58764. scaleInPlace(scale: number): Vector3;
  58765. /**
  58766. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  58767. * @param scale defines the multiplier factor
  58768. * @returns a new Vector3
  58769. */
  58770. scale(scale: number): Vector3;
  58771. /**
  58772. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  58773. * @param scale defines the multiplier factor
  58774. * @param result defines the Vector3 object where to store the result
  58775. * @returns the current Vector3
  58776. */
  58777. scaleToRef(scale: number, result: Vector3): Vector3;
  58778. /**
  58779. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  58780. * @param scale defines the scale factor
  58781. * @param result defines the Vector3 object where to store the result
  58782. * @returns the unmodified current Vector3
  58783. */
  58784. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  58785. /**
  58786. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  58787. * @param otherVector defines the second operand
  58788. * @returns true if both vectors are equals
  58789. */
  58790. equals(otherVector: DeepImmutable<Vector3>): boolean;
  58791. /**
  58792. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  58793. * @param otherVector defines the second operand
  58794. * @param epsilon defines the minimal distance to define values as equals
  58795. * @returns true if both vectors are distant less than epsilon
  58796. */
  58797. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  58798. /**
  58799. * Returns true if the current Vector3 coordinates equals the given floats
  58800. * @param x defines the x coordinate of the operand
  58801. * @param y defines the y coordinate of the operand
  58802. * @param z defines the z coordinate of the operand
  58803. * @returns true if both vectors are equals
  58804. */
  58805. equalsToFloats(x: number, y: number, z: number): boolean;
  58806. /**
  58807. * Multiplies the current Vector3 coordinates by the given ones
  58808. * @param otherVector defines the second operand
  58809. * @returns the current updated Vector3
  58810. */
  58811. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  58812. /**
  58813. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  58814. * @param otherVector defines the second operand
  58815. * @returns the new Vector3
  58816. */
  58817. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  58818. /**
  58819. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  58820. * @param otherVector defines the second operand
  58821. * @param result defines the Vector3 object where to store the result
  58822. * @returns the current Vector3
  58823. */
  58824. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  58825. /**
  58826. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  58827. * @param x defines the x coordinate of the operand
  58828. * @param y defines the y coordinate of the operand
  58829. * @param z defines the z coordinate of the operand
  58830. * @returns the new Vector3
  58831. */
  58832. multiplyByFloats(x: number, y: number, z: number): Vector3;
  58833. /**
  58834. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  58835. * @param otherVector defines the second operand
  58836. * @returns the new Vector3
  58837. */
  58838. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  58839. /**
  58840. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  58841. * @param otherVector defines the second operand
  58842. * @param result defines the Vector3 object where to store the result
  58843. * @returns the current Vector3
  58844. */
  58845. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  58846. /**
  58847. * Divides the current Vector3 coordinates by the given ones.
  58848. * @param otherVector defines the second operand
  58849. * @returns the current updated Vector3
  58850. */
  58851. divideInPlace(otherVector: Vector3): Vector3;
  58852. /**
  58853. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  58854. * @param other defines the second operand
  58855. * @returns the current updated Vector3
  58856. */
  58857. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  58858. /**
  58859. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  58860. * @param other defines the second operand
  58861. * @returns the current updated Vector3
  58862. */
  58863. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  58864. /**
  58865. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  58866. * @param x defines the x coordinate of the operand
  58867. * @param y defines the y coordinate of the operand
  58868. * @param z defines the z coordinate of the operand
  58869. * @returns the current updated Vector3
  58870. */
  58871. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  58872. /**
  58873. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  58874. * @param x defines the x coordinate of the operand
  58875. * @param y defines the y coordinate of the operand
  58876. * @param z defines the z coordinate of the operand
  58877. * @returns the current updated Vector3
  58878. */
  58879. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  58880. /**
  58881. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  58882. * Check if is non uniform within a certain amount of decimal places to account for this
  58883. * @param epsilon the amount the values can differ
  58884. * @returns if the the vector is non uniform to a certain number of decimal places
  58885. */
  58886. isNonUniformWithinEpsilon(epsilon: number): boolean;
  58887. /**
  58888. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  58889. */
  58890. readonly isNonUniform: boolean;
  58891. /**
  58892. * Gets a new Vector3 from current Vector3 floored values
  58893. * @returns a new Vector3
  58894. */
  58895. floor(): Vector3;
  58896. /**
  58897. * Gets a new Vector3 from current Vector3 floored values
  58898. * @returns a new Vector3
  58899. */
  58900. fract(): Vector3;
  58901. /**
  58902. * Gets the length of the Vector3
  58903. * @returns the length of the Vecto3
  58904. */
  58905. length(): number;
  58906. /**
  58907. * Gets the squared length of the Vector3
  58908. * @returns squared length of the Vector3
  58909. */
  58910. lengthSquared(): number;
  58911. /**
  58912. * Normalize the current Vector3.
  58913. * Please note that this is an in place operation.
  58914. * @returns the current updated Vector3
  58915. */
  58916. normalize(): Vector3;
  58917. /**
  58918. * Reorders the x y z properties of the vector in place
  58919. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  58920. * @returns the current updated vector
  58921. */
  58922. reorderInPlace(order: string): this;
  58923. /**
  58924. * Rotates the vector around 0,0,0 by a quaternion
  58925. * @param quaternion the rotation quaternion
  58926. * @param result vector to store the result
  58927. * @returns the resulting vector
  58928. */
  58929. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  58930. /**
  58931. * Rotates a vector around a given point
  58932. * @param quaternion the rotation quaternion
  58933. * @param point the point to rotate around
  58934. * @param result vector to store the result
  58935. * @returns the resulting vector
  58936. */
  58937. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  58938. /**
  58939. * Normalize the current Vector3 with the given input length.
  58940. * Please note that this is an in place operation.
  58941. * @param len the length of the vector
  58942. * @returns the current updated Vector3
  58943. */
  58944. normalizeFromLength(len: number): Vector3;
  58945. /**
  58946. * Normalize the current Vector3 to a new vector
  58947. * @returns the new Vector3
  58948. */
  58949. normalizeToNew(): Vector3;
  58950. /**
  58951. * Normalize the current Vector3 to the reference
  58952. * @param reference define the Vector3 to update
  58953. * @returns the updated Vector3
  58954. */
  58955. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  58956. /**
  58957. * Creates a new Vector3 copied from the current Vector3
  58958. * @returns the new Vector3
  58959. */
  58960. clone(): Vector3;
  58961. /**
  58962. * Copies the given vector coordinates to the current Vector3 ones
  58963. * @param source defines the source Vector3
  58964. * @returns the current updated Vector3
  58965. */
  58966. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  58967. /**
  58968. * Copies the given floats to the current Vector3 coordinates
  58969. * @param x defines the x coordinate of the operand
  58970. * @param y defines the y coordinate of the operand
  58971. * @param z defines the z coordinate of the operand
  58972. * @returns the current updated Vector3
  58973. */
  58974. copyFromFloats(x: number, y: number, z: number): Vector3;
  58975. /**
  58976. * Copies the given floats to the current Vector3 coordinates
  58977. * @param x defines the x coordinate of the operand
  58978. * @param y defines the y coordinate of the operand
  58979. * @param z defines the z coordinate of the operand
  58980. * @returns the current updated Vector3
  58981. */
  58982. set(x: number, y: number, z: number): Vector3;
  58983. /**
  58984. * Copies the given float to the current Vector3 coordinates
  58985. * @param v defines the x, y and z coordinates of the operand
  58986. * @returns the current updated Vector3
  58987. */
  58988. setAll(v: number): Vector3;
  58989. /**
  58990. * Get the clip factor between two vectors
  58991. * @param vector0 defines the first operand
  58992. * @param vector1 defines the second operand
  58993. * @param axis defines the axis to use
  58994. * @param size defines the size along the axis
  58995. * @returns the clip factor
  58996. */
  58997. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  58998. /**
  58999. * Get angle between two vectors
  59000. * @param vector0 angle between vector0 and vector1
  59001. * @param vector1 angle between vector0 and vector1
  59002. * @param normal direction of the normal
  59003. * @return the angle between vector0 and vector1
  59004. */
  59005. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  59006. /**
  59007. * Returns a new Vector3 set from the index "offset" of the given array
  59008. * @param array defines the source array
  59009. * @param offset defines the offset in the source array
  59010. * @returns the new Vector3
  59011. */
  59012. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  59013. /**
  59014. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  59015. * This function is deprecated. Use FromArray instead
  59016. * @param array defines the source array
  59017. * @param offset defines the offset in the source array
  59018. * @returns the new Vector3
  59019. */
  59020. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  59021. /**
  59022. * Sets the given vector "result" with the element values from the index "offset" of the given array
  59023. * @param array defines the source array
  59024. * @param offset defines the offset in the source array
  59025. * @param result defines the Vector3 where to store the result
  59026. */
  59027. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  59028. /**
  59029. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  59030. * This function is deprecated. Use FromArrayToRef instead.
  59031. * @param array defines the source array
  59032. * @param offset defines the offset in the source array
  59033. * @param result defines the Vector3 where to store the result
  59034. */
  59035. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  59036. /**
  59037. * Sets the given vector "result" with the given floats.
  59038. * @param x defines the x coordinate of the source
  59039. * @param y defines the y coordinate of the source
  59040. * @param z defines the z coordinate of the source
  59041. * @param result defines the Vector3 where to store the result
  59042. */
  59043. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  59044. /**
  59045. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  59046. * @returns a new empty Vector3
  59047. */
  59048. static Zero(): Vector3;
  59049. /**
  59050. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  59051. * @returns a new unit Vector3
  59052. */
  59053. static One(): Vector3;
  59054. /**
  59055. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  59056. * @returns a new up Vector3
  59057. */
  59058. static Up(): Vector3;
  59059. /**
  59060. * Gets a up Vector3 that must not be updated
  59061. */
  59062. static readonly UpReadOnly: DeepImmutable<Vector3>;
  59063. /**
  59064. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  59065. * @returns a new down Vector3
  59066. */
  59067. static Down(): Vector3;
  59068. /**
  59069. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  59070. * @returns a new forward Vector3
  59071. */
  59072. static Forward(): Vector3;
  59073. /**
  59074. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  59075. * @returns a new forward Vector3
  59076. */
  59077. static Backward(): Vector3;
  59078. /**
  59079. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  59080. * @returns a new right Vector3
  59081. */
  59082. static Right(): Vector3;
  59083. /**
  59084. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  59085. * @returns a new left Vector3
  59086. */
  59087. static Left(): Vector3;
  59088. /**
  59089. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  59090. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  59091. * @param vector defines the Vector3 to transform
  59092. * @param transformation defines the transformation matrix
  59093. * @returns the transformed Vector3
  59094. */
  59095. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  59096. /**
  59097. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  59098. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  59099. * @param vector defines the Vector3 to transform
  59100. * @param transformation defines the transformation matrix
  59101. * @param result defines the Vector3 where to store the result
  59102. */
  59103. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  59104. /**
  59105. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  59106. * This method computes tranformed coordinates only, not transformed direction vectors
  59107. * @param x define the x coordinate of the source vector
  59108. * @param y define the y coordinate of the source vector
  59109. * @param z define the z coordinate of the source vector
  59110. * @param transformation defines the transformation matrix
  59111. * @param result defines the Vector3 where to store the result
  59112. */
  59113. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  59114. /**
  59115. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  59116. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  59117. * @param vector defines the Vector3 to transform
  59118. * @param transformation defines the transformation matrix
  59119. * @returns the new Vector3
  59120. */
  59121. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  59122. /**
  59123. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  59124. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  59125. * @param vector defines the Vector3 to transform
  59126. * @param transformation defines the transformation matrix
  59127. * @param result defines the Vector3 where to store the result
  59128. */
  59129. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  59130. /**
  59131. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  59132. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  59133. * @param x define the x coordinate of the source vector
  59134. * @param y define the y coordinate of the source vector
  59135. * @param z define the z coordinate of the source vector
  59136. * @param transformation defines the transformation matrix
  59137. * @param result defines the Vector3 where to store the result
  59138. */
  59139. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  59140. /**
  59141. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  59142. * @param value1 defines the first control point
  59143. * @param value2 defines the second control point
  59144. * @param value3 defines the third control point
  59145. * @param value4 defines the fourth control point
  59146. * @param amount defines the amount on the spline to use
  59147. * @returns the new Vector3
  59148. */
  59149. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  59150. /**
  59151. * 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"
  59152. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  59153. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  59154. * @param value defines the current value
  59155. * @param min defines the lower range value
  59156. * @param max defines the upper range value
  59157. * @returns the new Vector3
  59158. */
  59159. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  59160. /**
  59161. * 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"
  59162. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  59163. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  59164. * @param value defines the current value
  59165. * @param min defines the lower range value
  59166. * @param max defines the upper range value
  59167. * @param result defines the Vector3 where to store the result
  59168. */
  59169. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  59170. /**
  59171. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  59172. * @param value1 defines the first control point
  59173. * @param tangent1 defines the first tangent vector
  59174. * @param value2 defines the second control point
  59175. * @param tangent2 defines the second tangent vector
  59176. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  59177. * @returns the new Vector3
  59178. */
  59179. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  59180. /**
  59181. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  59182. * @param start defines the start value
  59183. * @param end defines the end value
  59184. * @param amount max defines amount between both (between 0 and 1)
  59185. * @returns the new Vector3
  59186. */
  59187. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  59188. /**
  59189. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  59190. * @param start defines the start value
  59191. * @param end defines the end value
  59192. * @param amount max defines amount between both (between 0 and 1)
  59193. * @param result defines the Vector3 where to store the result
  59194. */
  59195. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  59196. /**
  59197. * Returns the dot product (float) between the vectors "left" and "right"
  59198. * @param left defines the left operand
  59199. * @param right defines the right operand
  59200. * @returns the dot product
  59201. */
  59202. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  59203. /**
  59204. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  59205. * The cross product is then orthogonal to both "left" and "right"
  59206. * @param left defines the left operand
  59207. * @param right defines the right operand
  59208. * @returns the cross product
  59209. */
  59210. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  59211. /**
  59212. * Sets the given vector "result" with the cross product of "left" and "right"
  59213. * The cross product is then orthogonal to both "left" and "right"
  59214. * @param left defines the left operand
  59215. * @param right defines the right operand
  59216. * @param result defines the Vector3 where to store the result
  59217. */
  59218. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  59219. /**
  59220. * Returns a new Vector3 as the normalization of the given vector
  59221. * @param vector defines the Vector3 to normalize
  59222. * @returns the new Vector3
  59223. */
  59224. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  59225. /**
  59226. * Sets the given vector "result" with the normalization of the given first vector
  59227. * @param vector defines the Vector3 to normalize
  59228. * @param result defines the Vector3 where to store the result
  59229. */
  59230. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  59231. /**
  59232. * Project a Vector3 onto screen space
  59233. * @param vector defines the Vector3 to project
  59234. * @param world defines the world matrix to use
  59235. * @param transform defines the transform (view x projection) matrix to use
  59236. * @param viewport defines the screen viewport to use
  59237. * @returns the new Vector3
  59238. */
  59239. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  59240. /** @hidden */
  59241. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  59242. /**
  59243. * Unproject from screen space to object space
  59244. * @param source defines the screen space Vector3 to use
  59245. * @param viewportWidth defines the current width of the viewport
  59246. * @param viewportHeight defines the current height of the viewport
  59247. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  59248. * @param transform defines the transform (view x projection) matrix to use
  59249. * @returns the new Vector3
  59250. */
  59251. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  59252. /**
  59253. * Unproject from screen space to object space
  59254. * @param source defines the screen space Vector3 to use
  59255. * @param viewportWidth defines the current width of the viewport
  59256. * @param viewportHeight defines the current height of the viewport
  59257. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  59258. * @param view defines the view matrix to use
  59259. * @param projection defines the projection matrix to use
  59260. * @returns the new Vector3
  59261. */
  59262. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  59263. /**
  59264. * Unproject from screen space to object space
  59265. * @param source defines the screen space Vector3 to use
  59266. * @param viewportWidth defines the current width of the viewport
  59267. * @param viewportHeight defines the current height of the viewport
  59268. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  59269. * @param view defines the view matrix to use
  59270. * @param projection defines the projection matrix to use
  59271. * @param result defines the Vector3 where to store the result
  59272. */
  59273. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  59274. /**
  59275. * Unproject from screen space to object space
  59276. * @param sourceX defines the screen space x coordinate to use
  59277. * @param sourceY defines the screen space y coordinate to use
  59278. * @param sourceZ defines the screen space z coordinate to use
  59279. * @param viewportWidth defines the current width of the viewport
  59280. * @param viewportHeight defines the current height of the viewport
  59281. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  59282. * @param view defines the view matrix to use
  59283. * @param projection defines the projection matrix to use
  59284. * @param result defines the Vector3 where to store the result
  59285. */
  59286. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  59287. /**
  59288. * Gets the minimal coordinate values between two Vector3
  59289. * @param left defines the first operand
  59290. * @param right defines the second operand
  59291. * @returns the new Vector3
  59292. */
  59293. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  59294. /**
  59295. * Gets the maximal coordinate values between two Vector3
  59296. * @param left defines the first operand
  59297. * @param right defines the second operand
  59298. * @returns the new Vector3
  59299. */
  59300. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  59301. /**
  59302. * Returns the distance between the vectors "value1" and "value2"
  59303. * @param value1 defines the first operand
  59304. * @param value2 defines the second operand
  59305. * @returns the distance
  59306. */
  59307. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  59308. /**
  59309. * Returns the squared distance between the vectors "value1" and "value2"
  59310. * @param value1 defines the first operand
  59311. * @param value2 defines the second operand
  59312. * @returns the squared distance
  59313. */
  59314. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  59315. /**
  59316. * Returns a new Vector3 located at the center between "value1" and "value2"
  59317. * @param value1 defines the first operand
  59318. * @param value2 defines the second operand
  59319. * @returns the new Vector3
  59320. */
  59321. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  59322. /**
  59323. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  59324. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  59325. * to something in order to rotate it from its local system to the given target system
  59326. * Note: axis1, axis2 and axis3 are normalized during this operation
  59327. * @param axis1 defines the first axis
  59328. * @param axis2 defines the second axis
  59329. * @param axis3 defines the third axis
  59330. * @returns a new Vector3
  59331. */
  59332. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  59333. /**
  59334. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  59335. * @param axis1 defines the first axis
  59336. * @param axis2 defines the second axis
  59337. * @param axis3 defines the third axis
  59338. * @param ref defines the Vector3 where to store the result
  59339. */
  59340. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  59341. }
  59342. /**
  59343. * Vector4 class created for EulerAngle class conversion to Quaternion
  59344. */
  59345. export class Vector4 {
  59346. /** x value of the vector */
  59347. x: number;
  59348. /** y value of the vector */
  59349. y: number;
  59350. /** z value of the vector */
  59351. z: number;
  59352. /** w value of the vector */
  59353. w: number;
  59354. /**
  59355. * Creates a Vector4 object from the given floats.
  59356. * @param x x value of the vector
  59357. * @param y y value of the vector
  59358. * @param z z value of the vector
  59359. * @param w w value of the vector
  59360. */
  59361. constructor(
  59362. /** x value of the vector */
  59363. x: number,
  59364. /** y value of the vector */
  59365. y: number,
  59366. /** z value of the vector */
  59367. z: number,
  59368. /** w value of the vector */
  59369. w: number);
  59370. /**
  59371. * Returns the string with the Vector4 coordinates.
  59372. * @returns a string containing all the vector values
  59373. */
  59374. toString(): string;
  59375. /**
  59376. * Returns the string "Vector4".
  59377. * @returns "Vector4"
  59378. */
  59379. getClassName(): string;
  59380. /**
  59381. * Returns the Vector4 hash code.
  59382. * @returns a unique hash code
  59383. */
  59384. getHashCode(): number;
  59385. /**
  59386. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  59387. * @returns the resulting array
  59388. */
  59389. asArray(): number[];
  59390. /**
  59391. * Populates the given array from the given index with the Vector4 coordinates.
  59392. * @param array array to populate
  59393. * @param index index of the array to start at (default: 0)
  59394. * @returns the Vector4.
  59395. */
  59396. toArray(array: FloatArray, index?: number): Vector4;
  59397. /**
  59398. * Adds the given vector to the current Vector4.
  59399. * @param otherVector the vector to add
  59400. * @returns the updated Vector4.
  59401. */
  59402. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  59403. /**
  59404. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  59405. * @param otherVector the vector to add
  59406. * @returns the resulting vector
  59407. */
  59408. add(otherVector: DeepImmutable<Vector4>): Vector4;
  59409. /**
  59410. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  59411. * @param otherVector the vector to add
  59412. * @param result the vector to store the result
  59413. * @returns the current Vector4.
  59414. */
  59415. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  59416. /**
  59417. * Subtract in place the given vector from the current Vector4.
  59418. * @param otherVector the vector to subtract
  59419. * @returns the updated Vector4.
  59420. */
  59421. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  59422. /**
  59423. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  59424. * @param otherVector the vector to add
  59425. * @returns the new vector with the result
  59426. */
  59427. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  59428. /**
  59429. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  59430. * @param otherVector the vector to subtract
  59431. * @param result the vector to store the result
  59432. * @returns the current Vector4.
  59433. */
  59434. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  59435. /**
  59436. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  59437. */
  59438. /**
  59439. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  59440. * @param x value to subtract
  59441. * @param y value to subtract
  59442. * @param z value to subtract
  59443. * @param w value to subtract
  59444. * @returns new vector containing the result
  59445. */
  59446. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  59447. /**
  59448. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  59449. * @param x value to subtract
  59450. * @param y value to subtract
  59451. * @param z value to subtract
  59452. * @param w value to subtract
  59453. * @param result the vector to store the result in
  59454. * @returns the current Vector4.
  59455. */
  59456. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  59457. /**
  59458. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  59459. * @returns a new vector with the negated values
  59460. */
  59461. negate(): Vector4;
  59462. /**
  59463. * Multiplies the current Vector4 coordinates by scale (float).
  59464. * @param scale the number to scale with
  59465. * @returns the updated Vector4.
  59466. */
  59467. scaleInPlace(scale: number): Vector4;
  59468. /**
  59469. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  59470. * @param scale the number to scale with
  59471. * @returns a new vector with the result
  59472. */
  59473. scale(scale: number): Vector4;
  59474. /**
  59475. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  59476. * @param scale the number to scale with
  59477. * @param result a vector to store the result in
  59478. * @returns the current Vector4.
  59479. */
  59480. scaleToRef(scale: number, result: Vector4): Vector4;
  59481. /**
  59482. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  59483. * @param scale defines the scale factor
  59484. * @param result defines the Vector4 object where to store the result
  59485. * @returns the unmodified current Vector4
  59486. */
  59487. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  59488. /**
  59489. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  59490. * @param otherVector the vector to compare against
  59491. * @returns true if they are equal
  59492. */
  59493. equals(otherVector: DeepImmutable<Vector4>): boolean;
  59494. /**
  59495. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  59496. * @param otherVector vector to compare against
  59497. * @param epsilon (Default: very small number)
  59498. * @returns true if they are equal
  59499. */
  59500. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  59501. /**
  59502. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  59503. * @param x x value to compare against
  59504. * @param y y value to compare against
  59505. * @param z z value to compare against
  59506. * @param w w value to compare against
  59507. * @returns true if equal
  59508. */
  59509. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  59510. /**
  59511. * Multiplies in place the current Vector4 by the given one.
  59512. * @param otherVector vector to multiple with
  59513. * @returns the updated Vector4.
  59514. */
  59515. multiplyInPlace(otherVector: Vector4): Vector4;
  59516. /**
  59517. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  59518. * @param otherVector vector to multiple with
  59519. * @returns resulting new vector
  59520. */
  59521. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  59522. /**
  59523. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  59524. * @param otherVector vector to multiple with
  59525. * @param result vector to store the result
  59526. * @returns the current Vector4.
  59527. */
  59528. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  59529. /**
  59530. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  59531. * @param x x value multiply with
  59532. * @param y y value multiply with
  59533. * @param z z value multiply with
  59534. * @param w w value multiply with
  59535. * @returns resulting new vector
  59536. */
  59537. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  59538. /**
  59539. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  59540. * @param otherVector vector to devide with
  59541. * @returns resulting new vector
  59542. */
  59543. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  59544. /**
  59545. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  59546. * @param otherVector vector to devide with
  59547. * @param result vector to store the result
  59548. * @returns the current Vector4.
  59549. */
  59550. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  59551. /**
  59552. * Divides the current Vector3 coordinates by the given ones.
  59553. * @param otherVector vector to devide with
  59554. * @returns the updated Vector3.
  59555. */
  59556. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  59557. /**
  59558. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  59559. * @param other defines the second operand
  59560. * @returns the current updated Vector4
  59561. */
  59562. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  59563. /**
  59564. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  59565. * @param other defines the second operand
  59566. * @returns the current updated Vector4
  59567. */
  59568. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  59569. /**
  59570. * Gets a new Vector4 from current Vector4 floored values
  59571. * @returns a new Vector4
  59572. */
  59573. floor(): Vector4;
  59574. /**
  59575. * Gets a new Vector4 from current Vector3 floored values
  59576. * @returns a new Vector4
  59577. */
  59578. fract(): Vector4;
  59579. /**
  59580. * Returns the Vector4 length (float).
  59581. * @returns the length
  59582. */
  59583. length(): number;
  59584. /**
  59585. * Returns the Vector4 squared length (float).
  59586. * @returns the length squared
  59587. */
  59588. lengthSquared(): number;
  59589. /**
  59590. * Normalizes in place the Vector4.
  59591. * @returns the updated Vector4.
  59592. */
  59593. normalize(): Vector4;
  59594. /**
  59595. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  59596. * @returns this converted to a new vector3
  59597. */
  59598. toVector3(): Vector3;
  59599. /**
  59600. * Returns a new Vector4 copied from the current one.
  59601. * @returns the new cloned vector
  59602. */
  59603. clone(): Vector4;
  59604. /**
  59605. * Updates the current Vector4 with the given one coordinates.
  59606. * @param source the source vector to copy from
  59607. * @returns the updated Vector4.
  59608. */
  59609. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  59610. /**
  59611. * Updates the current Vector4 coordinates with the given floats.
  59612. * @param x float to copy from
  59613. * @param y float to copy from
  59614. * @param z float to copy from
  59615. * @param w float to copy from
  59616. * @returns the updated Vector4.
  59617. */
  59618. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  59619. /**
  59620. * Updates the current Vector4 coordinates with the given floats.
  59621. * @param x float to set from
  59622. * @param y float to set from
  59623. * @param z float to set from
  59624. * @param w float to set from
  59625. * @returns the updated Vector4.
  59626. */
  59627. set(x: number, y: number, z: number, w: number): Vector4;
  59628. /**
  59629. * Copies the given float to the current Vector3 coordinates
  59630. * @param v defines the x, y, z and w coordinates of the operand
  59631. * @returns the current updated Vector3
  59632. */
  59633. setAll(v: number): Vector4;
  59634. /**
  59635. * Returns a new Vector4 set from the starting index of the given array.
  59636. * @param array the array to pull values from
  59637. * @param offset the offset into the array to start at
  59638. * @returns the new vector
  59639. */
  59640. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  59641. /**
  59642. * Updates the given vector "result" from the starting index of the given array.
  59643. * @param array the array to pull values from
  59644. * @param offset the offset into the array to start at
  59645. * @param result the vector to store the result in
  59646. */
  59647. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  59648. /**
  59649. * Updates the given vector "result" from the starting index of the given Float32Array.
  59650. * @param array the array to pull values from
  59651. * @param offset the offset into the array to start at
  59652. * @param result the vector to store the result in
  59653. */
  59654. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  59655. /**
  59656. * Updates the given vector "result" coordinates from the given floats.
  59657. * @param x float to set from
  59658. * @param y float to set from
  59659. * @param z float to set from
  59660. * @param w float to set from
  59661. * @param result the vector to the floats in
  59662. */
  59663. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  59664. /**
  59665. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  59666. * @returns the new vector
  59667. */
  59668. static Zero(): Vector4;
  59669. /**
  59670. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  59671. * @returns the new vector
  59672. */
  59673. static One(): Vector4;
  59674. /**
  59675. * Returns a new normalized Vector4 from the given one.
  59676. * @param vector the vector to normalize
  59677. * @returns the vector
  59678. */
  59679. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  59680. /**
  59681. * Updates the given vector "result" from the normalization of the given one.
  59682. * @param vector the vector to normalize
  59683. * @param result the vector to store the result in
  59684. */
  59685. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  59686. /**
  59687. * Returns a vector with the minimum values from the left and right vectors
  59688. * @param left left vector to minimize
  59689. * @param right right vector to minimize
  59690. * @returns a new vector with the minimum of the left and right vector values
  59691. */
  59692. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  59693. /**
  59694. * Returns a vector with the maximum values from the left and right vectors
  59695. * @param left left vector to maximize
  59696. * @param right right vector to maximize
  59697. * @returns a new vector with the maximum of the left and right vector values
  59698. */
  59699. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  59700. /**
  59701. * Returns the distance (float) between the vectors "value1" and "value2".
  59702. * @param value1 value to calulate the distance between
  59703. * @param value2 value to calulate the distance between
  59704. * @return the distance between the two vectors
  59705. */
  59706. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  59707. /**
  59708. * Returns the squared distance (float) between the vectors "value1" and "value2".
  59709. * @param value1 value to calulate the distance between
  59710. * @param value2 value to calulate the distance between
  59711. * @return the distance between the two vectors squared
  59712. */
  59713. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  59714. /**
  59715. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  59716. * @param value1 value to calulate the center between
  59717. * @param value2 value to calulate the center between
  59718. * @return the center between the two vectors
  59719. */
  59720. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  59721. /**
  59722. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  59723. * This methods computes transformed normalized direction vectors only.
  59724. * @param vector the vector to transform
  59725. * @param transformation the transformation matrix to apply
  59726. * @returns the new vector
  59727. */
  59728. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  59729. /**
  59730. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  59731. * This methods computes transformed normalized direction vectors only.
  59732. * @param vector the vector to transform
  59733. * @param transformation the transformation matrix to apply
  59734. * @param result the vector to store the result in
  59735. */
  59736. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  59737. /**
  59738. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  59739. * This methods computes transformed normalized direction vectors only.
  59740. * @param x value to transform
  59741. * @param y value to transform
  59742. * @param z value to transform
  59743. * @param w value to transform
  59744. * @param transformation the transformation matrix to apply
  59745. * @param result the vector to store the results in
  59746. */
  59747. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  59748. /**
  59749. * Creates a new Vector4 from a Vector3
  59750. * @param source defines the source data
  59751. * @param w defines the 4th component (default is 0)
  59752. * @returns a new Vector4
  59753. */
  59754. static FromVector3(source: Vector3, w?: number): Vector4;
  59755. }
  59756. /**
  59757. * Interface for the size containing width and height
  59758. */
  59759. export interface ISize {
  59760. /**
  59761. * Width
  59762. */
  59763. width: number;
  59764. /**
  59765. * Heighht
  59766. */
  59767. height: number;
  59768. }
  59769. /**
  59770. * Size containing widht and height
  59771. */
  59772. export class Size implements ISize {
  59773. /**
  59774. * Width
  59775. */
  59776. width: number;
  59777. /**
  59778. * Height
  59779. */
  59780. height: number;
  59781. /**
  59782. * Creates a Size object from the given width and height (floats).
  59783. * @param width width of the new size
  59784. * @param height height of the new size
  59785. */
  59786. constructor(width: number, height: number);
  59787. /**
  59788. * Returns a string with the Size width and height
  59789. * @returns a string with the Size width and height
  59790. */
  59791. toString(): string;
  59792. /**
  59793. * "Size"
  59794. * @returns the string "Size"
  59795. */
  59796. getClassName(): string;
  59797. /**
  59798. * Returns the Size hash code.
  59799. * @returns a hash code for a unique width and height
  59800. */
  59801. getHashCode(): number;
  59802. /**
  59803. * Updates the current size from the given one.
  59804. * @param src the given size
  59805. */
  59806. copyFrom(src: Size): void;
  59807. /**
  59808. * Updates in place the current Size from the given floats.
  59809. * @param width width of the new size
  59810. * @param height height of the new size
  59811. * @returns the updated Size.
  59812. */
  59813. copyFromFloats(width: number, height: number): Size;
  59814. /**
  59815. * Updates in place the current Size from the given floats.
  59816. * @param width width to set
  59817. * @param height height to set
  59818. * @returns the updated Size.
  59819. */
  59820. set(width: number, height: number): Size;
  59821. /**
  59822. * Multiplies the width and height by numbers
  59823. * @param w factor to multiple the width by
  59824. * @param h factor to multiple the height by
  59825. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  59826. */
  59827. multiplyByFloats(w: number, h: number): Size;
  59828. /**
  59829. * Clones the size
  59830. * @returns a new Size copied from the given one.
  59831. */
  59832. clone(): Size;
  59833. /**
  59834. * True if the current Size and the given one width and height are strictly equal.
  59835. * @param other the other size to compare against
  59836. * @returns True if the current Size and the given one width and height are strictly equal.
  59837. */
  59838. equals(other: Size): boolean;
  59839. /**
  59840. * The surface of the Size : width * height (float).
  59841. */
  59842. readonly surface: number;
  59843. /**
  59844. * Create a new size of zero
  59845. * @returns a new Size set to (0.0, 0.0)
  59846. */
  59847. static Zero(): Size;
  59848. /**
  59849. * Sums the width and height of two sizes
  59850. * @param otherSize size to add to this size
  59851. * @returns a new Size set as the addition result of the current Size and the given one.
  59852. */
  59853. add(otherSize: Size): Size;
  59854. /**
  59855. * Subtracts the width and height of two
  59856. * @param otherSize size to subtract to this size
  59857. * @returns a new Size set as the subtraction result of the given one from the current Size.
  59858. */
  59859. subtract(otherSize: Size): Size;
  59860. /**
  59861. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  59862. * @param start starting size to lerp between
  59863. * @param end end size to lerp between
  59864. * @param amount amount to lerp between the start and end values
  59865. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  59866. */
  59867. static Lerp(start: Size, end: Size, amount: number): Size;
  59868. }
  59869. /**
  59870. * Class used to store quaternion data
  59871. * @see https://en.wikipedia.org/wiki/Quaternion
  59872. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  59873. */
  59874. export class Quaternion {
  59875. /** defines the first component (0 by default) */
  59876. x: number;
  59877. /** defines the second component (0 by default) */
  59878. y: number;
  59879. /** defines the third component (0 by default) */
  59880. z: number;
  59881. /** defines the fourth component (1.0 by default) */
  59882. w: number;
  59883. /**
  59884. * Creates a new Quaternion from the given floats
  59885. * @param x defines the first component (0 by default)
  59886. * @param y defines the second component (0 by default)
  59887. * @param z defines the third component (0 by default)
  59888. * @param w defines the fourth component (1.0 by default)
  59889. */
  59890. constructor(
  59891. /** defines the first component (0 by default) */
  59892. x?: number,
  59893. /** defines the second component (0 by default) */
  59894. y?: number,
  59895. /** defines the third component (0 by default) */
  59896. z?: number,
  59897. /** defines the fourth component (1.0 by default) */
  59898. w?: number);
  59899. /**
  59900. * Gets a string representation for the current quaternion
  59901. * @returns a string with the Quaternion coordinates
  59902. */
  59903. toString(): string;
  59904. /**
  59905. * Gets the class name of the quaternion
  59906. * @returns the string "Quaternion"
  59907. */
  59908. getClassName(): string;
  59909. /**
  59910. * Gets a hash code for this quaternion
  59911. * @returns the quaternion hash code
  59912. */
  59913. getHashCode(): number;
  59914. /**
  59915. * Copy the quaternion to an array
  59916. * @returns a new array populated with 4 elements from the quaternion coordinates
  59917. */
  59918. asArray(): number[];
  59919. /**
  59920. * Check if two quaternions are equals
  59921. * @param otherQuaternion defines the second operand
  59922. * @return true if the current quaternion and the given one coordinates are strictly equals
  59923. */
  59924. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  59925. /**
  59926. * Clone the current quaternion
  59927. * @returns a new quaternion copied from the current one
  59928. */
  59929. clone(): Quaternion;
  59930. /**
  59931. * Copy a quaternion to the current one
  59932. * @param other defines the other quaternion
  59933. * @returns the updated current quaternion
  59934. */
  59935. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  59936. /**
  59937. * Updates the current quaternion with the given float coordinates
  59938. * @param x defines the x coordinate
  59939. * @param y defines the y coordinate
  59940. * @param z defines the z coordinate
  59941. * @param w defines the w coordinate
  59942. * @returns the updated current quaternion
  59943. */
  59944. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  59945. /**
  59946. * Updates the current quaternion from the given float coordinates
  59947. * @param x defines the x coordinate
  59948. * @param y defines the y coordinate
  59949. * @param z defines the z coordinate
  59950. * @param w defines the w coordinate
  59951. * @returns the updated current quaternion
  59952. */
  59953. set(x: number, y: number, z: number, w: number): Quaternion;
  59954. /**
  59955. * Adds two quaternions
  59956. * @param other defines the second operand
  59957. * @returns a new quaternion as the addition result of the given one and the current quaternion
  59958. */
  59959. add(other: DeepImmutable<Quaternion>): Quaternion;
  59960. /**
  59961. * Add a quaternion to the current one
  59962. * @param other defines the quaternion to add
  59963. * @returns the current quaternion
  59964. */
  59965. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  59966. /**
  59967. * Subtract two quaternions
  59968. * @param other defines the second operand
  59969. * @returns a new quaternion as the subtraction result of the given one from the current one
  59970. */
  59971. subtract(other: Quaternion): Quaternion;
  59972. /**
  59973. * Multiplies the current quaternion by a scale factor
  59974. * @param value defines the scale factor
  59975. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  59976. */
  59977. scale(value: number): Quaternion;
  59978. /**
  59979. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  59980. * @param scale defines the scale factor
  59981. * @param result defines the Quaternion object where to store the result
  59982. * @returns the unmodified current quaternion
  59983. */
  59984. scaleToRef(scale: number, result: Quaternion): Quaternion;
  59985. /**
  59986. * Multiplies in place the current quaternion by a scale factor
  59987. * @param value defines the scale factor
  59988. * @returns the current modified quaternion
  59989. */
  59990. scaleInPlace(value: number): Quaternion;
  59991. /**
  59992. * Scale the current quaternion values by a factor and add the result to a given quaternion
  59993. * @param scale defines the scale factor
  59994. * @param result defines the Quaternion object where to store the result
  59995. * @returns the unmodified current quaternion
  59996. */
  59997. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  59998. /**
  59999. * Multiplies two quaternions
  60000. * @param q1 defines the second operand
  60001. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  60002. */
  60003. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  60004. /**
  60005. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  60006. * @param q1 defines the second operand
  60007. * @param result defines the target quaternion
  60008. * @returns the current quaternion
  60009. */
  60010. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  60011. /**
  60012. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  60013. * @param q1 defines the second operand
  60014. * @returns the currentupdated quaternion
  60015. */
  60016. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  60017. /**
  60018. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  60019. * @param ref defines the target quaternion
  60020. * @returns the current quaternion
  60021. */
  60022. conjugateToRef(ref: Quaternion): Quaternion;
  60023. /**
  60024. * Conjugates in place (1-q) the current quaternion
  60025. * @returns the current updated quaternion
  60026. */
  60027. conjugateInPlace(): Quaternion;
  60028. /**
  60029. * Conjugates in place (1-q) the current quaternion
  60030. * @returns a new quaternion
  60031. */
  60032. conjugate(): Quaternion;
  60033. /**
  60034. * Gets length of current quaternion
  60035. * @returns the quaternion length (float)
  60036. */
  60037. length(): number;
  60038. /**
  60039. * Normalize in place the current quaternion
  60040. * @returns the current updated quaternion
  60041. */
  60042. normalize(): Quaternion;
  60043. /**
  60044. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  60045. * @param order is a reserved parameter and is ignore for now
  60046. * @returns a new Vector3 containing the Euler angles
  60047. */
  60048. toEulerAngles(order?: string): Vector3;
  60049. /**
  60050. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  60051. * @param result defines the vector which will be filled with the Euler angles
  60052. * @param order is a reserved parameter and is ignore for now
  60053. * @returns the current unchanged quaternion
  60054. */
  60055. toEulerAnglesToRef(result: Vector3): Quaternion;
  60056. /**
  60057. * Updates the given rotation matrix with the current quaternion values
  60058. * @param result defines the target matrix
  60059. * @returns the current unchanged quaternion
  60060. */
  60061. toRotationMatrix(result: Matrix): Quaternion;
  60062. /**
  60063. * Updates the current quaternion from the given rotation matrix values
  60064. * @param matrix defines the source matrix
  60065. * @returns the current updated quaternion
  60066. */
  60067. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  60068. /**
  60069. * Creates a new quaternion from a rotation matrix
  60070. * @param matrix defines the source matrix
  60071. * @returns a new quaternion created from the given rotation matrix values
  60072. */
  60073. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  60074. /**
  60075. * Updates the given quaternion with the given rotation matrix values
  60076. * @param matrix defines the source matrix
  60077. * @param result defines the target quaternion
  60078. */
  60079. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  60080. /**
  60081. * Returns the dot product (float) between the quaternions "left" and "right"
  60082. * @param left defines the left operand
  60083. * @param right defines the right operand
  60084. * @returns the dot product
  60085. */
  60086. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  60087. /**
  60088. * Checks if the two quaternions are close to each other
  60089. * @param quat0 defines the first quaternion to check
  60090. * @param quat1 defines the second quaternion to check
  60091. * @returns true if the two quaternions are close to each other
  60092. */
  60093. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  60094. /**
  60095. * Creates an empty quaternion
  60096. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  60097. */
  60098. static Zero(): Quaternion;
  60099. /**
  60100. * Inverse a given quaternion
  60101. * @param q defines the source quaternion
  60102. * @returns a new quaternion as the inverted current quaternion
  60103. */
  60104. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  60105. /**
  60106. * Inverse a given quaternion
  60107. * @param q defines the source quaternion
  60108. * @param result the quaternion the result will be stored in
  60109. * @returns the result quaternion
  60110. */
  60111. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  60112. /**
  60113. * Creates an identity quaternion
  60114. * @returns the identity quaternion
  60115. */
  60116. static Identity(): Quaternion;
  60117. /**
  60118. * Gets a boolean indicating if the given quaternion is identity
  60119. * @param quaternion defines the quaternion to check
  60120. * @returns true if the quaternion is identity
  60121. */
  60122. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  60123. /**
  60124. * Creates a quaternion from a rotation around an axis
  60125. * @param axis defines the axis to use
  60126. * @param angle defines the angle to use
  60127. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  60128. */
  60129. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  60130. /**
  60131. * Creates a rotation around an axis and stores it into the given quaternion
  60132. * @param axis defines the axis to use
  60133. * @param angle defines the angle to use
  60134. * @param result defines the target quaternion
  60135. * @returns the target quaternion
  60136. */
  60137. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  60138. /**
  60139. * Creates a new quaternion from data stored into an array
  60140. * @param array defines the data source
  60141. * @param offset defines the offset in the source array where the data starts
  60142. * @returns a new quaternion
  60143. */
  60144. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  60145. /**
  60146. * Create a quaternion from Euler rotation angles
  60147. * @param x Pitch
  60148. * @param y Yaw
  60149. * @param z Roll
  60150. * @returns the new Quaternion
  60151. */
  60152. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  60153. /**
  60154. * Updates a quaternion from Euler rotation angles
  60155. * @param x Pitch
  60156. * @param y Yaw
  60157. * @param z Roll
  60158. * @param result the quaternion to store the result
  60159. * @returns the updated quaternion
  60160. */
  60161. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  60162. /**
  60163. * Create a quaternion from Euler rotation vector
  60164. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  60165. * @returns the new Quaternion
  60166. */
  60167. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  60168. /**
  60169. * Updates a quaternion from Euler rotation vector
  60170. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  60171. * @param result the quaternion to store the result
  60172. * @returns the updated quaternion
  60173. */
  60174. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  60175. /**
  60176. * Creates a new quaternion from the given Euler float angles (y, x, z)
  60177. * @param yaw defines the rotation around Y axis
  60178. * @param pitch defines the rotation around X axis
  60179. * @param roll defines the rotation around Z axis
  60180. * @returns the new quaternion
  60181. */
  60182. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  60183. /**
  60184. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  60185. * @param yaw defines the rotation around Y axis
  60186. * @param pitch defines the rotation around X axis
  60187. * @param roll defines the rotation around Z axis
  60188. * @param result defines the target quaternion
  60189. */
  60190. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  60191. /**
  60192. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  60193. * @param alpha defines the rotation around first axis
  60194. * @param beta defines the rotation around second axis
  60195. * @param gamma defines the rotation around third axis
  60196. * @returns the new quaternion
  60197. */
  60198. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  60199. /**
  60200. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  60201. * @param alpha defines the rotation around first axis
  60202. * @param beta defines the rotation around second axis
  60203. * @param gamma defines the rotation around third axis
  60204. * @param result defines the target quaternion
  60205. */
  60206. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  60207. /**
  60208. * 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)
  60209. * @param axis1 defines the first axis
  60210. * @param axis2 defines the second axis
  60211. * @param axis3 defines the third axis
  60212. * @returns the new quaternion
  60213. */
  60214. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  60215. /**
  60216. * 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
  60217. * @param axis1 defines the first axis
  60218. * @param axis2 defines the second axis
  60219. * @param axis3 defines the third axis
  60220. * @param ref defines the target quaternion
  60221. */
  60222. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  60223. /**
  60224. * Interpolates between two quaternions
  60225. * @param left defines first quaternion
  60226. * @param right defines second quaternion
  60227. * @param amount defines the gradient to use
  60228. * @returns the new interpolated quaternion
  60229. */
  60230. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  60231. /**
  60232. * Interpolates between two quaternions and stores it into a target quaternion
  60233. * @param left defines first quaternion
  60234. * @param right defines second quaternion
  60235. * @param amount defines the gradient to use
  60236. * @param result defines the target quaternion
  60237. */
  60238. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  60239. /**
  60240. * Interpolate between two quaternions using Hermite interpolation
  60241. * @param value1 defines first quaternion
  60242. * @param tangent1 defines the incoming tangent
  60243. * @param value2 defines second quaternion
  60244. * @param tangent2 defines the outgoing tangent
  60245. * @param amount defines the target quaternion
  60246. * @returns the new interpolated quaternion
  60247. */
  60248. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  60249. }
  60250. /**
  60251. * Class used to store matrix data (4x4)
  60252. */
  60253. export class Matrix {
  60254. private static _updateFlagSeed;
  60255. private static _identityReadOnly;
  60256. private _isIdentity;
  60257. private _isIdentityDirty;
  60258. private _isIdentity3x2;
  60259. private _isIdentity3x2Dirty;
  60260. /**
  60261. * Gets the update flag of the matrix which is an unique number for the matrix.
  60262. * It will be incremented every time the matrix data change.
  60263. * You can use it to speed the comparison between two versions of the same matrix.
  60264. */
  60265. updateFlag: number;
  60266. private readonly _m;
  60267. /**
  60268. * Gets the internal data of the matrix
  60269. */
  60270. readonly m: DeepImmutable<Float32Array>;
  60271. /** @hidden */
  60272. _markAsUpdated(): void;
  60273. /** @hidden */
  60274. private _updateIdentityStatus;
  60275. /**
  60276. * Creates an empty matrix (filled with zeros)
  60277. */
  60278. constructor();
  60279. /**
  60280. * Check if the current matrix is identity
  60281. * @returns true is the matrix is the identity matrix
  60282. */
  60283. isIdentity(): boolean;
  60284. /**
  60285. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  60286. * @returns true is the matrix is the identity matrix
  60287. */
  60288. isIdentityAs3x2(): boolean;
  60289. /**
  60290. * Gets the determinant of the matrix
  60291. * @returns the matrix determinant
  60292. */
  60293. determinant(): number;
  60294. /**
  60295. * Returns the matrix as a Float32Array
  60296. * @returns the matrix underlying array
  60297. */
  60298. toArray(): DeepImmutable<Float32Array>;
  60299. /**
  60300. * Returns the matrix as a Float32Array
  60301. * @returns the matrix underlying array.
  60302. */
  60303. asArray(): DeepImmutable<Float32Array>;
  60304. /**
  60305. * Inverts the current matrix in place
  60306. * @returns the current inverted matrix
  60307. */
  60308. invert(): Matrix;
  60309. /**
  60310. * Sets all the matrix elements to zero
  60311. * @returns the current matrix
  60312. */
  60313. reset(): Matrix;
  60314. /**
  60315. * Adds the current matrix with a second one
  60316. * @param other defines the matrix to add
  60317. * @returns a new matrix as the addition of the current matrix and the given one
  60318. */
  60319. add(other: DeepImmutable<Matrix>): Matrix;
  60320. /**
  60321. * Sets the given matrix "result" to the addition of the current matrix and the given one
  60322. * @param other defines the matrix to add
  60323. * @param result defines the target matrix
  60324. * @returns the current matrix
  60325. */
  60326. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  60327. /**
  60328. * Adds in place the given matrix to the current matrix
  60329. * @param other defines the second operand
  60330. * @returns the current updated matrix
  60331. */
  60332. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  60333. /**
  60334. * Sets the given matrix to the current inverted Matrix
  60335. * @param other defines the target matrix
  60336. * @returns the unmodified current matrix
  60337. */
  60338. invertToRef(other: Matrix): Matrix;
  60339. /**
  60340. * add a value at the specified position in the current Matrix
  60341. * @param index the index of the value within the matrix. between 0 and 15.
  60342. * @param value the value to be added
  60343. * @returns the current updated matrix
  60344. */
  60345. addAtIndex(index: number, value: number): Matrix;
  60346. /**
  60347. * mutiply the specified position in the current Matrix by a value
  60348. * @param index the index of the value within the matrix. between 0 and 15.
  60349. * @param value the value to be added
  60350. * @returns the current updated matrix
  60351. */
  60352. multiplyAtIndex(index: number, value: number): Matrix;
  60353. /**
  60354. * Inserts the translation vector (using 3 floats) in the current matrix
  60355. * @param x defines the 1st component of the translation
  60356. * @param y defines the 2nd component of the translation
  60357. * @param z defines the 3rd component of the translation
  60358. * @returns the current updated matrix
  60359. */
  60360. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  60361. /**
  60362. * Inserts the translation vector in the current matrix
  60363. * @param vector3 defines the translation to insert
  60364. * @returns the current updated matrix
  60365. */
  60366. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  60367. /**
  60368. * Gets the translation value of the current matrix
  60369. * @returns a new Vector3 as the extracted translation from the matrix
  60370. */
  60371. getTranslation(): Vector3;
  60372. /**
  60373. * Fill a Vector3 with the extracted translation from the matrix
  60374. * @param result defines the Vector3 where to store the translation
  60375. * @returns the current matrix
  60376. */
  60377. getTranslationToRef(result: Vector3): Matrix;
  60378. /**
  60379. * Remove rotation and scaling part from the matrix
  60380. * @returns the updated matrix
  60381. */
  60382. removeRotationAndScaling(): Matrix;
  60383. /**
  60384. * Multiply two matrices
  60385. * @param other defines the second operand
  60386. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  60387. */
  60388. multiply(other: DeepImmutable<Matrix>): Matrix;
  60389. /**
  60390. * Copy the current matrix from the given one
  60391. * @param other defines the source matrix
  60392. * @returns the current updated matrix
  60393. */
  60394. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  60395. /**
  60396. * Populates the given array from the starting index with the current matrix values
  60397. * @param array defines the target array
  60398. * @param offset defines the offset in the target array where to start storing values
  60399. * @returns the current matrix
  60400. */
  60401. copyToArray(array: Float32Array, offset?: number): Matrix;
  60402. /**
  60403. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  60404. * @param other defines the second operand
  60405. * @param result defines the matrix where to store the multiplication
  60406. * @returns the current matrix
  60407. */
  60408. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  60409. /**
  60410. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  60411. * @param other defines the second operand
  60412. * @param result defines the array where to store the multiplication
  60413. * @param offset defines the offset in the target array where to start storing values
  60414. * @returns the current matrix
  60415. */
  60416. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  60417. /**
  60418. * Check equality between this matrix and a second one
  60419. * @param value defines the second matrix to compare
  60420. * @returns true is the current matrix and the given one values are strictly equal
  60421. */
  60422. equals(value: DeepImmutable<Matrix>): boolean;
  60423. /**
  60424. * Clone the current matrix
  60425. * @returns a new matrix from the current matrix
  60426. */
  60427. clone(): Matrix;
  60428. /**
  60429. * Returns the name of the current matrix class
  60430. * @returns the string "Matrix"
  60431. */
  60432. getClassName(): string;
  60433. /**
  60434. * Gets the hash code of the current matrix
  60435. * @returns the hash code
  60436. */
  60437. getHashCode(): number;
  60438. /**
  60439. * Decomposes the current Matrix into a translation, rotation and scaling components
  60440. * @param scale defines the scale vector3 given as a reference to update
  60441. * @param rotation defines the rotation quaternion given as a reference to update
  60442. * @param translation defines the translation vector3 given as a reference to update
  60443. * @returns true if operation was successful
  60444. */
  60445. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  60446. /**
  60447. * Gets specific row of the matrix
  60448. * @param index defines the number of the row to get
  60449. * @returns the index-th row of the current matrix as a new Vector4
  60450. */
  60451. getRow(index: number): Nullable<Vector4>;
  60452. /**
  60453. * Sets the index-th row of the current matrix to the vector4 values
  60454. * @param index defines the number of the row to set
  60455. * @param row defines the target vector4
  60456. * @returns the updated current matrix
  60457. */
  60458. setRow(index: number, row: Vector4): Matrix;
  60459. /**
  60460. * Compute the transpose of the matrix
  60461. * @returns the new transposed matrix
  60462. */
  60463. transpose(): Matrix;
  60464. /**
  60465. * Compute the transpose of the matrix and store it in a given matrix
  60466. * @param result defines the target matrix
  60467. * @returns the current matrix
  60468. */
  60469. transposeToRef(result: Matrix): Matrix;
  60470. /**
  60471. * Sets the index-th row of the current matrix with the given 4 x float values
  60472. * @param index defines the row index
  60473. * @param x defines the x component to set
  60474. * @param y defines the y component to set
  60475. * @param z defines the z component to set
  60476. * @param w defines the w component to set
  60477. * @returns the updated current matrix
  60478. */
  60479. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  60480. /**
  60481. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  60482. * @param scale defines the scale factor
  60483. * @returns a new matrix
  60484. */
  60485. scale(scale: number): Matrix;
  60486. /**
  60487. * Scale the current matrix values by a factor to a given result matrix
  60488. * @param scale defines the scale factor
  60489. * @param result defines the matrix to store the result
  60490. * @returns the current matrix
  60491. */
  60492. scaleToRef(scale: number, result: Matrix): Matrix;
  60493. /**
  60494. * Scale the current matrix values by a factor and add the result to a given matrix
  60495. * @param scale defines the scale factor
  60496. * @param result defines the Matrix to store the result
  60497. * @returns the current matrix
  60498. */
  60499. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  60500. /**
  60501. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  60502. * @param ref matrix to store the result
  60503. */
  60504. toNormalMatrix(ref: Matrix): void;
  60505. /**
  60506. * Gets only rotation part of the current matrix
  60507. * @returns a new matrix sets to the extracted rotation matrix from the current one
  60508. */
  60509. getRotationMatrix(): Matrix;
  60510. /**
  60511. * Extracts the rotation matrix from the current one and sets it as the given "result"
  60512. * @param result defines the target matrix to store data to
  60513. * @returns the current matrix
  60514. */
  60515. getRotationMatrixToRef(result: Matrix): Matrix;
  60516. /**
  60517. * Toggles model matrix from being right handed to left handed in place and vice versa
  60518. */
  60519. toggleModelMatrixHandInPlace(): void;
  60520. /**
  60521. * Toggles projection matrix from being right handed to left handed in place and vice versa
  60522. */
  60523. toggleProjectionMatrixHandInPlace(): void;
  60524. /**
  60525. * Creates a matrix from an array
  60526. * @param array defines the source array
  60527. * @param offset defines an offset in the source array
  60528. * @returns a new Matrix set from the starting index of the given array
  60529. */
  60530. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  60531. /**
  60532. * Copy the content of an array into a given matrix
  60533. * @param array defines the source array
  60534. * @param offset defines an offset in the source array
  60535. * @param result defines the target matrix
  60536. */
  60537. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  60538. /**
  60539. * Stores an array into a matrix after having multiplied each component by a given factor
  60540. * @param array defines the source array
  60541. * @param offset defines the offset in the source array
  60542. * @param scale defines the scaling factor
  60543. * @param result defines the target matrix
  60544. */
  60545. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  60546. /**
  60547. * Gets an identity matrix that must not be updated
  60548. */
  60549. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  60550. /**
  60551. * Stores a list of values (16) inside a given matrix
  60552. * @param initialM11 defines 1st value of 1st row
  60553. * @param initialM12 defines 2nd value of 1st row
  60554. * @param initialM13 defines 3rd value of 1st row
  60555. * @param initialM14 defines 4th value of 1st row
  60556. * @param initialM21 defines 1st value of 2nd row
  60557. * @param initialM22 defines 2nd value of 2nd row
  60558. * @param initialM23 defines 3rd value of 2nd row
  60559. * @param initialM24 defines 4th value of 2nd row
  60560. * @param initialM31 defines 1st value of 3rd row
  60561. * @param initialM32 defines 2nd value of 3rd row
  60562. * @param initialM33 defines 3rd value of 3rd row
  60563. * @param initialM34 defines 4th value of 3rd row
  60564. * @param initialM41 defines 1st value of 4th row
  60565. * @param initialM42 defines 2nd value of 4th row
  60566. * @param initialM43 defines 3rd value of 4th row
  60567. * @param initialM44 defines 4th value of 4th row
  60568. * @param result defines the target matrix
  60569. */
  60570. 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;
  60571. /**
  60572. * Creates new matrix from a list of values (16)
  60573. * @param initialM11 defines 1st value of 1st row
  60574. * @param initialM12 defines 2nd value of 1st row
  60575. * @param initialM13 defines 3rd value of 1st row
  60576. * @param initialM14 defines 4th value of 1st row
  60577. * @param initialM21 defines 1st value of 2nd row
  60578. * @param initialM22 defines 2nd value of 2nd row
  60579. * @param initialM23 defines 3rd value of 2nd row
  60580. * @param initialM24 defines 4th value of 2nd row
  60581. * @param initialM31 defines 1st value of 3rd row
  60582. * @param initialM32 defines 2nd value of 3rd row
  60583. * @param initialM33 defines 3rd value of 3rd row
  60584. * @param initialM34 defines 4th value of 3rd row
  60585. * @param initialM41 defines 1st value of 4th row
  60586. * @param initialM42 defines 2nd value of 4th row
  60587. * @param initialM43 defines 3rd value of 4th row
  60588. * @param initialM44 defines 4th value of 4th row
  60589. * @returns the new matrix
  60590. */
  60591. 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;
  60592. /**
  60593. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  60594. * @param scale defines the scale vector3
  60595. * @param rotation defines the rotation quaternion
  60596. * @param translation defines the translation vector3
  60597. * @returns a new matrix
  60598. */
  60599. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  60600. /**
  60601. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  60602. * @param scale defines the scale vector3
  60603. * @param rotation defines the rotation quaternion
  60604. * @param translation defines the translation vector3
  60605. * @param result defines the target matrix
  60606. */
  60607. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  60608. /**
  60609. * Creates a new identity matrix
  60610. * @returns a new identity matrix
  60611. */
  60612. static Identity(): Matrix;
  60613. /**
  60614. * Creates a new identity matrix and stores the result in a given matrix
  60615. * @param result defines the target matrix
  60616. */
  60617. static IdentityToRef(result: Matrix): void;
  60618. /**
  60619. * Creates a new zero matrix
  60620. * @returns a new zero matrix
  60621. */
  60622. static Zero(): Matrix;
  60623. /**
  60624. * Creates a new rotation matrix for "angle" radians around the X axis
  60625. * @param angle defines the angle (in radians) to use
  60626. * @return the new matrix
  60627. */
  60628. static RotationX(angle: number): Matrix;
  60629. /**
  60630. * Creates a new matrix as the invert of a given matrix
  60631. * @param source defines the source matrix
  60632. * @returns the new matrix
  60633. */
  60634. static Invert(source: DeepImmutable<Matrix>): Matrix;
  60635. /**
  60636. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  60637. * @param angle defines the angle (in radians) to use
  60638. * @param result defines the target matrix
  60639. */
  60640. static RotationXToRef(angle: number, result: Matrix): void;
  60641. /**
  60642. * Creates a new rotation matrix for "angle" radians around the Y axis
  60643. * @param angle defines the angle (in radians) to use
  60644. * @return the new matrix
  60645. */
  60646. static RotationY(angle: number): Matrix;
  60647. /**
  60648. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  60649. * @param angle defines the angle (in radians) to use
  60650. * @param result defines the target matrix
  60651. */
  60652. static RotationYToRef(angle: number, result: Matrix): void;
  60653. /**
  60654. * Creates a new rotation matrix for "angle" radians around the Z axis
  60655. * @param angle defines the angle (in radians) to use
  60656. * @return the new matrix
  60657. */
  60658. static RotationZ(angle: number): Matrix;
  60659. /**
  60660. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  60661. * @param angle defines the angle (in radians) to use
  60662. * @param result defines the target matrix
  60663. */
  60664. static RotationZToRef(angle: number, result: Matrix): void;
  60665. /**
  60666. * Creates a new rotation matrix for "angle" radians around the given axis
  60667. * @param axis defines the axis to use
  60668. * @param angle defines the angle (in radians) to use
  60669. * @return the new matrix
  60670. */
  60671. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  60672. /**
  60673. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  60674. * @param axis defines the axis to use
  60675. * @param angle defines the angle (in radians) to use
  60676. * @param result defines the target matrix
  60677. */
  60678. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  60679. /**
  60680. * Creates a rotation matrix
  60681. * @param yaw defines the yaw angle in radians (Y axis)
  60682. * @param pitch defines the pitch angle in radians (X axis)
  60683. * @param roll defines the roll angle in radians (X axis)
  60684. * @returns the new rotation matrix
  60685. */
  60686. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  60687. /**
  60688. * Creates a rotation matrix and stores it in a given matrix
  60689. * @param yaw defines the yaw angle in radians (Y axis)
  60690. * @param pitch defines the pitch angle in radians (X axis)
  60691. * @param roll defines the roll angle in radians (X axis)
  60692. * @param result defines the target matrix
  60693. */
  60694. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  60695. /**
  60696. * Creates a scaling matrix
  60697. * @param x defines the scale factor on X axis
  60698. * @param y defines the scale factor on Y axis
  60699. * @param z defines the scale factor on Z axis
  60700. * @returns the new matrix
  60701. */
  60702. static Scaling(x: number, y: number, z: number): Matrix;
  60703. /**
  60704. * Creates a scaling matrix and stores it in a given matrix
  60705. * @param x defines the scale factor on X axis
  60706. * @param y defines the scale factor on Y axis
  60707. * @param z defines the scale factor on Z axis
  60708. * @param result defines the target matrix
  60709. */
  60710. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  60711. /**
  60712. * Creates a translation matrix
  60713. * @param x defines the translation on X axis
  60714. * @param y defines the translation on Y axis
  60715. * @param z defines the translationon Z axis
  60716. * @returns the new matrix
  60717. */
  60718. static Translation(x: number, y: number, z: number): Matrix;
  60719. /**
  60720. * Creates a translation matrix and stores it in a given matrix
  60721. * @param x defines the translation on X axis
  60722. * @param y defines the translation on Y axis
  60723. * @param z defines the translationon Z axis
  60724. * @param result defines the target matrix
  60725. */
  60726. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  60727. /**
  60728. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  60729. * @param startValue defines the start value
  60730. * @param endValue defines the end value
  60731. * @param gradient defines the gradient factor
  60732. * @returns the new matrix
  60733. */
  60734. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  60735. /**
  60736. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  60737. * @param startValue defines the start value
  60738. * @param endValue defines the end value
  60739. * @param gradient defines the gradient factor
  60740. * @param result defines the Matrix object where to store data
  60741. */
  60742. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  60743. /**
  60744. * Builds a new matrix whose values are computed by:
  60745. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  60746. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  60747. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  60748. * @param startValue defines the first matrix
  60749. * @param endValue defines the second matrix
  60750. * @param gradient defines the gradient between the two matrices
  60751. * @returns the new matrix
  60752. */
  60753. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  60754. /**
  60755. * Update a matrix to values which are computed by:
  60756. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  60757. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  60758. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  60759. * @param startValue defines the first matrix
  60760. * @param endValue defines the second matrix
  60761. * @param gradient defines the gradient between the two matrices
  60762. * @param result defines the target matrix
  60763. */
  60764. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  60765. /**
  60766. * 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"
  60767. * This function works in left handed mode
  60768. * @param eye defines the final position of the entity
  60769. * @param target defines where the entity should look at
  60770. * @param up defines the up vector for the entity
  60771. * @returns the new matrix
  60772. */
  60773. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  60774. /**
  60775. * 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".
  60776. * This function works in left handed mode
  60777. * @param eye defines the final position of the entity
  60778. * @param target defines where the entity should look at
  60779. * @param up defines the up vector for the entity
  60780. * @param result defines the target matrix
  60781. */
  60782. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  60783. /**
  60784. * 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"
  60785. * This function works in right handed mode
  60786. * @param eye defines the final position of the entity
  60787. * @param target defines where the entity should look at
  60788. * @param up defines the up vector for the entity
  60789. * @returns the new matrix
  60790. */
  60791. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  60792. /**
  60793. * 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".
  60794. * This function works in right handed mode
  60795. * @param eye defines the final position of the entity
  60796. * @param target defines where the entity should look at
  60797. * @param up defines the up vector for the entity
  60798. * @param result defines the target matrix
  60799. */
  60800. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  60801. /**
  60802. * Create a left-handed orthographic projection matrix
  60803. * @param width defines the viewport width
  60804. * @param height defines the viewport height
  60805. * @param znear defines the near clip plane
  60806. * @param zfar defines the far clip plane
  60807. * @returns a new matrix as a left-handed orthographic projection matrix
  60808. */
  60809. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  60810. /**
  60811. * Store a left-handed orthographic projection to a given matrix
  60812. * @param width defines the viewport width
  60813. * @param height defines the viewport height
  60814. * @param znear defines the near clip plane
  60815. * @param zfar defines the far clip plane
  60816. * @param result defines the target matrix
  60817. */
  60818. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  60819. /**
  60820. * Create a left-handed orthographic projection matrix
  60821. * @param left defines the viewport left coordinate
  60822. * @param right defines the viewport right coordinate
  60823. * @param bottom defines the viewport bottom coordinate
  60824. * @param top defines the viewport top coordinate
  60825. * @param znear defines the near clip plane
  60826. * @param zfar defines the far clip plane
  60827. * @returns a new matrix as a left-handed orthographic projection matrix
  60828. */
  60829. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  60830. /**
  60831. * Stores a left-handed orthographic projection into a given matrix
  60832. * @param left defines the viewport left coordinate
  60833. * @param right defines the viewport right coordinate
  60834. * @param bottom defines the viewport bottom coordinate
  60835. * @param top defines the viewport top coordinate
  60836. * @param znear defines the near clip plane
  60837. * @param zfar defines the far clip plane
  60838. * @param result defines the target matrix
  60839. */
  60840. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  60841. /**
  60842. * Creates a right-handed orthographic projection matrix
  60843. * @param left defines the viewport left coordinate
  60844. * @param right defines the viewport right coordinate
  60845. * @param bottom defines the viewport bottom coordinate
  60846. * @param top defines the viewport top coordinate
  60847. * @param znear defines the near clip plane
  60848. * @param zfar defines the far clip plane
  60849. * @returns a new matrix as a right-handed orthographic projection matrix
  60850. */
  60851. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  60852. /**
  60853. * Stores a right-handed orthographic projection into a given matrix
  60854. * @param left defines the viewport left coordinate
  60855. * @param right defines the viewport right coordinate
  60856. * @param bottom defines the viewport bottom coordinate
  60857. * @param top defines the viewport top coordinate
  60858. * @param znear defines the near clip plane
  60859. * @param zfar defines the far clip plane
  60860. * @param result defines the target matrix
  60861. */
  60862. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  60863. /**
  60864. * Creates a left-handed perspective projection matrix
  60865. * @param width defines the viewport width
  60866. * @param height defines the viewport height
  60867. * @param znear defines the near clip plane
  60868. * @param zfar defines the far clip plane
  60869. * @returns a new matrix as a left-handed perspective projection matrix
  60870. */
  60871. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  60872. /**
  60873. * Creates a left-handed perspective projection matrix
  60874. * @param fov defines the horizontal field of view
  60875. * @param aspect defines the aspect ratio
  60876. * @param znear defines the near clip plane
  60877. * @param zfar defines the far clip plane
  60878. * @returns a new matrix as a left-handed perspective projection matrix
  60879. */
  60880. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  60881. /**
  60882. * Stores a left-handed perspective projection into a given matrix
  60883. * @param fov defines the horizontal field of view
  60884. * @param aspect defines the aspect ratio
  60885. * @param znear defines the near clip plane
  60886. * @param zfar defines the far clip plane
  60887. * @param result defines the target matrix
  60888. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  60889. */
  60890. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  60891. /**
  60892. * Creates a right-handed perspective projection matrix
  60893. * @param fov defines the horizontal field of view
  60894. * @param aspect defines the aspect ratio
  60895. * @param znear defines the near clip plane
  60896. * @param zfar defines the far clip plane
  60897. * @returns a new matrix as a right-handed perspective projection matrix
  60898. */
  60899. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  60900. /**
  60901. * Stores a right-handed perspective projection into a given matrix
  60902. * @param fov defines the horizontal field of view
  60903. * @param aspect defines the aspect ratio
  60904. * @param znear defines the near clip plane
  60905. * @param zfar defines the far clip plane
  60906. * @param result defines the target matrix
  60907. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  60908. */
  60909. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  60910. /**
  60911. * Stores a perspective projection for WebVR info a given matrix
  60912. * @param fov defines the field of view
  60913. * @param znear defines the near clip plane
  60914. * @param zfar defines the far clip plane
  60915. * @param result defines the target matrix
  60916. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  60917. */
  60918. static PerspectiveFovWebVRToRef(fov: {
  60919. upDegrees: number;
  60920. downDegrees: number;
  60921. leftDegrees: number;
  60922. rightDegrees: number;
  60923. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  60924. /**
  60925. * Computes a complete transformation matrix
  60926. * @param viewport defines the viewport to use
  60927. * @param world defines the world matrix
  60928. * @param view defines the view matrix
  60929. * @param projection defines the projection matrix
  60930. * @param zmin defines the near clip plane
  60931. * @param zmax defines the far clip plane
  60932. * @returns the transformation matrix
  60933. */
  60934. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  60935. /**
  60936. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  60937. * @param matrix defines the matrix to use
  60938. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  60939. */
  60940. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  60941. /**
  60942. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  60943. * @param matrix defines the matrix to use
  60944. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  60945. */
  60946. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  60947. /**
  60948. * Compute the transpose of a given matrix
  60949. * @param matrix defines the matrix to transpose
  60950. * @returns the new matrix
  60951. */
  60952. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  60953. /**
  60954. * Compute the transpose of a matrix and store it in a target matrix
  60955. * @param matrix defines the matrix to transpose
  60956. * @param result defines the target matrix
  60957. */
  60958. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  60959. /**
  60960. * Computes a reflection matrix from a plane
  60961. * @param plane defines the reflection plane
  60962. * @returns a new matrix
  60963. */
  60964. static Reflection(plane: DeepImmutable<Plane>): Matrix;
  60965. /**
  60966. * Computes a reflection matrix from a plane
  60967. * @param plane defines the reflection plane
  60968. * @param result defines the target matrix
  60969. */
  60970. static ReflectionToRef(plane: DeepImmutable<Plane>, result: Matrix): void;
  60971. /**
  60972. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  60973. * @param xaxis defines the value of the 1st axis
  60974. * @param yaxis defines the value of the 2nd axis
  60975. * @param zaxis defines the value of the 3rd axis
  60976. * @param result defines the target matrix
  60977. */
  60978. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  60979. /**
  60980. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  60981. * @param quat defines the quaternion to use
  60982. * @param result defines the target matrix
  60983. */
  60984. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  60985. }
  60986. /**
  60987. * Represens a plane by the equation ax + by + cz + d = 0
  60988. */
  60989. export class Plane {
  60990. /**
  60991. * Normal of the plane (a,b,c)
  60992. */
  60993. normal: Vector3;
  60994. /**
  60995. * d component of the plane
  60996. */
  60997. d: number;
  60998. /**
  60999. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  61000. * @param a a component of the plane
  61001. * @param b b component of the plane
  61002. * @param c c component of the plane
  61003. * @param d d component of the plane
  61004. */
  61005. constructor(a: number, b: number, c: number, d: number);
  61006. /**
  61007. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  61008. */
  61009. asArray(): number[];
  61010. /**
  61011. * @returns a new plane copied from the current Plane.
  61012. */
  61013. clone(): Plane;
  61014. /**
  61015. * @returns the string "Plane".
  61016. */
  61017. getClassName(): string;
  61018. /**
  61019. * @returns the Plane hash code.
  61020. */
  61021. getHashCode(): number;
  61022. /**
  61023. * Normalize the current Plane in place.
  61024. * @returns the updated Plane.
  61025. */
  61026. normalize(): Plane;
  61027. /**
  61028. * Applies a transformation the plane and returns the result
  61029. * @param transformation the transformation matrix to be applied to the plane
  61030. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  61031. */
  61032. transform(transformation: DeepImmutable<Matrix>): Plane;
  61033. /**
  61034. * Calcualtte the dot product between the point and the plane normal
  61035. * @param point point to calculate the dot product with
  61036. * @returns the dot product (float) of the point coordinates and the plane normal.
  61037. */
  61038. dotCoordinate(point: DeepImmutable<Vector3>): number;
  61039. /**
  61040. * Updates the current Plane from the plane defined by the three given points.
  61041. * @param point1 one of the points used to contruct the plane
  61042. * @param point2 one of the points used to contruct the plane
  61043. * @param point3 one of the points used to contruct the plane
  61044. * @returns the updated Plane.
  61045. */
  61046. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  61047. /**
  61048. * Checks if the plane is facing a given direction
  61049. * @param direction the direction to check if the plane is facing
  61050. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  61051. * @returns True is the vector "direction" is the same side than the plane normal.
  61052. */
  61053. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  61054. /**
  61055. * Calculates the distance to a point
  61056. * @param point point to calculate distance to
  61057. * @returns the signed distance (float) from the given point to the Plane.
  61058. */
  61059. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  61060. /**
  61061. * Creates a plane from an array
  61062. * @param array the array to create a plane from
  61063. * @returns a new Plane from the given array.
  61064. */
  61065. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  61066. /**
  61067. * Creates a plane from three points
  61068. * @param point1 point used to create the plane
  61069. * @param point2 point used to create the plane
  61070. * @param point3 point used to create the plane
  61071. * @returns a new Plane defined by the three given points.
  61072. */
  61073. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  61074. /**
  61075. * Creates a plane from an origin point and a normal
  61076. * @param origin origin of the plane to be constructed
  61077. * @param normal normal of the plane to be constructed
  61078. * @returns a new Plane the normal vector to this plane at the given origin point.
  61079. * Note : the vector "normal" is updated because normalized.
  61080. */
  61081. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  61082. /**
  61083. * Calculates the distance from a plane and a point
  61084. * @param origin origin of the plane to be constructed
  61085. * @param normal normal of the plane to be constructed
  61086. * @param point point to calculate distance to
  61087. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  61088. */
  61089. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  61090. }
  61091. /**
  61092. * Class used to represent a viewport on screen
  61093. */
  61094. export class Viewport {
  61095. /** viewport left coordinate */
  61096. x: number;
  61097. /** viewport top coordinate */
  61098. y: number;
  61099. /**viewport width */
  61100. width: number;
  61101. /** viewport height */
  61102. height: number;
  61103. /**
  61104. * Creates a Viewport object located at (x, y) and sized (width, height)
  61105. * @param x defines viewport left coordinate
  61106. * @param y defines viewport top coordinate
  61107. * @param width defines the viewport width
  61108. * @param height defines the viewport height
  61109. */
  61110. constructor(
  61111. /** viewport left coordinate */
  61112. x: number,
  61113. /** viewport top coordinate */
  61114. y: number,
  61115. /**viewport width */
  61116. width: number,
  61117. /** viewport height */
  61118. height: number);
  61119. /**
  61120. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  61121. * @param renderWidth defines the rendering width
  61122. * @param renderHeight defines the rendering height
  61123. * @returns a new Viewport
  61124. */
  61125. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  61126. /**
  61127. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  61128. * @param renderWidth defines the rendering width
  61129. * @param renderHeight defines the rendering height
  61130. * @param ref defines the target viewport
  61131. * @returns the current viewport
  61132. */
  61133. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  61134. /**
  61135. * Returns a new Viewport copied from the current one
  61136. * @returns a new Viewport
  61137. */
  61138. clone(): Viewport;
  61139. }
  61140. /**
  61141. * Reprasents a camera frustum
  61142. */
  61143. export class Frustum {
  61144. /**
  61145. * Gets the planes representing the frustum
  61146. * @param transform matrix to be applied to the returned planes
  61147. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  61148. */
  61149. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  61150. /**
  61151. * Gets the near 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 GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  61156. /**
  61157. * Gets the far frustum plane transformed by the transform matrix
  61158. * @param transform transformation matrix to be applied to the resulting frustum plane
  61159. * @param frustumPlane the resuling frustum plane
  61160. */
  61161. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  61162. /**
  61163. * Gets the left frustum plane transformed by the transform matrix
  61164. * @param transform transformation matrix to be applied to the resulting frustum plane
  61165. * @param frustumPlane the resuling frustum plane
  61166. */
  61167. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  61168. /**
  61169. * Gets the right frustum plane transformed by the transform matrix
  61170. * @param transform transformation matrix to be applied to the resulting frustum plane
  61171. * @param frustumPlane the resuling frustum plane
  61172. */
  61173. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  61174. /**
  61175. * Gets the top frustum plane transformed by the transform matrix
  61176. * @param transform transformation matrix to be applied to the resulting frustum plane
  61177. * @param frustumPlane the resuling frustum plane
  61178. */
  61179. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  61180. /**
  61181. * Gets the bottom frustum plane transformed by the transform matrix
  61182. * @param transform transformation matrix to be applied to the resulting frustum plane
  61183. * @param frustumPlane the resuling frustum plane
  61184. */
  61185. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  61186. /**
  61187. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  61188. * @param transform transformation matrix to be applied to the resulting frustum planes
  61189. * @param frustumPlanes the resuling frustum planes
  61190. */
  61191. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  61192. }
  61193. /** Defines supported spaces */
  61194. export enum Space {
  61195. /** Local (object) space */
  61196. LOCAL = 0,
  61197. /** World space */
  61198. WORLD = 1,
  61199. /** Bone space */
  61200. BONE = 2
  61201. }
  61202. /** Defines the 3 main axes */
  61203. export class Axis {
  61204. /** X axis */
  61205. static X: Vector3;
  61206. /** Y axis */
  61207. static Y: Vector3;
  61208. /** Z axis */
  61209. static Z: Vector3;
  61210. }
  61211. /** Class used to represent a Bezier curve */
  61212. export class BezierCurve {
  61213. /**
  61214. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  61215. * @param t defines the time
  61216. * @param x1 defines the left coordinate on X axis
  61217. * @param y1 defines the left coordinate on Y axis
  61218. * @param x2 defines the right coordinate on X axis
  61219. * @param y2 defines the right coordinate on Y axis
  61220. * @returns the interpolated value
  61221. */
  61222. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  61223. }
  61224. /**
  61225. * Defines potential orientation for back face culling
  61226. */
  61227. export enum Orientation {
  61228. /**
  61229. * Clockwise
  61230. */
  61231. CW = 0,
  61232. /** Counter clockwise */
  61233. CCW = 1
  61234. }
  61235. /**
  61236. * Defines angle representation
  61237. */
  61238. export class Angle {
  61239. private _radians;
  61240. /**
  61241. * Creates an Angle object of "radians" radians (float).
  61242. * @param radians the angle in radians
  61243. */
  61244. constructor(radians: number);
  61245. /**
  61246. * Get value in degrees
  61247. * @returns the Angle value in degrees (float)
  61248. */
  61249. degrees(): number;
  61250. /**
  61251. * Get value in radians
  61252. * @returns the Angle value in radians (float)
  61253. */
  61254. radians(): number;
  61255. /**
  61256. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  61257. * @param a defines first vector
  61258. * @param b defines second vector
  61259. * @returns a new Angle
  61260. */
  61261. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  61262. /**
  61263. * Gets a new Angle object from the given float in radians
  61264. * @param radians defines the angle value in radians
  61265. * @returns a new Angle
  61266. */
  61267. static FromRadians(radians: number): Angle;
  61268. /**
  61269. * Gets a new Angle object from the given float in degrees
  61270. * @param degrees defines the angle value in degrees
  61271. * @returns a new Angle
  61272. */
  61273. static FromDegrees(degrees: number): Angle;
  61274. }
  61275. /**
  61276. * This represents an arc in a 2d space.
  61277. */
  61278. export class Arc2 {
  61279. /** Defines the start point of the arc */
  61280. startPoint: Vector2;
  61281. /** Defines the mid point of the arc */
  61282. midPoint: Vector2;
  61283. /** Defines the end point of the arc */
  61284. endPoint: Vector2;
  61285. /**
  61286. * Defines the center point of the arc.
  61287. */
  61288. centerPoint: Vector2;
  61289. /**
  61290. * Defines the radius of the arc.
  61291. */
  61292. radius: number;
  61293. /**
  61294. * Defines the angle of the arc (from mid point to end point).
  61295. */
  61296. angle: Angle;
  61297. /**
  61298. * Defines the start angle of the arc (from start point to middle point).
  61299. */
  61300. startAngle: Angle;
  61301. /**
  61302. * Defines the orientation of the arc (clock wise/counter clock wise).
  61303. */
  61304. orientation: Orientation;
  61305. /**
  61306. * Creates an Arc object from the three given points : start, middle and end.
  61307. * @param startPoint Defines the start point of the arc
  61308. * @param midPoint Defines the midlle point of the arc
  61309. * @param endPoint Defines the end point of the arc
  61310. */
  61311. constructor(
  61312. /** Defines the start point of the arc */
  61313. startPoint: Vector2,
  61314. /** Defines the mid point of the arc */
  61315. midPoint: Vector2,
  61316. /** Defines the end point of the arc */
  61317. endPoint: Vector2);
  61318. }
  61319. /**
  61320. * Represents a 2D path made up of multiple 2D points
  61321. */
  61322. export class Path2 {
  61323. private _points;
  61324. private _length;
  61325. /**
  61326. * If the path start and end point are the same
  61327. */
  61328. closed: boolean;
  61329. /**
  61330. * Creates a Path2 object from the starting 2D coordinates x and y.
  61331. * @param x the starting points x value
  61332. * @param y the starting points y value
  61333. */
  61334. constructor(x: number, y: number);
  61335. /**
  61336. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  61337. * @param x the added points x value
  61338. * @param y the added points y value
  61339. * @returns the updated Path2.
  61340. */
  61341. addLineTo(x: number, y: number): Path2;
  61342. /**
  61343. * 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.
  61344. * @param midX middle point x value
  61345. * @param midY middle point y value
  61346. * @param endX end point x value
  61347. * @param endY end point y value
  61348. * @param numberOfSegments (default: 36)
  61349. * @returns the updated Path2.
  61350. */
  61351. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  61352. /**
  61353. * Closes the Path2.
  61354. * @returns the Path2.
  61355. */
  61356. close(): Path2;
  61357. /**
  61358. * Gets the sum of the distance between each sequential point in the path
  61359. * @returns the Path2 total length (float).
  61360. */
  61361. length(): number;
  61362. /**
  61363. * Gets the points which construct the path
  61364. * @returns the Path2 internal array of points.
  61365. */
  61366. getPoints(): Vector2[];
  61367. /**
  61368. * Retreives the point at the distance aways from the starting point
  61369. * @param normalizedLengthPosition the length along the path to retreive the point from
  61370. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  61371. */
  61372. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  61373. /**
  61374. * Creates a new path starting from an x and y position
  61375. * @param x starting x value
  61376. * @param y starting y value
  61377. * @returns a new Path2 starting at the coordinates (x, y).
  61378. */
  61379. static StartingAt(x: number, y: number): Path2;
  61380. }
  61381. /**
  61382. * Represents a 3D path made up of multiple 3D points
  61383. */
  61384. export class Path3D {
  61385. /**
  61386. * an array of Vector3, the curve axis of the Path3D
  61387. */
  61388. path: Vector3[];
  61389. private _curve;
  61390. private _distances;
  61391. private _tangents;
  61392. private _normals;
  61393. private _binormals;
  61394. private _raw;
  61395. /**
  61396. * new Path3D(path, normal, raw)
  61397. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  61398. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  61399. * @param path an array of Vector3, the curve axis of the Path3D
  61400. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  61401. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  61402. */
  61403. constructor(
  61404. /**
  61405. * an array of Vector3, the curve axis of the Path3D
  61406. */
  61407. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  61408. /**
  61409. * Returns the Path3D array of successive Vector3 designing its curve.
  61410. * @returns the Path3D array of successive Vector3 designing its curve.
  61411. */
  61412. getCurve(): Vector3[];
  61413. /**
  61414. * Returns an array populated with tangent vectors on each Path3D curve point.
  61415. * @returns an array populated with tangent vectors on each Path3D curve point.
  61416. */
  61417. getTangents(): Vector3[];
  61418. /**
  61419. * Returns an array populated with normal vectors on each Path3D curve point.
  61420. * @returns an array populated with normal vectors on each Path3D curve point.
  61421. */
  61422. getNormals(): Vector3[];
  61423. /**
  61424. * Returns an array populated with binormal vectors on each Path3D curve point.
  61425. * @returns an array populated with binormal vectors on each Path3D curve point.
  61426. */
  61427. getBinormals(): Vector3[];
  61428. /**
  61429. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  61430. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  61431. */
  61432. getDistances(): number[];
  61433. /**
  61434. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  61435. * @param path path which all values are copied into the curves points
  61436. * @param firstNormal which should be projected onto the curve
  61437. * @returns the same object updated.
  61438. */
  61439. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  61440. private _compute;
  61441. private _getFirstNonNullVector;
  61442. private _getLastNonNullVector;
  61443. private _normalVector;
  61444. }
  61445. /**
  61446. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  61447. * A Curve3 is designed from a series of successive Vector3.
  61448. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  61449. */
  61450. export class Curve3 {
  61451. private _points;
  61452. private _length;
  61453. /**
  61454. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  61455. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  61456. * @param v1 (Vector3) the control point
  61457. * @param v2 (Vector3) the end point of the Quadratic Bezier
  61458. * @param nbPoints (integer) the wanted number of points in the curve
  61459. * @returns the created Curve3
  61460. */
  61461. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  61462. /**
  61463. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  61464. * @param v0 (Vector3) the origin point of the Cubic Bezier
  61465. * @param v1 (Vector3) the first control point
  61466. * @param v2 (Vector3) the second control point
  61467. * @param v3 (Vector3) the end point of the Cubic Bezier
  61468. * @param nbPoints (integer) the wanted number of points in the curve
  61469. * @returns the created Curve3
  61470. */
  61471. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  61472. /**
  61473. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  61474. * @param p1 (Vector3) the origin point of the Hermite Spline
  61475. * @param t1 (Vector3) the tangent vector at the origin point
  61476. * @param p2 (Vector3) the end point of the Hermite Spline
  61477. * @param t2 (Vector3) the tangent vector at the end point
  61478. * @param nbPoints (integer) the wanted number of points in the curve
  61479. * @returns the created Curve3
  61480. */
  61481. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  61482. /**
  61483. * Returns a Curve3 object along a CatmullRom Spline curve :
  61484. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  61485. * @param nbPoints (integer) the wanted number of points between each curve control points
  61486. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  61487. * @returns the created Curve3
  61488. */
  61489. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  61490. /**
  61491. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  61492. * A Curve3 is designed from a series of successive Vector3.
  61493. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  61494. * @param points points which make up the curve
  61495. */
  61496. constructor(points: Vector3[]);
  61497. /**
  61498. * @returns the Curve3 stored array of successive Vector3
  61499. */
  61500. getPoints(): Vector3[];
  61501. /**
  61502. * @returns the computed length (float) of the curve.
  61503. */
  61504. length(): number;
  61505. /**
  61506. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  61507. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  61508. * curveA and curveB keep unchanged.
  61509. * @param curve the curve to continue from this curve
  61510. * @returns the newly constructed curve
  61511. */
  61512. continue(curve: DeepImmutable<Curve3>): Curve3;
  61513. private _computeLength;
  61514. }
  61515. /**
  61516. * Contains position and normal vectors for a vertex
  61517. */
  61518. export class PositionNormalVertex {
  61519. /** the position of the vertex (defaut: 0,0,0) */
  61520. position: Vector3;
  61521. /** the normal of the vertex (defaut: 0,1,0) */
  61522. normal: Vector3;
  61523. /**
  61524. * Creates a PositionNormalVertex
  61525. * @param position the position of the vertex (defaut: 0,0,0)
  61526. * @param normal the normal of the vertex (defaut: 0,1,0)
  61527. */
  61528. constructor(
  61529. /** the position of the vertex (defaut: 0,0,0) */
  61530. position?: Vector3,
  61531. /** the normal of the vertex (defaut: 0,1,0) */
  61532. normal?: Vector3);
  61533. /**
  61534. * Clones the PositionNormalVertex
  61535. * @returns the cloned PositionNormalVertex
  61536. */
  61537. clone(): PositionNormalVertex;
  61538. }
  61539. /**
  61540. * Contains position, normal and uv vectors for a vertex
  61541. */
  61542. export class PositionNormalTextureVertex {
  61543. /** the position of the vertex (defaut: 0,0,0) */
  61544. position: Vector3;
  61545. /** the normal of the vertex (defaut: 0,1,0) */
  61546. normal: Vector3;
  61547. /** the uv of the vertex (default: 0,0) */
  61548. uv: Vector2;
  61549. /**
  61550. * Creates a PositionNormalTextureVertex
  61551. * @param position the position of the vertex (defaut: 0,0,0)
  61552. * @param normal the normal of the vertex (defaut: 0,1,0)
  61553. * @param uv the uv of the vertex (default: 0,0)
  61554. */
  61555. constructor(
  61556. /** the position of the vertex (defaut: 0,0,0) */
  61557. position?: Vector3,
  61558. /** the normal of the vertex (defaut: 0,1,0) */
  61559. normal?: Vector3,
  61560. /** the uv of the vertex (default: 0,0) */
  61561. uv?: Vector2);
  61562. /**
  61563. * Clones the PositionNormalTextureVertex
  61564. * @returns the cloned PositionNormalTextureVertex
  61565. */
  61566. clone(): PositionNormalTextureVertex;
  61567. }
  61568. /**
  61569. * @hidden
  61570. */
  61571. export class Tmp {
  61572. static Color3: Color3[];
  61573. static Color4: Color4[];
  61574. static Vector2: Vector2[];
  61575. static Vector3: Vector3[];
  61576. static Vector4: Vector4[];
  61577. static Quaternion: Quaternion[];
  61578. static Matrix: Matrix[];
  61579. }
  61580. }
  61581. declare module BABYLON {
  61582. /**
  61583. * Class used to enable access to offline support
  61584. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  61585. */
  61586. export interface IOfflineProvider {
  61587. /**
  61588. * Gets a boolean indicating if scene must be saved in the database
  61589. */
  61590. enableSceneOffline: boolean;
  61591. /**
  61592. * Gets a boolean indicating if textures must be saved in the database
  61593. */
  61594. enableTexturesOffline: boolean;
  61595. /**
  61596. * Open the offline support and make it available
  61597. * @param successCallback defines the callback to call on success
  61598. * @param errorCallback defines the callback to call on error
  61599. */
  61600. open(successCallback: () => void, errorCallback: () => void): void;
  61601. /**
  61602. * Loads an image from the offline support
  61603. * @param url defines the url to load from
  61604. * @param image defines the target DOM image
  61605. */
  61606. loadImage(url: string, image: HTMLImageElement): void;
  61607. /**
  61608. * Loads a file from offline support
  61609. * @param url defines the URL to load from
  61610. * @param sceneLoaded defines a callback to call on success
  61611. * @param progressCallBack defines a callback to call when progress changed
  61612. * @param errorCallback defines a callback to call on error
  61613. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  61614. */
  61615. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  61616. }
  61617. }
  61618. declare module BABYLON {
  61619. /**
  61620. * A class serves as a medium between the observable and its observers
  61621. */
  61622. export class EventState {
  61623. /**
  61624. * Create a new EventState
  61625. * @param mask defines the mask associated with this state
  61626. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  61627. * @param target defines the original target of the state
  61628. * @param currentTarget defines the current target of the state
  61629. */
  61630. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  61631. /**
  61632. * Initialize the current event state
  61633. * @param mask defines the mask associated with this state
  61634. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  61635. * @param target defines the original target of the state
  61636. * @param currentTarget defines the current target of the state
  61637. * @returns the current event state
  61638. */
  61639. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  61640. /**
  61641. * An Observer can set this property to true to prevent subsequent observers of being notified
  61642. */
  61643. skipNextObservers: boolean;
  61644. /**
  61645. * Get the mask value that were used to trigger the event corresponding to this EventState object
  61646. */
  61647. mask: number;
  61648. /**
  61649. * The object that originally notified the event
  61650. */
  61651. target?: any;
  61652. /**
  61653. * The current object in the bubbling phase
  61654. */
  61655. currentTarget?: any;
  61656. /**
  61657. * This will be populated with the return value of the last function that was executed.
  61658. * If it is the first function in the callback chain it will be the event data.
  61659. */
  61660. lastReturnValue?: any;
  61661. }
  61662. /**
  61663. * Represent an Observer registered to a given Observable object.
  61664. */
  61665. export class Observer<T> {
  61666. /**
  61667. * Defines the callback to call when the observer is notified
  61668. */
  61669. callback: (eventData: T, eventState: EventState) => void;
  61670. /**
  61671. * Defines the mask of the observer (used to filter notifications)
  61672. */
  61673. mask: number;
  61674. /**
  61675. * Defines the current scope used to restore the JS context
  61676. */
  61677. scope: any;
  61678. /** @hidden */
  61679. _willBeUnregistered: boolean;
  61680. /**
  61681. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  61682. */
  61683. unregisterOnNextCall: boolean;
  61684. /**
  61685. * Creates a new observer
  61686. * @param callback defines the callback to call when the observer is notified
  61687. * @param mask defines the mask of the observer (used to filter notifications)
  61688. * @param scope defines the current scope used to restore the JS context
  61689. */
  61690. constructor(
  61691. /**
  61692. * Defines the callback to call when the observer is notified
  61693. */
  61694. callback: (eventData: T, eventState: EventState) => void,
  61695. /**
  61696. * Defines the mask of the observer (used to filter notifications)
  61697. */
  61698. mask: number,
  61699. /**
  61700. * Defines the current scope used to restore the JS context
  61701. */
  61702. scope?: any);
  61703. }
  61704. /**
  61705. * Represent a list of observers registered to multiple Observables object.
  61706. */
  61707. export class MultiObserver<T> {
  61708. private _observers;
  61709. private _observables;
  61710. /**
  61711. * Release associated resources
  61712. */
  61713. dispose(): void;
  61714. /**
  61715. * Raise a callback when one of the observable will notify
  61716. * @param observables defines a list of observables to watch
  61717. * @param callback defines the callback to call on notification
  61718. * @param mask defines the mask used to filter notifications
  61719. * @param scope defines the current scope used to restore the JS context
  61720. * @returns the new MultiObserver
  61721. */
  61722. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  61723. }
  61724. /**
  61725. * The Observable class is a simple implementation of the Observable pattern.
  61726. *
  61727. * 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.
  61728. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  61729. * 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).
  61730. * 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.
  61731. */
  61732. export class Observable<T> {
  61733. private _observers;
  61734. private _eventState;
  61735. private _onObserverAdded;
  61736. /**
  61737. * Creates a new observable
  61738. * @param onObserverAdded defines a callback to call when a new observer is added
  61739. */
  61740. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  61741. /**
  61742. * Create a new Observer with the specified callback
  61743. * @param callback the callback that will be executed for that Observer
  61744. * @param mask the mask used to filter observers
  61745. * @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.
  61746. * @param scope optional scope for the callback to be called from
  61747. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  61748. * @returns the new observer created for the callback
  61749. */
  61750. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  61751. /**
  61752. * Create a new Observer with the specified callback and unregisters after the next notification
  61753. * @param callback the callback that will be executed for that Observer
  61754. * @returns the new observer created for the callback
  61755. */
  61756. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  61757. /**
  61758. * Remove an Observer from the Observable object
  61759. * @param observer the instance of the Observer to remove
  61760. * @returns false if it doesn't belong to this Observable
  61761. */
  61762. remove(observer: Nullable<Observer<T>>): boolean;
  61763. /**
  61764. * Remove a callback from the Observable object
  61765. * @param callback the callback to remove
  61766. * @param scope optional scope. If used only the callbacks with this scope will be removed
  61767. * @returns false if it doesn't belong to this Observable
  61768. */
  61769. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  61770. private _deferUnregister;
  61771. private _remove;
  61772. /**
  61773. * Notify all Observers by calling their respective callback with the given data
  61774. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  61775. * @param eventData defines the data to send to all observers
  61776. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  61777. * @param target defines the original target of the state
  61778. * @param currentTarget defines the current target of the state
  61779. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  61780. */
  61781. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  61782. /**
  61783. * Calling this will execute each callback, expecting it to be a promise or return a value.
  61784. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  61785. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  61786. * and it is crucial that all callbacks will be executed.
  61787. * The order of the callbacks is kept, callbacks are not executed parallel.
  61788. *
  61789. * @param eventData The data to be sent to each callback
  61790. * @param mask is used to filter observers defaults to -1
  61791. * @param target defines the callback target (see EventState)
  61792. * @param currentTarget defines he current object in the bubbling phase
  61793. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  61794. */
  61795. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  61796. /**
  61797. * Notify a specific observer
  61798. * @param observer defines the observer to notify
  61799. * @param eventData defines the data to be sent to each callback
  61800. * @param mask is used to filter observers defaults to -1
  61801. */
  61802. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  61803. /**
  61804. * Gets a boolean indicating if the observable has at least one observer
  61805. * @returns true is the Observable has at least one Observer registered
  61806. */
  61807. hasObservers(): boolean;
  61808. /**
  61809. * Clear the list of observers
  61810. */
  61811. clear(): void;
  61812. /**
  61813. * Clone the current observable
  61814. * @returns a new observable
  61815. */
  61816. clone(): Observable<T>;
  61817. /**
  61818. * Does this observable handles observer registered with a given mask
  61819. * @param mask defines the mask to be tested
  61820. * @return whether or not one observer registered with the given mask is handeled
  61821. **/
  61822. hasSpecificMask(mask?: number): boolean;
  61823. }
  61824. }
  61825. declare module BABYLON {
  61826. /**
  61827. * Class used to help managing file picking and drag'n'drop
  61828. * File Storage
  61829. */
  61830. export class FilesInputStore {
  61831. /**
  61832. * List of files ready to be loaded
  61833. */
  61834. static FilesToLoad: {
  61835. [key: string]: File;
  61836. };
  61837. }
  61838. }
  61839. declare module BABYLON {
  61840. /** Defines the cross module used constants to avoid circular dependncies */
  61841. export class Constants {
  61842. /** Defines that alpha blending is disabled */
  61843. static readonly ALPHA_DISABLE: number;
  61844. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  61845. static readonly ALPHA_ADD: number;
  61846. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  61847. static readonly ALPHA_COMBINE: number;
  61848. /** Defines that alpha blending to DEST - SRC * DEST */
  61849. static readonly ALPHA_SUBTRACT: number;
  61850. /** Defines that alpha blending to SRC * DEST */
  61851. static readonly ALPHA_MULTIPLY: number;
  61852. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  61853. static readonly ALPHA_MAXIMIZED: number;
  61854. /** Defines that alpha blending to SRC + DEST */
  61855. static readonly ALPHA_ONEONE: number;
  61856. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  61857. static readonly ALPHA_PREMULTIPLIED: number;
  61858. /**
  61859. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  61860. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  61861. */
  61862. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  61863. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  61864. static readonly ALPHA_INTERPOLATE: number;
  61865. /**
  61866. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  61867. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  61868. */
  61869. static readonly ALPHA_SCREENMODE: number;
  61870. /** Defines that the ressource is not delayed*/
  61871. static readonly DELAYLOADSTATE_NONE: number;
  61872. /** Defines that the ressource was successfully delay loaded */
  61873. static readonly DELAYLOADSTATE_LOADED: number;
  61874. /** Defines that the ressource is currently delay loading */
  61875. static readonly DELAYLOADSTATE_LOADING: number;
  61876. /** Defines that the ressource is delayed and has not started loading */
  61877. static readonly DELAYLOADSTATE_NOTLOADED: number;
  61878. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  61879. static readonly NEVER: number;
  61880. /** 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 */
  61881. static readonly ALWAYS: number;
  61882. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  61883. static readonly LESS: number;
  61884. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  61885. static readonly EQUAL: number;
  61886. /** 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 */
  61887. static readonly LEQUAL: number;
  61888. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  61889. static readonly GREATER: number;
  61890. /** 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 */
  61891. static readonly GEQUAL: number;
  61892. /** 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 */
  61893. static readonly NOTEQUAL: number;
  61894. /** Passed to stencilOperation to specify that stencil value must be kept */
  61895. static readonly KEEP: number;
  61896. /** Passed to stencilOperation to specify that stencil value must be replaced */
  61897. static readonly REPLACE: number;
  61898. /** Passed to stencilOperation to specify that stencil value must be incremented */
  61899. static readonly INCR: number;
  61900. /** Passed to stencilOperation to specify that stencil value must be decremented */
  61901. static readonly DECR: number;
  61902. /** Passed to stencilOperation to specify that stencil value must be inverted */
  61903. static readonly INVERT: number;
  61904. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  61905. static readonly INCR_WRAP: number;
  61906. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  61907. static readonly DECR_WRAP: number;
  61908. /** Texture is not repeating outside of 0..1 UVs */
  61909. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  61910. /** Texture is repeating outside of 0..1 UVs */
  61911. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  61912. /** Texture is repeating and mirrored */
  61913. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  61914. /** ALPHA */
  61915. static readonly TEXTUREFORMAT_ALPHA: number;
  61916. /** LUMINANCE */
  61917. static readonly TEXTUREFORMAT_LUMINANCE: number;
  61918. /** LUMINANCE_ALPHA */
  61919. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  61920. /** RGB */
  61921. static readonly TEXTUREFORMAT_RGB: number;
  61922. /** RGBA */
  61923. static readonly TEXTUREFORMAT_RGBA: number;
  61924. /** RED */
  61925. static readonly TEXTUREFORMAT_RED: number;
  61926. /** RED (2nd reference) */
  61927. static readonly TEXTUREFORMAT_R: number;
  61928. /** RG */
  61929. static readonly TEXTUREFORMAT_RG: number;
  61930. /** RED_INTEGER */
  61931. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  61932. /** RED_INTEGER (2nd reference) */
  61933. static readonly TEXTUREFORMAT_R_INTEGER: number;
  61934. /** RG_INTEGER */
  61935. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  61936. /** RGB_INTEGER */
  61937. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  61938. /** RGBA_INTEGER */
  61939. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  61940. /** UNSIGNED_BYTE */
  61941. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  61942. /** UNSIGNED_BYTE (2nd reference) */
  61943. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  61944. /** FLOAT */
  61945. static readonly TEXTURETYPE_FLOAT: number;
  61946. /** HALF_FLOAT */
  61947. static readonly TEXTURETYPE_HALF_FLOAT: number;
  61948. /** BYTE */
  61949. static readonly TEXTURETYPE_BYTE: number;
  61950. /** SHORT */
  61951. static readonly TEXTURETYPE_SHORT: number;
  61952. /** UNSIGNED_SHORT */
  61953. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  61954. /** INT */
  61955. static readonly TEXTURETYPE_INT: number;
  61956. /** UNSIGNED_INT */
  61957. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  61958. /** UNSIGNED_SHORT_4_4_4_4 */
  61959. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  61960. /** UNSIGNED_SHORT_5_5_5_1 */
  61961. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  61962. /** UNSIGNED_SHORT_5_6_5 */
  61963. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  61964. /** UNSIGNED_INT_2_10_10_10_REV */
  61965. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  61966. /** UNSIGNED_INT_24_8 */
  61967. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  61968. /** UNSIGNED_INT_10F_11F_11F_REV */
  61969. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  61970. /** UNSIGNED_INT_5_9_9_9_REV */
  61971. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  61972. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  61973. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  61974. /** nearest is mag = nearest and min = nearest and mip = linear */
  61975. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  61976. /** Bilinear is mag = linear and min = linear and mip = nearest */
  61977. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  61978. /** Trilinear is mag = linear and min = linear and mip = linear */
  61979. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  61980. /** nearest is mag = nearest and min = nearest and mip = linear */
  61981. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  61982. /** Bilinear is mag = linear and min = linear and mip = nearest */
  61983. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  61984. /** Trilinear is mag = linear and min = linear and mip = linear */
  61985. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  61986. /** mag = nearest and min = nearest and mip = nearest */
  61987. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  61988. /** mag = nearest and min = linear and mip = nearest */
  61989. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  61990. /** mag = nearest and min = linear and mip = linear */
  61991. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  61992. /** mag = nearest and min = linear and mip = none */
  61993. static readonly TEXTURE_NEAREST_LINEAR: number;
  61994. /** mag = nearest and min = nearest and mip = none */
  61995. static readonly TEXTURE_NEAREST_NEAREST: number;
  61996. /** mag = linear and min = nearest and mip = nearest */
  61997. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  61998. /** mag = linear and min = nearest and mip = linear */
  61999. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  62000. /** mag = linear and min = linear and mip = none */
  62001. static readonly TEXTURE_LINEAR_LINEAR: number;
  62002. /** mag = linear and min = nearest and mip = none */
  62003. static readonly TEXTURE_LINEAR_NEAREST: number;
  62004. /** Explicit coordinates mode */
  62005. static readonly TEXTURE_EXPLICIT_MODE: number;
  62006. /** Spherical coordinates mode */
  62007. static readonly TEXTURE_SPHERICAL_MODE: number;
  62008. /** Planar coordinates mode */
  62009. static readonly TEXTURE_PLANAR_MODE: number;
  62010. /** Cubic coordinates mode */
  62011. static readonly TEXTURE_CUBIC_MODE: number;
  62012. /** Projection coordinates mode */
  62013. static readonly TEXTURE_PROJECTION_MODE: number;
  62014. /** Skybox coordinates mode */
  62015. static readonly TEXTURE_SKYBOX_MODE: number;
  62016. /** Inverse Cubic coordinates mode */
  62017. static readonly TEXTURE_INVCUBIC_MODE: number;
  62018. /** Equirectangular coordinates mode */
  62019. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  62020. /** Equirectangular Fixed coordinates mode */
  62021. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  62022. /** Equirectangular Fixed Mirrored coordinates mode */
  62023. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  62024. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  62025. static readonly SCALEMODE_FLOOR: number;
  62026. /** Defines that texture rescaling will look for the nearest power of 2 size */
  62027. static readonly SCALEMODE_NEAREST: number;
  62028. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  62029. static readonly SCALEMODE_CEILING: number;
  62030. /**
  62031. * The dirty texture flag value
  62032. */
  62033. static readonly MATERIAL_TextureDirtyFlag: number;
  62034. /**
  62035. * The dirty light flag value
  62036. */
  62037. static readonly MATERIAL_LightDirtyFlag: number;
  62038. /**
  62039. * The dirty fresnel flag value
  62040. */
  62041. static readonly MATERIAL_FresnelDirtyFlag: number;
  62042. /**
  62043. * The dirty attribute flag value
  62044. */
  62045. static readonly MATERIAL_AttributesDirtyFlag: number;
  62046. /**
  62047. * The dirty misc flag value
  62048. */
  62049. static readonly MATERIAL_MiscDirtyFlag: number;
  62050. /**
  62051. * The all dirty flag value
  62052. */
  62053. static readonly MATERIAL_AllDirtyFlag: number;
  62054. /**
  62055. * Returns the triangle fill mode
  62056. */
  62057. static readonly MATERIAL_TriangleFillMode: number;
  62058. /**
  62059. * Returns the wireframe mode
  62060. */
  62061. static readonly MATERIAL_WireFrameFillMode: number;
  62062. /**
  62063. * Returns the point fill mode
  62064. */
  62065. static readonly MATERIAL_PointFillMode: number;
  62066. /**
  62067. * Returns the point list draw mode
  62068. */
  62069. static readonly MATERIAL_PointListDrawMode: number;
  62070. /**
  62071. * Returns the line list draw mode
  62072. */
  62073. static readonly MATERIAL_LineListDrawMode: number;
  62074. /**
  62075. * Returns the line loop draw mode
  62076. */
  62077. static readonly MATERIAL_LineLoopDrawMode: number;
  62078. /**
  62079. * Returns the line strip draw mode
  62080. */
  62081. static readonly MATERIAL_LineStripDrawMode: number;
  62082. /**
  62083. * Returns the triangle strip draw mode
  62084. */
  62085. static readonly MATERIAL_TriangleStripDrawMode: number;
  62086. /**
  62087. * Returns the triangle fan draw mode
  62088. */
  62089. static readonly MATERIAL_TriangleFanDrawMode: number;
  62090. /**
  62091. * Stores the clock-wise side orientation
  62092. */
  62093. static readonly MATERIAL_ClockWiseSideOrientation: number;
  62094. /**
  62095. * Stores the counter clock-wise side orientation
  62096. */
  62097. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  62098. /**
  62099. * Nothing
  62100. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62101. */
  62102. static readonly ACTION_NothingTrigger: number;
  62103. /**
  62104. * On pick
  62105. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62106. */
  62107. static readonly ACTION_OnPickTrigger: number;
  62108. /**
  62109. * On left pick
  62110. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62111. */
  62112. static readonly ACTION_OnLeftPickTrigger: number;
  62113. /**
  62114. * On right pick
  62115. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62116. */
  62117. static readonly ACTION_OnRightPickTrigger: number;
  62118. /**
  62119. * On center pick
  62120. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62121. */
  62122. static readonly ACTION_OnCenterPickTrigger: number;
  62123. /**
  62124. * On pick down
  62125. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62126. */
  62127. static readonly ACTION_OnPickDownTrigger: number;
  62128. /**
  62129. * On double pick
  62130. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62131. */
  62132. static readonly ACTION_OnDoublePickTrigger: number;
  62133. /**
  62134. * On pick up
  62135. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62136. */
  62137. static readonly ACTION_OnPickUpTrigger: number;
  62138. /**
  62139. * On pick out.
  62140. * This trigger will only be raised if you also declared a OnPickDown
  62141. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62142. */
  62143. static readonly ACTION_OnPickOutTrigger: number;
  62144. /**
  62145. * On long press
  62146. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62147. */
  62148. static readonly ACTION_OnLongPressTrigger: number;
  62149. /**
  62150. * On pointer over
  62151. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62152. */
  62153. static readonly ACTION_OnPointerOverTrigger: number;
  62154. /**
  62155. * On pointer out
  62156. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62157. */
  62158. static readonly ACTION_OnPointerOutTrigger: number;
  62159. /**
  62160. * On every frame
  62161. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62162. */
  62163. static readonly ACTION_OnEveryFrameTrigger: number;
  62164. /**
  62165. * On intersection enter
  62166. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62167. */
  62168. static readonly ACTION_OnIntersectionEnterTrigger: number;
  62169. /**
  62170. * On intersection exit
  62171. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62172. */
  62173. static readonly ACTION_OnIntersectionExitTrigger: number;
  62174. /**
  62175. * On key down
  62176. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62177. */
  62178. static readonly ACTION_OnKeyDownTrigger: number;
  62179. /**
  62180. * On key up
  62181. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62182. */
  62183. static readonly ACTION_OnKeyUpTrigger: number;
  62184. /**
  62185. * Billboard mode will only apply to Y axis
  62186. */
  62187. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  62188. /**
  62189. * Billboard mode will apply to all axes
  62190. */
  62191. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  62192. /**
  62193. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  62194. */
  62195. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  62196. /**
  62197. * Gets or sets base Assets URL
  62198. */
  62199. static readonly PARTICLES_BaseAssetsUrl: string;
  62200. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  62201. * Test order :
  62202. * Is the bounding sphere outside the frustum ?
  62203. * If not, are the bounding box vertices outside the frustum ?
  62204. * It not, then the cullable object is in the frustum.
  62205. */
  62206. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  62207. /** Culling strategy : Bounding Sphere Only.
  62208. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  62209. * It's also less accurate than the standard because some not visible objects can still be selected.
  62210. * Test : is the bounding sphere outside the frustum ?
  62211. * If not, then the cullable object is in the frustum.
  62212. */
  62213. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  62214. /** Culling strategy : Optimistic Inclusion.
  62215. * This in an inclusion test first, then the standard exclusion test.
  62216. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  62217. * 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.
  62218. * Anyway, it's as accurate as the standard strategy.
  62219. * Test :
  62220. * Is the cullable object bounding sphere center in the frustum ?
  62221. * If not, apply the default culling strategy.
  62222. */
  62223. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  62224. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  62225. * This in an inclusion test first, then the bounding sphere only exclusion test.
  62226. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  62227. * 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.
  62228. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  62229. * Test :
  62230. * Is the cullable object bounding sphere center in the frustum ?
  62231. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  62232. */
  62233. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  62234. /**
  62235. * No logging while loading
  62236. */
  62237. static readonly SCENELOADER_NO_LOGGING: number;
  62238. /**
  62239. * Minimal logging while loading
  62240. */
  62241. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  62242. /**
  62243. * Summary logging while loading
  62244. */
  62245. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  62246. /**
  62247. * Detailled logging while loading
  62248. */
  62249. static readonly SCENELOADER_DETAILED_LOGGING: number;
  62250. }
  62251. }
  62252. declare module BABYLON {
  62253. /**
  62254. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  62255. * Babylon.js
  62256. */
  62257. export class DomManagement {
  62258. /**
  62259. * Checks if the window object exists
  62260. * @returns true if the window object exists
  62261. */
  62262. static IsWindowObjectExist(): boolean;
  62263. /**
  62264. * Extracts text content from a DOM element hierarchy
  62265. * @param element defines the root element
  62266. * @returns a string
  62267. */
  62268. static GetDOMTextContent(element: HTMLElement): string;
  62269. }
  62270. }
  62271. declare module BABYLON {
  62272. /**
  62273. * Logger used througouht the application to allow configuration of
  62274. * the log level required for the messages.
  62275. */
  62276. export class Logger {
  62277. /**
  62278. * No log
  62279. */
  62280. static readonly NoneLogLevel: number;
  62281. /**
  62282. * Only message logs
  62283. */
  62284. static readonly MessageLogLevel: number;
  62285. /**
  62286. * Only warning logs
  62287. */
  62288. static readonly WarningLogLevel: number;
  62289. /**
  62290. * Only error logs
  62291. */
  62292. static readonly ErrorLogLevel: number;
  62293. /**
  62294. * All logs
  62295. */
  62296. static readonly AllLogLevel: number;
  62297. private static _LogCache;
  62298. /**
  62299. * Gets a value indicating the number of loading errors
  62300. * @ignorenaming
  62301. */
  62302. static errorsCount: number;
  62303. /**
  62304. * Callback called when a new log is added
  62305. */
  62306. static OnNewCacheEntry: (entry: string) => void;
  62307. private static _AddLogEntry;
  62308. private static _FormatMessage;
  62309. private static _LogDisabled;
  62310. private static _LogEnabled;
  62311. private static _WarnDisabled;
  62312. private static _WarnEnabled;
  62313. private static _ErrorDisabled;
  62314. private static _ErrorEnabled;
  62315. /**
  62316. * Log a message to the console
  62317. */
  62318. static Log: (message: string) => void;
  62319. /**
  62320. * Write a warning message to the console
  62321. */
  62322. static Warn: (message: string) => void;
  62323. /**
  62324. * Write an error message to the console
  62325. */
  62326. static Error: (message: string) => void;
  62327. /**
  62328. * Gets current log cache (list of logs)
  62329. */
  62330. static readonly LogCache: string;
  62331. /**
  62332. * Clears the log cache
  62333. */
  62334. static ClearLogCache(): void;
  62335. /**
  62336. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  62337. */
  62338. static LogLevels: number;
  62339. }
  62340. }
  62341. declare module BABYLON {
  62342. /** @hidden */
  62343. export class _TypeStore {
  62344. /** @hidden */
  62345. static RegisteredTypes: {
  62346. [key: string]: Object;
  62347. };
  62348. /** @hidden */
  62349. static GetClass(fqdn: string): any;
  62350. }
  62351. }
  62352. declare module BABYLON {
  62353. /**
  62354. * Class containing a set of static utilities functions for deep copy.
  62355. */
  62356. export class DeepCopier {
  62357. /**
  62358. * Tries to copy an object by duplicating every property
  62359. * @param source defines the source object
  62360. * @param destination defines the target object
  62361. * @param doNotCopyList defines a list of properties to avoid
  62362. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  62363. */
  62364. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  62365. }
  62366. }
  62367. declare module BABYLON {
  62368. /**
  62369. * Class containing a set of static utilities functions for precision date
  62370. */
  62371. export class PrecisionDate {
  62372. /**
  62373. * Gets either window.performance.now() if supported or Date.now() else
  62374. */
  62375. static readonly Now: number;
  62376. }
  62377. }
  62378. declare module BABYLON {
  62379. /** @hidden */
  62380. export class _DevTools {
  62381. static WarnImport(name: string): string;
  62382. }
  62383. }
  62384. declare module BABYLON {
  62385. /**
  62386. * Class used to evalaute queries containing `and` and `or` operators
  62387. */
  62388. export class AndOrNotEvaluator {
  62389. /**
  62390. * Evaluate a query
  62391. * @param query defines the query to evaluate
  62392. * @param evaluateCallback defines the callback used to filter result
  62393. * @returns true if the query matches
  62394. */
  62395. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  62396. private static _HandleParenthesisContent;
  62397. private static _SimplifyNegation;
  62398. }
  62399. }
  62400. declare module BABYLON {
  62401. /**
  62402. * Class used to store custom tags
  62403. */
  62404. export class Tags {
  62405. /**
  62406. * Adds support for tags on the given object
  62407. * @param obj defines the object to use
  62408. */
  62409. static EnableFor(obj: any): void;
  62410. /**
  62411. * Removes tags support
  62412. * @param obj defines the object to use
  62413. */
  62414. static DisableFor(obj: any): void;
  62415. /**
  62416. * Gets a boolean indicating if the given object has tags
  62417. * @param obj defines the object to use
  62418. * @returns a boolean
  62419. */
  62420. static HasTags(obj: any): boolean;
  62421. /**
  62422. * Gets the tags available on a given object
  62423. * @param obj defines the object to use
  62424. * @param asString defines if the tags must be returned as a string instead of an array of strings
  62425. * @returns the tags
  62426. */
  62427. static GetTags(obj: any, asString?: boolean): any;
  62428. /**
  62429. * Adds tags to an object
  62430. * @param obj defines the object to use
  62431. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  62432. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  62433. */
  62434. static AddTagsTo(obj: any, tagsString: string): void;
  62435. /**
  62436. * @hidden
  62437. */
  62438. static _AddTagTo(obj: any, tag: string): void;
  62439. /**
  62440. * Removes specific tags from a specific object
  62441. * @param obj defines the object to use
  62442. * @param tagsString defines the tags to remove
  62443. */
  62444. static RemoveTagsFrom(obj: any, tagsString: string): void;
  62445. /**
  62446. * @hidden
  62447. */
  62448. static _RemoveTagFrom(obj: any, tag: string): void;
  62449. /**
  62450. * Defines if tags hosted on an object match a given query
  62451. * @param obj defines the object to use
  62452. * @param tagsQuery defines the tag query
  62453. * @returns a boolean
  62454. */
  62455. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  62456. }
  62457. }
  62458. declare module BABYLON {
  62459. /**
  62460. * Manages the defines for the Material
  62461. */
  62462. export class MaterialDefines {
  62463. private _keys;
  62464. private _isDirty;
  62465. /** @hidden */
  62466. _renderId: number;
  62467. /** @hidden */
  62468. _areLightsDirty: boolean;
  62469. /** @hidden */
  62470. _areAttributesDirty: boolean;
  62471. /** @hidden */
  62472. _areTexturesDirty: boolean;
  62473. /** @hidden */
  62474. _areFresnelDirty: boolean;
  62475. /** @hidden */
  62476. _areMiscDirty: boolean;
  62477. /** @hidden */
  62478. _areImageProcessingDirty: boolean;
  62479. /** @hidden */
  62480. _normals: boolean;
  62481. /** @hidden */
  62482. _uvs: boolean;
  62483. /** @hidden */
  62484. _needNormals: boolean;
  62485. /** @hidden */
  62486. _needUVs: boolean;
  62487. /**
  62488. * Specifies if the material needs to be re-calculated
  62489. */
  62490. readonly isDirty: boolean;
  62491. /**
  62492. * Marks the material to indicate that it has been re-calculated
  62493. */
  62494. markAsProcessed(): void;
  62495. /**
  62496. * Marks the material to indicate that it needs to be re-calculated
  62497. */
  62498. markAsUnprocessed(): void;
  62499. /**
  62500. * Marks the material to indicate all of its defines need to be re-calculated
  62501. */
  62502. markAllAsDirty(): void;
  62503. /**
  62504. * Marks the material to indicate that image processing needs to be re-calculated
  62505. */
  62506. markAsImageProcessingDirty(): void;
  62507. /**
  62508. * Marks the material to indicate the lights need to be re-calculated
  62509. */
  62510. markAsLightDirty(): void;
  62511. /**
  62512. * Marks the attribute state as changed
  62513. */
  62514. markAsAttributesDirty(): void;
  62515. /**
  62516. * Marks the texture state as changed
  62517. */
  62518. markAsTexturesDirty(): void;
  62519. /**
  62520. * Marks the fresnel state as changed
  62521. */
  62522. markAsFresnelDirty(): void;
  62523. /**
  62524. * Marks the misc state as changed
  62525. */
  62526. markAsMiscDirty(): void;
  62527. /**
  62528. * Rebuilds the material defines
  62529. */
  62530. rebuild(): void;
  62531. /**
  62532. * Specifies if two material defines are equal
  62533. * @param other - A material define instance to compare to
  62534. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  62535. */
  62536. isEqual(other: MaterialDefines): boolean;
  62537. /**
  62538. * Clones this instance's defines to another instance
  62539. * @param other - material defines to clone values to
  62540. */
  62541. cloneTo(other: MaterialDefines): void;
  62542. /**
  62543. * Resets the material define values
  62544. */
  62545. reset(): void;
  62546. /**
  62547. * Converts the material define values to a string
  62548. * @returns - String of material define information
  62549. */
  62550. toString(): string;
  62551. }
  62552. }
  62553. declare module BABYLON {
  62554. /**
  62555. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  62556. */
  62557. export class PerformanceMonitor {
  62558. private _enabled;
  62559. private _rollingFrameTime;
  62560. private _lastFrameTimeMs;
  62561. /**
  62562. * constructor
  62563. * @param frameSampleSize The number of samples required to saturate the sliding window
  62564. */
  62565. constructor(frameSampleSize?: number);
  62566. /**
  62567. * Samples current frame
  62568. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  62569. */
  62570. sampleFrame(timeMs?: number): void;
  62571. /**
  62572. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  62573. */
  62574. readonly averageFrameTime: number;
  62575. /**
  62576. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  62577. */
  62578. readonly averageFrameTimeVariance: number;
  62579. /**
  62580. * Returns the frame time of the most recent frame
  62581. */
  62582. readonly instantaneousFrameTime: number;
  62583. /**
  62584. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  62585. */
  62586. readonly averageFPS: number;
  62587. /**
  62588. * Returns the average framerate in frames per second using the most recent frame time
  62589. */
  62590. readonly instantaneousFPS: number;
  62591. /**
  62592. * Returns true if enough samples have been taken to completely fill the sliding window
  62593. */
  62594. readonly isSaturated: boolean;
  62595. /**
  62596. * Enables contributions to the sliding window sample set
  62597. */
  62598. enable(): void;
  62599. /**
  62600. * Disables contributions to the sliding window sample set
  62601. * Samples will not be interpolated over the disabled period
  62602. */
  62603. disable(): void;
  62604. /**
  62605. * Returns true if sampling is enabled
  62606. */
  62607. readonly isEnabled: boolean;
  62608. /**
  62609. * Resets performance monitor
  62610. */
  62611. reset(): void;
  62612. }
  62613. /**
  62614. * RollingAverage
  62615. *
  62616. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  62617. */
  62618. export class RollingAverage {
  62619. /**
  62620. * Current average
  62621. */
  62622. average: number;
  62623. /**
  62624. * Current variance
  62625. */
  62626. variance: number;
  62627. protected _samples: Array<number>;
  62628. protected _sampleCount: number;
  62629. protected _pos: number;
  62630. protected _m2: number;
  62631. /**
  62632. * constructor
  62633. * @param length The number of samples required to saturate the sliding window
  62634. */
  62635. constructor(length: number);
  62636. /**
  62637. * Adds a sample to the sample set
  62638. * @param v The sample value
  62639. */
  62640. add(v: number): void;
  62641. /**
  62642. * Returns previously added values or null if outside of history or outside the sliding window domain
  62643. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  62644. * @return Value previously recorded with add() or null if outside of range
  62645. */
  62646. history(i: number): number;
  62647. /**
  62648. * Returns true if enough samples have been taken to completely fill the sliding window
  62649. * @return true if sample-set saturated
  62650. */
  62651. isSaturated(): boolean;
  62652. /**
  62653. * Resets the rolling average (equivalent to 0 samples taken so far)
  62654. */
  62655. reset(): void;
  62656. /**
  62657. * Wraps a value around the sample range boundaries
  62658. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  62659. * @return Wrapped position in sample range
  62660. */
  62661. protected _wrapPosition(i: number): number;
  62662. }
  62663. }
  62664. declare module BABYLON {
  62665. /**
  62666. * This class implement a typical dictionary using a string as key and the generic type T as value.
  62667. * The underlying implementation relies on an associative array to ensure the best performances.
  62668. * The value can be anything including 'null' but except 'undefined'
  62669. */
  62670. export class StringDictionary<T> {
  62671. /**
  62672. * This will clear this dictionary and copy the content from the 'source' one.
  62673. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  62674. * @param source the dictionary to take the content from and copy to this dictionary
  62675. */
  62676. copyFrom(source: StringDictionary<T>): void;
  62677. /**
  62678. * Get a value based from its key
  62679. * @param key the given key to get the matching value from
  62680. * @return the value if found, otherwise undefined is returned
  62681. */
  62682. get(key: string): T | undefined;
  62683. /**
  62684. * Get a value from its key or add it if it doesn't exist.
  62685. * This method will ensure you that a given key/data will be present in the dictionary.
  62686. * @param key the given key to get the matching value from
  62687. * @param factory the factory that will create the value if the key is not present in the dictionary.
  62688. * The factory will only be invoked if there's no data for the given key.
  62689. * @return the value corresponding to the key.
  62690. */
  62691. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  62692. /**
  62693. * Get a value from its key if present in the dictionary otherwise add it
  62694. * @param key the key to get the value from
  62695. * @param val if there's no such key/value pair in the dictionary add it with this value
  62696. * @return the value corresponding to the key
  62697. */
  62698. getOrAdd(key: string, val: T): T;
  62699. /**
  62700. * Check if there's a given key in the dictionary
  62701. * @param key the key to check for
  62702. * @return true if the key is present, false otherwise
  62703. */
  62704. contains(key: string): boolean;
  62705. /**
  62706. * Add a new key and its corresponding value
  62707. * @param key the key to add
  62708. * @param value the value corresponding to the key
  62709. * @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
  62710. */
  62711. add(key: string, value: T): boolean;
  62712. /**
  62713. * Update a specific value associated to a key
  62714. * @param key defines the key to use
  62715. * @param value defines the value to store
  62716. * @returns true if the value was updated (or false if the key was not found)
  62717. */
  62718. set(key: string, value: T): boolean;
  62719. /**
  62720. * Get the element of the given key and remove it from the dictionary
  62721. * @param key defines the key to search
  62722. * @returns the value associated with the key or null if not found
  62723. */
  62724. getAndRemove(key: string): Nullable<T>;
  62725. /**
  62726. * Remove a key/value from the dictionary.
  62727. * @param key the key to remove
  62728. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  62729. */
  62730. remove(key: string): boolean;
  62731. /**
  62732. * Clear the whole content of the dictionary
  62733. */
  62734. clear(): void;
  62735. /**
  62736. * Gets the current count
  62737. */
  62738. readonly count: number;
  62739. /**
  62740. * Execute a callback on each key/val of the dictionary.
  62741. * Note that you can remove any element in this dictionary in the callback implementation
  62742. * @param callback the callback to execute on a given key/value pair
  62743. */
  62744. forEach(callback: (key: string, val: T) => void): void;
  62745. /**
  62746. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  62747. * If the callback returns null or undefined the method will iterate to the next key/value pair
  62748. * Note that you can remove any element in this dictionary in the callback implementation
  62749. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  62750. * @returns the first item
  62751. */
  62752. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  62753. private _count;
  62754. private _data;
  62755. }
  62756. }
  62757. declare module BABYLON {
  62758. /**
  62759. * Helper class that provides a small promise polyfill
  62760. */
  62761. export class PromisePolyfill {
  62762. /**
  62763. * Static function used to check if the polyfill is required
  62764. * If this is the case then the function will inject the polyfill to window.Promise
  62765. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  62766. */
  62767. static Apply(force?: boolean): void;
  62768. }
  62769. }
  62770. declare module BABYLON {
  62771. /**
  62772. * Class used to store data that will be store in GPU memory
  62773. */
  62774. export class Buffer {
  62775. private _engine;
  62776. private _buffer;
  62777. /** @hidden */
  62778. _data: Nullable<DataArray>;
  62779. private _updatable;
  62780. private _instanced;
  62781. /**
  62782. * Gets the byte stride.
  62783. */
  62784. readonly byteStride: number;
  62785. /**
  62786. * Constructor
  62787. * @param engine the engine
  62788. * @param data the data to use for this buffer
  62789. * @param updatable whether the data is updatable
  62790. * @param stride the stride (optional)
  62791. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  62792. * @param instanced whether the buffer is instanced (optional)
  62793. * @param useBytes set to true if the stride in in bytes (optional)
  62794. */
  62795. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  62796. /**
  62797. * Create a new VertexBuffer based on the current buffer
  62798. * @param kind defines the vertex buffer kind (position, normal, etc.)
  62799. * @param offset defines offset in the buffer (0 by default)
  62800. * @param size defines the size in floats of attributes (position is 3 for instance)
  62801. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  62802. * @param instanced defines if the vertex buffer contains indexed data
  62803. * @param useBytes defines if the offset and stride are in bytes
  62804. * @returns the new vertex buffer
  62805. */
  62806. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  62807. /**
  62808. * Gets a boolean indicating if the Buffer is updatable?
  62809. * @returns true if the buffer is updatable
  62810. */
  62811. isUpdatable(): boolean;
  62812. /**
  62813. * Gets current buffer's data
  62814. * @returns a DataArray or null
  62815. */
  62816. getData(): Nullable<DataArray>;
  62817. /**
  62818. * Gets underlying native buffer
  62819. * @returns underlying native buffer
  62820. */
  62821. getBuffer(): Nullable<WebGLBuffer>;
  62822. /**
  62823. * Gets the stride in float32 units (i.e. byte stride / 4).
  62824. * May not be an integer if the byte stride is not divisible by 4.
  62825. * DEPRECATED. Use byteStride instead.
  62826. * @returns the stride in float32 units
  62827. */
  62828. getStrideSize(): number;
  62829. /**
  62830. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  62831. * @param data defines the data to store
  62832. */
  62833. create(data?: Nullable<DataArray>): void;
  62834. /** @hidden */
  62835. _rebuild(): void;
  62836. /**
  62837. * Update current buffer data
  62838. * @param data defines the data to store
  62839. */
  62840. update(data: DataArray): void;
  62841. /**
  62842. * Updates the data directly.
  62843. * @param data the new data
  62844. * @param offset the new offset
  62845. * @param vertexCount the vertex count (optional)
  62846. * @param useBytes set to true if the offset is in bytes
  62847. */
  62848. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  62849. /**
  62850. * Release all resources
  62851. */
  62852. dispose(): void;
  62853. }
  62854. /**
  62855. * Specialized buffer used to store vertex data
  62856. */
  62857. export class VertexBuffer {
  62858. /** @hidden */
  62859. _buffer: Buffer;
  62860. private _kind;
  62861. private _size;
  62862. private _ownsBuffer;
  62863. private _instanced;
  62864. private _instanceDivisor;
  62865. /**
  62866. * The byte type.
  62867. */
  62868. static readonly BYTE: number;
  62869. /**
  62870. * The unsigned byte type.
  62871. */
  62872. static readonly UNSIGNED_BYTE: number;
  62873. /**
  62874. * The short type.
  62875. */
  62876. static readonly SHORT: number;
  62877. /**
  62878. * The unsigned short type.
  62879. */
  62880. static readonly UNSIGNED_SHORT: number;
  62881. /**
  62882. * The integer type.
  62883. */
  62884. static readonly INT: number;
  62885. /**
  62886. * The unsigned integer type.
  62887. */
  62888. static readonly UNSIGNED_INT: number;
  62889. /**
  62890. * The float type.
  62891. */
  62892. static readonly FLOAT: number;
  62893. /**
  62894. * Gets or sets the instance divisor when in instanced mode
  62895. */
  62896. instanceDivisor: number;
  62897. /**
  62898. * Gets the byte stride.
  62899. */
  62900. readonly byteStride: number;
  62901. /**
  62902. * Gets the byte offset.
  62903. */
  62904. readonly byteOffset: number;
  62905. /**
  62906. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  62907. */
  62908. readonly normalized: boolean;
  62909. /**
  62910. * Gets the data type of each component in the array.
  62911. */
  62912. readonly type: number;
  62913. /**
  62914. * Constructor
  62915. * @param engine the engine
  62916. * @param data the data to use for this vertex buffer
  62917. * @param kind the vertex buffer kind
  62918. * @param updatable whether the data is updatable
  62919. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  62920. * @param stride the stride (optional)
  62921. * @param instanced whether the buffer is instanced (optional)
  62922. * @param offset the offset of the data (optional)
  62923. * @param size the number of components (optional)
  62924. * @param type the type of the component (optional)
  62925. * @param normalized whether the data contains normalized data (optional)
  62926. * @param useBytes set to true if stride and offset are in bytes (optional)
  62927. */
  62928. 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);
  62929. /** @hidden */
  62930. _rebuild(): void;
  62931. /**
  62932. * Returns the kind of the VertexBuffer (string)
  62933. * @returns a string
  62934. */
  62935. getKind(): string;
  62936. /**
  62937. * Gets a boolean indicating if the VertexBuffer is updatable?
  62938. * @returns true if the buffer is updatable
  62939. */
  62940. isUpdatable(): boolean;
  62941. /**
  62942. * Gets current buffer's data
  62943. * @returns a DataArray or null
  62944. */
  62945. getData(): Nullable<DataArray>;
  62946. /**
  62947. * Gets underlying native buffer
  62948. * @returns underlying native buffer
  62949. */
  62950. getBuffer(): Nullable<WebGLBuffer>;
  62951. /**
  62952. * Gets the stride in float32 units (i.e. byte stride / 4).
  62953. * May not be an integer if the byte stride is not divisible by 4.
  62954. * DEPRECATED. Use byteStride instead.
  62955. * @returns the stride in float32 units
  62956. */
  62957. getStrideSize(): number;
  62958. /**
  62959. * Returns the offset as a multiple of the type byte length.
  62960. * DEPRECATED. Use byteOffset instead.
  62961. * @returns the offset in bytes
  62962. */
  62963. getOffset(): number;
  62964. /**
  62965. * Returns the number of components per vertex attribute (integer)
  62966. * @returns the size in float
  62967. */
  62968. getSize(): number;
  62969. /**
  62970. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  62971. * @returns true if this buffer is instanced
  62972. */
  62973. getIsInstanced(): boolean;
  62974. /**
  62975. * Returns the instancing divisor, zero for non-instanced (integer).
  62976. * @returns a number
  62977. */
  62978. getInstanceDivisor(): number;
  62979. /**
  62980. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  62981. * @param data defines the data to store
  62982. */
  62983. create(data?: DataArray): void;
  62984. /**
  62985. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  62986. * This function will create a new buffer if the current one is not updatable
  62987. * @param data defines the data to store
  62988. */
  62989. update(data: DataArray): void;
  62990. /**
  62991. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  62992. * Returns the directly updated WebGLBuffer.
  62993. * @param data the new data
  62994. * @param offset the new offset
  62995. * @param useBytes set to true if the offset is in bytes
  62996. */
  62997. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  62998. /**
  62999. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  63000. */
  63001. dispose(): void;
  63002. /**
  63003. * Enumerates each value of this vertex buffer as numbers.
  63004. * @param count the number of values to enumerate
  63005. * @param callback the callback function called for each value
  63006. */
  63007. forEach(count: number, callback: (value: number, index: number) => void): void;
  63008. /**
  63009. * Positions
  63010. */
  63011. static readonly PositionKind: string;
  63012. /**
  63013. * Normals
  63014. */
  63015. static readonly NormalKind: string;
  63016. /**
  63017. * Tangents
  63018. */
  63019. static readonly TangentKind: string;
  63020. /**
  63021. * Texture coordinates
  63022. */
  63023. static readonly UVKind: string;
  63024. /**
  63025. * Texture coordinates 2
  63026. */
  63027. static readonly UV2Kind: string;
  63028. /**
  63029. * Texture coordinates 3
  63030. */
  63031. static readonly UV3Kind: string;
  63032. /**
  63033. * Texture coordinates 4
  63034. */
  63035. static readonly UV4Kind: string;
  63036. /**
  63037. * Texture coordinates 5
  63038. */
  63039. static readonly UV5Kind: string;
  63040. /**
  63041. * Texture coordinates 6
  63042. */
  63043. static readonly UV6Kind: string;
  63044. /**
  63045. * Colors
  63046. */
  63047. static readonly ColorKind: string;
  63048. /**
  63049. * Matrix indices (for bones)
  63050. */
  63051. static readonly MatricesIndicesKind: string;
  63052. /**
  63053. * Matrix weights (for bones)
  63054. */
  63055. static readonly MatricesWeightsKind: string;
  63056. /**
  63057. * Additional matrix indices (for bones)
  63058. */
  63059. static readonly MatricesIndicesExtraKind: string;
  63060. /**
  63061. * Additional matrix weights (for bones)
  63062. */
  63063. static readonly MatricesWeightsExtraKind: string;
  63064. /**
  63065. * Deduces the stride given a kind.
  63066. * @param kind The kind string to deduce
  63067. * @returns The deduced stride
  63068. */
  63069. static DeduceStride(kind: string): number;
  63070. /**
  63071. * Gets the byte length of the given type.
  63072. * @param type the type
  63073. * @returns the number of bytes
  63074. */
  63075. static GetTypeByteLength(type: number): number;
  63076. /**
  63077. * Enumerates each value of the given parameters as numbers.
  63078. * @param data the data to enumerate
  63079. * @param byteOffset the byte offset of the data
  63080. * @param byteStride the byte stride of the data
  63081. * @param componentCount the number of components per element
  63082. * @param componentType the type of the component
  63083. * @param count the total number of components
  63084. * @param normalized whether the data is normalized
  63085. * @param callback the callback function called for each value
  63086. */
  63087. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  63088. private static _GetFloatValue;
  63089. }
  63090. }
  63091. declare module BABYLON {
  63092. /**
  63093. * Class representing spherical polynomial coefficients to the 3rd degree
  63094. */
  63095. export class SphericalPolynomial {
  63096. /**
  63097. * The x coefficients of the spherical polynomial
  63098. */
  63099. x: Vector3;
  63100. /**
  63101. * The y coefficients of the spherical polynomial
  63102. */
  63103. y: Vector3;
  63104. /**
  63105. * The z coefficients of the spherical polynomial
  63106. */
  63107. z: Vector3;
  63108. /**
  63109. * The xx coefficients of the spherical polynomial
  63110. */
  63111. xx: Vector3;
  63112. /**
  63113. * The yy coefficients of the spherical polynomial
  63114. */
  63115. yy: Vector3;
  63116. /**
  63117. * The zz coefficients of the spherical polynomial
  63118. */
  63119. zz: Vector3;
  63120. /**
  63121. * The xy coefficients of the spherical polynomial
  63122. */
  63123. xy: Vector3;
  63124. /**
  63125. * The yz coefficients of the spherical polynomial
  63126. */
  63127. yz: Vector3;
  63128. /**
  63129. * The zx coefficients of the spherical polynomial
  63130. */
  63131. zx: Vector3;
  63132. /**
  63133. * Adds an ambient color to the spherical polynomial
  63134. * @param color the color to add
  63135. */
  63136. addAmbient(color: Color3): void;
  63137. /**
  63138. * Scales the spherical polynomial by the given amount
  63139. * @param scale the amount to scale
  63140. */
  63141. scale(scale: number): void;
  63142. /**
  63143. * Gets the spherical polynomial from harmonics
  63144. * @param harmonics the spherical harmonics
  63145. * @returns the spherical polynomial
  63146. */
  63147. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  63148. /**
  63149. * Constructs a spherical polynomial from an array.
  63150. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  63151. * @returns the spherical polynomial
  63152. */
  63153. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  63154. }
  63155. /**
  63156. * Class representing spherical harmonics coefficients to the 3rd degree
  63157. */
  63158. export class SphericalHarmonics {
  63159. /**
  63160. * The l0,0 coefficients of the spherical harmonics
  63161. */
  63162. l00: Vector3;
  63163. /**
  63164. * The l1,-1 coefficients of the spherical harmonics
  63165. */
  63166. l1_1: Vector3;
  63167. /**
  63168. * The l1,0 coefficients of the spherical harmonics
  63169. */
  63170. l10: Vector3;
  63171. /**
  63172. * The l1,1 coefficients of the spherical harmonics
  63173. */
  63174. l11: Vector3;
  63175. /**
  63176. * The l2,-2 coefficients of the spherical harmonics
  63177. */
  63178. l2_2: Vector3;
  63179. /**
  63180. * The l2,-1 coefficients of the spherical harmonics
  63181. */
  63182. l2_1: Vector3;
  63183. /**
  63184. * The l2,0 coefficients of the spherical harmonics
  63185. */
  63186. l20: Vector3;
  63187. /**
  63188. * The l2,1 coefficients of the spherical harmonics
  63189. */
  63190. l21: Vector3;
  63191. /**
  63192. * The l2,2 coefficients of the spherical harmonics
  63193. */
  63194. lL22: Vector3;
  63195. /**
  63196. * Adds a light to the spherical harmonics
  63197. * @param direction the direction of the light
  63198. * @param color the color of the light
  63199. * @param deltaSolidAngle the delta solid angle of the light
  63200. */
  63201. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  63202. /**
  63203. * Scales the spherical harmonics by the given amount
  63204. * @param scale the amount to scale
  63205. */
  63206. scale(scale: number): void;
  63207. /**
  63208. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  63209. *
  63210. * ```
  63211. * E_lm = A_l * L_lm
  63212. * ```
  63213. *
  63214. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  63215. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  63216. * the scaling factors are given in equation 9.
  63217. */
  63218. convertIncidentRadianceToIrradiance(): void;
  63219. /**
  63220. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  63221. *
  63222. * ```
  63223. * L = (1/pi) * E * rho
  63224. * ```
  63225. *
  63226. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  63227. */
  63228. convertIrradianceToLambertianRadiance(): void;
  63229. /**
  63230. * Gets the spherical harmonics from polynomial
  63231. * @param polynomial the spherical polynomial
  63232. * @returns the spherical harmonics
  63233. */
  63234. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  63235. /**
  63236. * Constructs a spherical harmonics from an array.
  63237. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  63238. * @returns the spherical harmonics
  63239. */
  63240. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  63241. }
  63242. }
  63243. declare module BABYLON {
  63244. /**
  63245. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  63246. */
  63247. export interface CubeMapInfo {
  63248. /**
  63249. * The pixel array for the front face.
  63250. * This is stored in format, left to right, up to down format.
  63251. */
  63252. front: Nullable<ArrayBufferView>;
  63253. /**
  63254. * The pixel array for the back face.
  63255. * This is stored in format, left to right, up to down format.
  63256. */
  63257. back: Nullable<ArrayBufferView>;
  63258. /**
  63259. * The pixel array for the left face.
  63260. * This is stored in format, left to right, up to down format.
  63261. */
  63262. left: Nullable<ArrayBufferView>;
  63263. /**
  63264. * The pixel array for the right face.
  63265. * This is stored in format, left to right, up to down format.
  63266. */
  63267. right: Nullable<ArrayBufferView>;
  63268. /**
  63269. * The pixel array for the up face.
  63270. * This is stored in format, left to right, up to down format.
  63271. */
  63272. up: Nullable<ArrayBufferView>;
  63273. /**
  63274. * The pixel array for the down face.
  63275. * This is stored in format, left to right, up to down format.
  63276. */
  63277. down: Nullable<ArrayBufferView>;
  63278. /**
  63279. * The size of the cubemap stored.
  63280. *
  63281. * Each faces will be size * size pixels.
  63282. */
  63283. size: number;
  63284. /**
  63285. * The format of the texture.
  63286. *
  63287. * RGBA, RGB.
  63288. */
  63289. format: number;
  63290. /**
  63291. * The type of the texture data.
  63292. *
  63293. * UNSIGNED_INT, FLOAT.
  63294. */
  63295. type: number;
  63296. /**
  63297. * Specifies whether the texture is in gamma space.
  63298. */
  63299. gammaSpace: boolean;
  63300. }
  63301. /**
  63302. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  63303. */
  63304. export class PanoramaToCubeMapTools {
  63305. private static FACE_FRONT;
  63306. private static FACE_BACK;
  63307. private static FACE_RIGHT;
  63308. private static FACE_LEFT;
  63309. private static FACE_DOWN;
  63310. private static FACE_UP;
  63311. /**
  63312. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  63313. *
  63314. * @param float32Array The source data.
  63315. * @param inputWidth The width of the input panorama.
  63316. * @param inputHeight The height of the input panorama.
  63317. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  63318. * @return The cubemap data
  63319. */
  63320. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  63321. private static CreateCubemapTexture;
  63322. private static CalcProjectionSpherical;
  63323. }
  63324. }
  63325. declare module BABYLON {
  63326. /**
  63327. * Helper class dealing with the extraction of spherical polynomial dataArray
  63328. * from a cube map.
  63329. */
  63330. export class CubeMapToSphericalPolynomialTools {
  63331. private static FileFaces;
  63332. /**
  63333. * Converts a texture to the according Spherical Polynomial data.
  63334. * This extracts the first 3 orders only as they are the only one used in the lighting.
  63335. *
  63336. * @param texture The texture to extract the information from.
  63337. * @return The Spherical Polynomial data.
  63338. */
  63339. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): SphericalPolynomial | null;
  63340. /**
  63341. * Converts a cubemap to the according Spherical Polynomial data.
  63342. * This extracts the first 3 orders only as they are the only one used in the lighting.
  63343. *
  63344. * @param cubeInfo The Cube map to extract the information from.
  63345. * @return The Spherical Polynomial data.
  63346. */
  63347. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  63348. }
  63349. }
  63350. declare module BABYLON {
  63351. /**
  63352. * The engine store class is responsible to hold all the instances of Engine and Scene created
  63353. * during the life time of the application.
  63354. */
  63355. export class EngineStore {
  63356. /** Gets the list of created engines */
  63357. static Instances: Engine[];
  63358. /**
  63359. * Gets the latest created engine
  63360. */
  63361. static readonly LastCreatedEngine: Nullable<Engine>;
  63362. /**
  63363. * Gets the latest created scene
  63364. */
  63365. static readonly LastCreatedScene: Nullable<Scene>;
  63366. }
  63367. }
  63368. declare module BABYLON {
  63369. /**
  63370. * Define options used to create a render target texture
  63371. */
  63372. export class RenderTargetCreationOptions {
  63373. /**
  63374. * Specifies is mipmaps must be generated
  63375. */
  63376. generateMipMaps?: boolean;
  63377. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  63378. generateDepthBuffer?: boolean;
  63379. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  63380. generateStencilBuffer?: boolean;
  63381. /** Defines texture type (int by default) */
  63382. type?: number;
  63383. /** Defines sampling mode (trilinear by default) */
  63384. samplingMode?: number;
  63385. /** Defines format (RGBA by default) */
  63386. format?: number;
  63387. }
  63388. }
  63389. declare module BABYLON {
  63390. /**
  63391. * @hidden
  63392. **/
  63393. export class _AlphaState {
  63394. private _isAlphaBlendDirty;
  63395. private _isBlendFunctionParametersDirty;
  63396. private _isBlendEquationParametersDirty;
  63397. private _isBlendConstantsDirty;
  63398. private _alphaBlend;
  63399. private _blendFunctionParameters;
  63400. private _blendEquationParameters;
  63401. private _blendConstants;
  63402. /**
  63403. * Initializes the state.
  63404. */
  63405. constructor();
  63406. readonly isDirty: boolean;
  63407. alphaBlend: boolean;
  63408. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  63409. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  63410. setAlphaEquationParameters(rgb: number, alpha: number): void;
  63411. reset(): void;
  63412. apply(gl: WebGLRenderingContext): void;
  63413. }
  63414. }
  63415. declare module BABYLON {
  63416. /**
  63417. * @hidden
  63418. **/
  63419. export class _DepthCullingState {
  63420. private _isDepthTestDirty;
  63421. private _isDepthMaskDirty;
  63422. private _isDepthFuncDirty;
  63423. private _isCullFaceDirty;
  63424. private _isCullDirty;
  63425. private _isZOffsetDirty;
  63426. private _isFrontFaceDirty;
  63427. private _depthTest;
  63428. private _depthMask;
  63429. private _depthFunc;
  63430. private _cull;
  63431. private _cullFace;
  63432. private _zOffset;
  63433. private _frontFace;
  63434. /**
  63435. * Initializes the state.
  63436. */
  63437. constructor();
  63438. readonly isDirty: boolean;
  63439. zOffset: number;
  63440. cullFace: Nullable<number>;
  63441. cull: Nullable<boolean>;
  63442. depthFunc: Nullable<number>;
  63443. depthMask: boolean;
  63444. depthTest: boolean;
  63445. frontFace: Nullable<number>;
  63446. reset(): void;
  63447. apply(gl: WebGLRenderingContext): void;
  63448. }
  63449. }
  63450. declare module BABYLON {
  63451. /**
  63452. * @hidden
  63453. **/
  63454. export class _StencilState {
  63455. /** 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 */
  63456. static readonly ALWAYS: number;
  63457. /** Passed to stencilOperation to specify that stencil value must be kept */
  63458. static readonly KEEP: number;
  63459. /** Passed to stencilOperation to specify that stencil value must be replaced */
  63460. static readonly REPLACE: number;
  63461. private _isStencilTestDirty;
  63462. private _isStencilMaskDirty;
  63463. private _isStencilFuncDirty;
  63464. private _isStencilOpDirty;
  63465. private _stencilTest;
  63466. private _stencilMask;
  63467. private _stencilFunc;
  63468. private _stencilFuncRef;
  63469. private _stencilFuncMask;
  63470. private _stencilOpStencilFail;
  63471. private _stencilOpDepthFail;
  63472. private _stencilOpStencilDepthPass;
  63473. readonly isDirty: boolean;
  63474. stencilFunc: number;
  63475. stencilFuncRef: number;
  63476. stencilFuncMask: number;
  63477. stencilOpStencilFail: number;
  63478. stencilOpDepthFail: number;
  63479. stencilOpStencilDepthPass: number;
  63480. stencilMask: number;
  63481. stencilTest: boolean;
  63482. constructor();
  63483. reset(): void;
  63484. apply(gl: WebGLRenderingContext): void;
  63485. }
  63486. }
  63487. declare module BABYLON {
  63488. /**
  63489. * @hidden
  63490. **/
  63491. export class _TimeToken {
  63492. _startTimeQuery: Nullable<WebGLQuery>;
  63493. _endTimeQuery: Nullable<WebGLQuery>;
  63494. _timeElapsedQuery: Nullable<WebGLQuery>;
  63495. _timeElapsedQueryEnded: boolean;
  63496. }
  63497. }
  63498. declare module BABYLON {
  63499. /**
  63500. * Internal interface used to track InternalTexture already bound to the GL context
  63501. */
  63502. export interface IInternalTextureTracker {
  63503. /**
  63504. * Gets or set the previous tracker in the list
  63505. */
  63506. previous: Nullable<IInternalTextureTracker>;
  63507. /**
  63508. * Gets or set the next tracker in the list
  63509. */
  63510. next: Nullable<IInternalTextureTracker>;
  63511. }
  63512. /**
  63513. * Internal class used by the engine to get list of InternalTexture already bound to the GL context
  63514. */
  63515. export class DummyInternalTextureTracker {
  63516. /**
  63517. * Gets or set the previous tracker in the list
  63518. */
  63519. previous: Nullable<IInternalTextureTracker>;
  63520. /**
  63521. * Gets or set the next tracker in the list
  63522. */
  63523. next: Nullable<IInternalTextureTracker>;
  63524. }
  63525. }
  63526. declare module BABYLON {
  63527. /**
  63528. * Class used to store data associated with WebGL texture data for the engine
  63529. * This class should not be used directly
  63530. */
  63531. export class InternalTexture implements IInternalTextureTracker {
  63532. /** hidden */
  63533. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise<void>;
  63534. /**
  63535. * The source of the texture data is unknown
  63536. */
  63537. static DATASOURCE_UNKNOWN: number;
  63538. /**
  63539. * Texture data comes from an URL
  63540. */
  63541. static DATASOURCE_URL: number;
  63542. /**
  63543. * Texture data is only used for temporary storage
  63544. */
  63545. static DATASOURCE_TEMP: number;
  63546. /**
  63547. * Texture data comes from raw data (ArrayBuffer)
  63548. */
  63549. static DATASOURCE_RAW: number;
  63550. /**
  63551. * Texture content is dynamic (video or dynamic texture)
  63552. */
  63553. static DATASOURCE_DYNAMIC: number;
  63554. /**
  63555. * Texture content is generated by rendering to it
  63556. */
  63557. static DATASOURCE_RENDERTARGET: number;
  63558. /**
  63559. * Texture content is part of a multi render target process
  63560. */
  63561. static DATASOURCE_MULTIRENDERTARGET: number;
  63562. /**
  63563. * Texture data comes from a cube data file
  63564. */
  63565. static DATASOURCE_CUBE: number;
  63566. /**
  63567. * Texture data comes from a raw cube data
  63568. */
  63569. static DATASOURCE_CUBERAW: number;
  63570. /**
  63571. * Texture data come from a prefiltered cube data file
  63572. */
  63573. static DATASOURCE_CUBEPREFILTERED: number;
  63574. /**
  63575. * Texture content is raw 3D data
  63576. */
  63577. static DATASOURCE_RAW3D: number;
  63578. /**
  63579. * Texture content is a depth texture
  63580. */
  63581. static DATASOURCE_DEPTHTEXTURE: number;
  63582. /**
  63583. * Texture data comes from a raw cube data encoded with RGBD
  63584. */
  63585. static DATASOURCE_CUBERAW_RGBD: number;
  63586. /**
  63587. * Defines if the texture is ready
  63588. */
  63589. isReady: boolean;
  63590. /**
  63591. * Defines if the texture is a cube texture
  63592. */
  63593. isCube: boolean;
  63594. /**
  63595. * Defines if the texture contains 3D data
  63596. */
  63597. is3D: boolean;
  63598. /**
  63599. * Gets the URL used to load this texture
  63600. */
  63601. url: string;
  63602. /**
  63603. * Gets the sampling mode of the texture
  63604. */
  63605. samplingMode: number;
  63606. /**
  63607. * Gets a boolean indicating if the texture needs mipmaps generation
  63608. */
  63609. generateMipMaps: boolean;
  63610. /**
  63611. * Gets the number of samples used by the texture (WebGL2+ only)
  63612. */
  63613. samples: number;
  63614. /**
  63615. * Gets the type of the texture (int, float...)
  63616. */
  63617. type: number;
  63618. /**
  63619. * Gets the format of the texture (RGB, RGBA...)
  63620. */
  63621. format: number;
  63622. /**
  63623. * Observable called when the texture is loaded
  63624. */
  63625. onLoadedObservable: Observable<InternalTexture>;
  63626. /**
  63627. * Gets the width of the texture
  63628. */
  63629. width: number;
  63630. /**
  63631. * Gets the height of the texture
  63632. */
  63633. height: number;
  63634. /**
  63635. * Gets the depth of the texture
  63636. */
  63637. depth: number;
  63638. /**
  63639. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  63640. */
  63641. baseWidth: number;
  63642. /**
  63643. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  63644. */
  63645. baseHeight: number;
  63646. /**
  63647. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  63648. */
  63649. baseDepth: number;
  63650. /**
  63651. * Gets a boolean indicating if the texture is inverted on Y axis
  63652. */
  63653. invertY: boolean;
  63654. /**
  63655. * Gets or set the previous tracker in the list
  63656. */
  63657. previous: Nullable<IInternalTextureTracker>;
  63658. /**
  63659. * Gets or set the next tracker in the list
  63660. */
  63661. next: Nullable<IInternalTextureTracker>;
  63662. /** @hidden */
  63663. _invertVScale: boolean;
  63664. /** @hidden */
  63665. _initialSlot: number;
  63666. /** @hidden */
  63667. _designatedSlot: number;
  63668. /** @hidden */
  63669. _dataSource: number;
  63670. /** @hidden */
  63671. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  63672. /** @hidden */
  63673. _bufferView: Nullable<ArrayBufferView>;
  63674. /** @hidden */
  63675. _bufferViewArray: Nullable<ArrayBufferView[]>;
  63676. /** @hidden */
  63677. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  63678. /** @hidden */
  63679. _size: number;
  63680. /** @hidden */
  63681. _extension: string;
  63682. /** @hidden */
  63683. _files: Nullable<string[]>;
  63684. /** @hidden */
  63685. _workingCanvas: HTMLCanvasElement;
  63686. /** @hidden */
  63687. _workingContext: CanvasRenderingContext2D;
  63688. /** @hidden */
  63689. _framebuffer: Nullable<WebGLFramebuffer>;
  63690. /** @hidden */
  63691. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  63692. /** @hidden */
  63693. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  63694. /** @hidden */
  63695. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  63696. /** @hidden */
  63697. _attachments: Nullable<number[]>;
  63698. /** @hidden */
  63699. _cachedCoordinatesMode: Nullable<number>;
  63700. /** @hidden */
  63701. _cachedWrapU: Nullable<number>;
  63702. /** @hidden */
  63703. _cachedWrapV: Nullable<number>;
  63704. /** @hidden */
  63705. _cachedWrapR: Nullable<number>;
  63706. /** @hidden */
  63707. _cachedAnisotropicFilteringLevel: Nullable<number>;
  63708. /** @hidden */
  63709. _isDisabled: boolean;
  63710. /** @hidden */
  63711. _compression: Nullable<string>;
  63712. /** @hidden */
  63713. _generateStencilBuffer: boolean;
  63714. /** @hidden */
  63715. _generateDepthBuffer: boolean;
  63716. /** @hidden */
  63717. _comparisonFunction: number;
  63718. /** @hidden */
  63719. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  63720. /** @hidden */
  63721. _lodGenerationScale: number;
  63722. /** @hidden */
  63723. _lodGenerationOffset: number;
  63724. /** @hidden */
  63725. _lodTextureHigh: BaseTexture;
  63726. /** @hidden */
  63727. _lodTextureMid: BaseTexture;
  63728. /** @hidden */
  63729. _lodTextureLow: BaseTexture;
  63730. /** @hidden */
  63731. _isRGBD: boolean;
  63732. /** @hidden */
  63733. _webGLTexture: Nullable<WebGLTexture>;
  63734. /** @hidden */
  63735. _references: number;
  63736. private _engine;
  63737. /**
  63738. * Gets the Engine the texture belongs to.
  63739. * @returns The babylon engine
  63740. */
  63741. getEngine(): Engine;
  63742. /**
  63743. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  63744. */
  63745. readonly dataSource: number;
  63746. /**
  63747. * Creates a new InternalTexture
  63748. * @param engine defines the engine to use
  63749. * @param dataSource defines the type of data that will be used
  63750. * @param delayAllocation if the texture allocation should be delayed (default: false)
  63751. */
  63752. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  63753. /**
  63754. * Increments the number of references (ie. the number of Texture that point to it)
  63755. */
  63756. incrementReferences(): void;
  63757. /**
  63758. * Change the size of the texture (not the size of the content)
  63759. * @param width defines the new width
  63760. * @param height defines the new height
  63761. * @param depth defines the new depth (1 by default)
  63762. */
  63763. updateSize(width: int, height: int, depth?: int): void;
  63764. /** @hidden */
  63765. _rebuild(): void;
  63766. /** @hidden */
  63767. _swapAndDie(target: InternalTexture): void;
  63768. /**
  63769. * Dispose the current allocated resources
  63770. */
  63771. dispose(): void;
  63772. }
  63773. }
  63774. declare module BABYLON {
  63775. /**
  63776. * This represents the main contract an easing function should follow.
  63777. * Easing functions are used throughout the animation system.
  63778. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  63779. */
  63780. export interface IEasingFunction {
  63781. /**
  63782. * Given an input gradient between 0 and 1, this returns the corrseponding value
  63783. * of the easing function.
  63784. * The link below provides some of the most common examples of easing functions.
  63785. * @see https://easings.net/
  63786. * @param gradient Defines the value between 0 and 1 we want the easing value for
  63787. * @returns the corresponding value on the curve defined by the easing function
  63788. */
  63789. ease(gradient: number): number;
  63790. }
  63791. /**
  63792. * Base class used for every default easing function.
  63793. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  63794. */
  63795. export class EasingFunction implements IEasingFunction {
  63796. /**
  63797. * Interpolation follows the mathematical formula associated with the easing function.
  63798. */
  63799. static readonly EASINGMODE_EASEIN: number;
  63800. /**
  63801. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  63802. */
  63803. static readonly EASINGMODE_EASEOUT: number;
  63804. /**
  63805. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  63806. */
  63807. static readonly EASINGMODE_EASEINOUT: number;
  63808. private _easingMode;
  63809. /**
  63810. * Sets the easing mode of the current function.
  63811. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  63812. */
  63813. setEasingMode(easingMode: number): void;
  63814. /**
  63815. * Gets the current easing mode.
  63816. * @returns the easing mode
  63817. */
  63818. getEasingMode(): number;
  63819. /**
  63820. * @hidden
  63821. */
  63822. easeInCore(gradient: number): number;
  63823. /**
  63824. * Given an input gradient between 0 and 1, this returns the corrseponding value
  63825. * of the easing function.
  63826. * @param gradient Defines the value between 0 and 1 we want the easing value for
  63827. * @returns the corresponding value on the curve defined by the easing function
  63828. */
  63829. ease(gradient: number): number;
  63830. }
  63831. /**
  63832. * Easing function with a circle shape (see link below).
  63833. * @see https://easings.net/#easeInCirc
  63834. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  63835. */
  63836. export class CircleEase extends EasingFunction implements IEasingFunction {
  63837. /** @hidden */
  63838. easeInCore(gradient: number): number;
  63839. }
  63840. /**
  63841. * Easing function with a ease back shape (see link below).
  63842. * @see https://easings.net/#easeInBack
  63843. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  63844. */
  63845. export class BackEase extends EasingFunction implements IEasingFunction {
  63846. /** Defines the amplitude of the function */
  63847. amplitude: number;
  63848. /**
  63849. * Instantiates a back ease easing
  63850. * @see https://easings.net/#easeInBack
  63851. * @param amplitude Defines the amplitude of the function
  63852. */
  63853. constructor(
  63854. /** Defines the amplitude of the function */
  63855. amplitude?: number);
  63856. /** @hidden */
  63857. easeInCore(gradient: number): number;
  63858. }
  63859. /**
  63860. * Easing function with a bouncing shape (see link below).
  63861. * @see https://easings.net/#easeInBounce
  63862. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  63863. */
  63864. export class BounceEase extends EasingFunction implements IEasingFunction {
  63865. /** Defines the number of bounces */
  63866. bounces: number;
  63867. /** Defines the amplitude of the bounce */
  63868. bounciness: number;
  63869. /**
  63870. * Instantiates a bounce easing
  63871. * @see https://easings.net/#easeInBounce
  63872. * @param bounces Defines the number of bounces
  63873. * @param bounciness Defines the amplitude of the bounce
  63874. */
  63875. constructor(
  63876. /** Defines the number of bounces */
  63877. bounces?: number,
  63878. /** Defines the amplitude of the bounce */
  63879. bounciness?: number);
  63880. /** @hidden */
  63881. easeInCore(gradient: number): number;
  63882. }
  63883. /**
  63884. * Easing function with a power of 3 shape (see link below).
  63885. * @see https://easings.net/#easeInCubic
  63886. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  63887. */
  63888. export class CubicEase extends EasingFunction implements IEasingFunction {
  63889. /** @hidden */
  63890. easeInCore(gradient: number): number;
  63891. }
  63892. /**
  63893. * Easing function with an elastic shape (see link below).
  63894. * @see https://easings.net/#easeInElastic
  63895. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  63896. */
  63897. export class ElasticEase extends EasingFunction implements IEasingFunction {
  63898. /** Defines the number of oscillations*/
  63899. oscillations: number;
  63900. /** Defines the amplitude of the oscillations*/
  63901. springiness: number;
  63902. /**
  63903. * Instantiates an elastic easing function
  63904. * @see https://easings.net/#easeInElastic
  63905. * @param oscillations Defines the number of oscillations
  63906. * @param springiness Defines the amplitude of the oscillations
  63907. */
  63908. constructor(
  63909. /** Defines the number of oscillations*/
  63910. oscillations?: number,
  63911. /** Defines the amplitude of the oscillations*/
  63912. springiness?: number);
  63913. /** @hidden */
  63914. easeInCore(gradient: number): number;
  63915. }
  63916. /**
  63917. * Easing function with an exponential shape (see link below).
  63918. * @see https://easings.net/#easeInExpo
  63919. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  63920. */
  63921. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  63922. /** Defines the exponent of the function */
  63923. exponent: number;
  63924. /**
  63925. * Instantiates an exponential easing function
  63926. * @see https://easings.net/#easeInExpo
  63927. * @param exponent Defines the exponent of the function
  63928. */
  63929. constructor(
  63930. /** Defines the exponent of the function */
  63931. exponent?: number);
  63932. /** @hidden */
  63933. easeInCore(gradient: number): number;
  63934. }
  63935. /**
  63936. * Easing function with a power shape (see link below).
  63937. * @see https://easings.net/#easeInQuad
  63938. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  63939. */
  63940. export class PowerEase extends EasingFunction implements IEasingFunction {
  63941. /** Defines the power of the function */
  63942. power: number;
  63943. /**
  63944. * Instantiates an power base easing function
  63945. * @see https://easings.net/#easeInQuad
  63946. * @param power Defines the power of the function
  63947. */
  63948. constructor(
  63949. /** Defines the power of the function */
  63950. power?: number);
  63951. /** @hidden */
  63952. easeInCore(gradient: number): number;
  63953. }
  63954. /**
  63955. * Easing function with a power of 2 shape (see link below).
  63956. * @see https://easings.net/#easeInQuad
  63957. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  63958. */
  63959. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  63960. /** @hidden */
  63961. easeInCore(gradient: number): number;
  63962. }
  63963. /**
  63964. * Easing function with a power of 4 shape (see link below).
  63965. * @see https://easings.net/#easeInQuart
  63966. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  63967. */
  63968. export class QuarticEase extends EasingFunction implements IEasingFunction {
  63969. /** @hidden */
  63970. easeInCore(gradient: number): number;
  63971. }
  63972. /**
  63973. * Easing function with a power of 5 shape (see link below).
  63974. * @see https://easings.net/#easeInQuint
  63975. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  63976. */
  63977. export class QuinticEase extends EasingFunction implements IEasingFunction {
  63978. /** @hidden */
  63979. easeInCore(gradient: number): number;
  63980. }
  63981. /**
  63982. * Easing function with a sin shape (see link below).
  63983. * @see https://easings.net/#easeInSine
  63984. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  63985. */
  63986. export class SineEase extends EasingFunction implements IEasingFunction {
  63987. /** @hidden */
  63988. easeInCore(gradient: number): number;
  63989. }
  63990. /**
  63991. * Easing function with a bezier shape (see link below).
  63992. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  63993. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  63994. */
  63995. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  63996. /** Defines the x component of the start tangent in the bezier curve */
  63997. x1: number;
  63998. /** Defines the y component of the start tangent in the bezier curve */
  63999. y1: number;
  64000. /** Defines the x component of the end tangent in the bezier curve */
  64001. x2: number;
  64002. /** Defines the y component of the end tangent in the bezier curve */
  64003. y2: number;
  64004. /**
  64005. * Instantiates a bezier function
  64006. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  64007. * @param x1 Defines the x component of the start tangent in the bezier curve
  64008. * @param y1 Defines the y component of the start tangent in the bezier curve
  64009. * @param x2 Defines the x component of the end tangent in the bezier curve
  64010. * @param y2 Defines the y component of the end tangent in the bezier curve
  64011. */
  64012. constructor(
  64013. /** Defines the x component of the start tangent in the bezier curve */
  64014. x1?: number,
  64015. /** Defines the y component of the start tangent in the bezier curve */
  64016. y1?: number,
  64017. /** Defines the x component of the end tangent in the bezier curve */
  64018. x2?: number,
  64019. /** Defines the y component of the end tangent in the bezier curve */
  64020. y2?: number);
  64021. /** @hidden */
  64022. easeInCore(gradient: number): number;
  64023. }
  64024. }
  64025. declare module BABYLON {
  64026. /**
  64027. * Defines an interface which represents an animation key frame
  64028. */
  64029. export interface IAnimationKey {
  64030. /**
  64031. * Frame of the key frame
  64032. */
  64033. frame: number;
  64034. /**
  64035. * Value at the specifies key frame
  64036. */
  64037. value: any;
  64038. /**
  64039. * The input tangent for the cubic hermite spline
  64040. */
  64041. inTangent?: any;
  64042. /**
  64043. * The output tangent for the cubic hermite spline
  64044. */
  64045. outTangent?: any;
  64046. /**
  64047. * The animation interpolation type
  64048. */
  64049. interpolation?: AnimationKeyInterpolation;
  64050. }
  64051. /**
  64052. * Enum for the animation key frame interpolation type
  64053. */
  64054. export enum AnimationKeyInterpolation {
  64055. /**
  64056. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  64057. */
  64058. STEP = 1
  64059. }
  64060. }
  64061. declare module BABYLON {
  64062. /**
  64063. * Represents the range of an animation
  64064. */
  64065. export class AnimationRange {
  64066. /**The name of the animation range**/
  64067. name: string;
  64068. /**The starting frame of the animation */
  64069. from: number;
  64070. /**The ending frame of the animation*/
  64071. to: number;
  64072. /**
  64073. * Initializes the range of an animation
  64074. * @param name The name of the animation range
  64075. * @param from The starting frame of the animation
  64076. * @param to The ending frame of the animation
  64077. */
  64078. constructor(
  64079. /**The name of the animation range**/
  64080. name: string,
  64081. /**The starting frame of the animation */
  64082. from: number,
  64083. /**The ending frame of the animation*/
  64084. to: number);
  64085. /**
  64086. * Makes a copy of the animation range
  64087. * @returns A copy of the animation range
  64088. */
  64089. clone(): AnimationRange;
  64090. }
  64091. }
  64092. declare module BABYLON {
  64093. /**
  64094. * Composed of a frame, and an action function
  64095. */
  64096. export class AnimationEvent {
  64097. /** The frame for which the event is triggered **/
  64098. frame: number;
  64099. /** The event to perform when triggered **/
  64100. action: (currentFrame: number) => void;
  64101. /** Specifies if the event should be triggered only once**/
  64102. onlyOnce?: boolean | undefined;
  64103. /**
  64104. * Specifies if the animation event is done
  64105. */
  64106. isDone: boolean;
  64107. /**
  64108. * Initializes the animation event
  64109. * @param frame The frame for which the event is triggered
  64110. * @param action The event to perform when triggered
  64111. * @param onlyOnce Specifies if the event should be triggered only once
  64112. */
  64113. constructor(
  64114. /** The frame for which the event is triggered **/
  64115. frame: number,
  64116. /** The event to perform when triggered **/
  64117. action: (currentFrame: number) => void,
  64118. /** Specifies if the event should be triggered only once**/
  64119. onlyOnce?: boolean | undefined);
  64120. /** @hidden */
  64121. _clone(): AnimationEvent;
  64122. }
  64123. }
  64124. declare module BABYLON {
  64125. /**
  64126. * Interface used to define a behavior
  64127. */
  64128. export interface Behavior<T> {
  64129. /** gets or sets behavior's name */
  64130. name: string;
  64131. /**
  64132. * Function called when the behavior needs to be initialized (after attaching it to a target)
  64133. */
  64134. init(): void;
  64135. /**
  64136. * Called when the behavior is attached to a target
  64137. * @param target defines the target where the behavior is attached to
  64138. */
  64139. attach(target: T): void;
  64140. /**
  64141. * Called when the behavior is detached from its target
  64142. */
  64143. detach(): void;
  64144. }
  64145. /**
  64146. * Interface implemented by classes supporting behaviors
  64147. */
  64148. export interface IBehaviorAware<T> {
  64149. /**
  64150. * Attach a behavior
  64151. * @param behavior defines the behavior to attach
  64152. * @returns the current host
  64153. */
  64154. addBehavior(behavior: Behavior<T>): T;
  64155. /**
  64156. * Remove a behavior from the current object
  64157. * @param behavior defines the behavior to detach
  64158. * @returns the current host
  64159. */
  64160. removeBehavior(behavior: Behavior<T>): T;
  64161. /**
  64162. * Gets a behavior using its name to search
  64163. * @param name defines the name to search
  64164. * @returns the behavior or null if not found
  64165. */
  64166. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  64167. }
  64168. }
  64169. declare module BABYLON {
  64170. /**
  64171. * @hidden
  64172. */
  64173. export class IntersectionInfo {
  64174. bu: Nullable<number>;
  64175. bv: Nullable<number>;
  64176. distance: number;
  64177. faceId: number;
  64178. subMeshId: number;
  64179. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  64180. }
  64181. }
  64182. declare module BABYLON {
  64183. /**
  64184. * Class used to store bounding sphere information
  64185. */
  64186. export class BoundingSphere {
  64187. /**
  64188. * Gets the center of the bounding sphere in local space
  64189. */
  64190. readonly center: Vector3;
  64191. /**
  64192. * Radius of the bounding sphere in local space
  64193. */
  64194. radius: number;
  64195. /**
  64196. * Gets the center of the bounding sphere in world space
  64197. */
  64198. readonly centerWorld: Vector3;
  64199. /**
  64200. * Radius of the bounding sphere in world space
  64201. */
  64202. radiusWorld: number;
  64203. /**
  64204. * Gets the minimum vector in local space
  64205. */
  64206. readonly minimum: Vector3;
  64207. /**
  64208. * Gets the maximum vector in local space
  64209. */
  64210. readonly maximum: Vector3;
  64211. private _worldMatrix;
  64212. private static readonly TmpVector3;
  64213. /**
  64214. * Creates a new bounding sphere
  64215. * @param min defines the minimum vector (in local space)
  64216. * @param max defines the maximum vector (in local space)
  64217. * @param worldMatrix defines the new world matrix
  64218. */
  64219. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  64220. /**
  64221. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  64222. * @param min defines the new minimum vector (in local space)
  64223. * @param max defines the new maximum vector (in local space)
  64224. * @param worldMatrix defines the new world matrix
  64225. */
  64226. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  64227. /**
  64228. * Scale the current bounding sphere by applying a scale factor
  64229. * @param factor defines the scale factor to apply
  64230. * @returns the current bounding box
  64231. */
  64232. scale(factor: number): BoundingSphere;
  64233. /**
  64234. * Gets the world matrix of the bounding box
  64235. * @returns a matrix
  64236. */
  64237. getWorldMatrix(): DeepImmutable<Matrix>;
  64238. /** @hidden */
  64239. _update(worldMatrix: DeepImmutable<Matrix>): void;
  64240. /**
  64241. * Tests if the bounding sphere is intersecting the frustum planes
  64242. * @param frustumPlanes defines the frustum planes to test
  64243. * @returns true if there is an intersection
  64244. */
  64245. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  64246. /**
  64247. * Tests if the bounding sphere center is in between the frustum planes.
  64248. * Used for optimistic fast inclusion.
  64249. * @param frustumPlanes defines the frustum planes to test
  64250. * @returns true if the sphere center is in between the frustum planes
  64251. */
  64252. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  64253. /**
  64254. * Tests if a point is inside the bounding sphere
  64255. * @param point defines the point to test
  64256. * @returns true if the point is inside the bounding sphere
  64257. */
  64258. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  64259. /**
  64260. * Checks if two sphere intersct
  64261. * @param sphere0 sphere 0
  64262. * @param sphere1 sphere 1
  64263. * @returns true if the speres intersect
  64264. */
  64265. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  64266. }
  64267. }
  64268. declare module BABYLON {
  64269. /**
  64270. * Class used to store bounding box information
  64271. */
  64272. export class BoundingBox implements ICullable {
  64273. /**
  64274. * Gets the 8 vectors representing the bounding box in local space
  64275. */
  64276. readonly vectors: Vector3[];
  64277. /**
  64278. * Gets the center of the bounding box in local space
  64279. */
  64280. readonly center: Vector3;
  64281. /**
  64282. * Gets the center of the bounding box in world space
  64283. */
  64284. readonly centerWorld: Vector3;
  64285. /**
  64286. * Gets the extend size in local space
  64287. */
  64288. readonly extendSize: Vector3;
  64289. /**
  64290. * Gets the extend size in world space
  64291. */
  64292. readonly extendSizeWorld: Vector3;
  64293. /**
  64294. * Gets the OBB (object bounding box) directions
  64295. */
  64296. readonly directions: Vector3[];
  64297. /**
  64298. * Gets the 8 vectors representing the bounding box in world space
  64299. */
  64300. readonly vectorsWorld: Vector3[];
  64301. /**
  64302. * Gets the minimum vector in world space
  64303. */
  64304. readonly minimumWorld: Vector3;
  64305. /**
  64306. * Gets the maximum vector in world space
  64307. */
  64308. readonly maximumWorld: Vector3;
  64309. /**
  64310. * Gets the minimum vector in local space
  64311. */
  64312. readonly minimum: Vector3;
  64313. /**
  64314. * Gets the maximum vector in local space
  64315. */
  64316. readonly maximum: Vector3;
  64317. private _worldMatrix;
  64318. private static readonly TmpVector3;
  64319. /**
  64320. * @hidden
  64321. */
  64322. _tag: number;
  64323. /**
  64324. * Creates a new bounding box
  64325. * @param min defines the minimum vector (in local space)
  64326. * @param max defines the maximum vector (in local space)
  64327. * @param worldMatrix defines the new world matrix
  64328. */
  64329. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  64330. /**
  64331. * Recreates the entire bounding box from scratch as if we call the constructor in place
  64332. * @param min defines the new minimum vector (in local space)
  64333. * @param max defines the new maximum vector (in local space)
  64334. * @param worldMatrix defines the new world matrix
  64335. */
  64336. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  64337. /**
  64338. * Scale the current bounding box by applying a scale factor
  64339. * @param factor defines the scale factor to apply
  64340. * @returns the current bounding box
  64341. */
  64342. scale(factor: number): BoundingBox;
  64343. /**
  64344. * Gets the world matrix of the bounding box
  64345. * @returns a matrix
  64346. */
  64347. getWorldMatrix(): DeepImmutable<Matrix>;
  64348. /** @hidden */
  64349. _update(world: DeepImmutable<Matrix>): void;
  64350. /**
  64351. * Tests if the bounding box is intersecting the frustum planes
  64352. * @param frustumPlanes defines the frustum planes to test
  64353. * @returns true if there is an intersection
  64354. */
  64355. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  64356. /**
  64357. * Tests if the bounding box is entirely inside the frustum planes
  64358. * @param frustumPlanes defines the frustum planes to test
  64359. * @returns true if there is an inclusion
  64360. */
  64361. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  64362. /**
  64363. * Tests if a point is inside the bounding box
  64364. * @param point defines the point to test
  64365. * @returns true if the point is inside the bounding box
  64366. */
  64367. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  64368. /**
  64369. * Tests if the bounding box intersects with a bounding sphere
  64370. * @param sphere defines the sphere to test
  64371. * @returns true if there is an intersection
  64372. */
  64373. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  64374. /**
  64375. * Tests if the bounding box intersects with a box defined by a min and max vectors
  64376. * @param min defines the min vector to use
  64377. * @param max defines the max vector to use
  64378. * @returns true if there is an intersection
  64379. */
  64380. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  64381. /**
  64382. * Tests if two bounding boxes are intersections
  64383. * @param box0 defines the first box to test
  64384. * @param box1 defines the second box to test
  64385. * @returns true if there is an intersection
  64386. */
  64387. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  64388. /**
  64389. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  64390. * @param minPoint defines the minimum vector of the bounding box
  64391. * @param maxPoint defines the maximum vector of the bounding box
  64392. * @param sphereCenter defines the sphere center
  64393. * @param sphereRadius defines the sphere radius
  64394. * @returns true if there is an intersection
  64395. */
  64396. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  64397. /**
  64398. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  64399. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  64400. * @param frustumPlanes defines the frustum planes to test
  64401. * @return true if there is an inclusion
  64402. */
  64403. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  64404. /**
  64405. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  64406. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  64407. * @param frustumPlanes defines the frustum planes to test
  64408. * @return true if there is an intersection
  64409. */
  64410. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  64411. }
  64412. }
  64413. declare module BABYLON {
  64414. /** @hidden */
  64415. export class Collider {
  64416. /** Define if a collision was found */
  64417. collisionFound: boolean;
  64418. /**
  64419. * Define last intersection point in local space
  64420. */
  64421. intersectionPoint: Vector3;
  64422. /**
  64423. * Define last collided mesh
  64424. */
  64425. collidedMesh: Nullable<AbstractMesh>;
  64426. private _collisionPoint;
  64427. private _planeIntersectionPoint;
  64428. private _tempVector;
  64429. private _tempVector2;
  64430. private _tempVector3;
  64431. private _tempVector4;
  64432. private _edge;
  64433. private _baseToVertex;
  64434. private _destinationPoint;
  64435. private _slidePlaneNormal;
  64436. private _displacementVector;
  64437. /** @hidden */
  64438. _radius: Vector3;
  64439. /** @hidden */
  64440. _retry: number;
  64441. private _velocity;
  64442. private _basePoint;
  64443. private _epsilon;
  64444. /** @hidden */
  64445. _velocityWorldLength: number;
  64446. /** @hidden */
  64447. _basePointWorld: Vector3;
  64448. private _velocityWorld;
  64449. private _normalizedVelocity;
  64450. /** @hidden */
  64451. _initialVelocity: Vector3;
  64452. /** @hidden */
  64453. _initialPosition: Vector3;
  64454. private _nearestDistance;
  64455. private _collisionMask;
  64456. collisionMask: number;
  64457. /**
  64458. * Gets the plane normal used to compute the sliding response (in local space)
  64459. */
  64460. readonly slidePlaneNormal: Vector3;
  64461. /** @hidden */
  64462. _initialize(source: Vector3, dir: Vector3, e: number): void;
  64463. /** @hidden */
  64464. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  64465. /** @hidden */
  64466. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  64467. /** @hidden */
  64468. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  64469. /** @hidden */
  64470. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  64471. /** @hidden */
  64472. _getResponse(pos: Vector3, vel: Vector3): void;
  64473. }
  64474. }
  64475. declare module BABYLON {
  64476. /**
  64477. * Interface for cullable objects
  64478. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  64479. */
  64480. export interface ICullable {
  64481. /**
  64482. * Checks if the object or part of the object is in the frustum
  64483. * @param frustumPlanes Camera near/planes
  64484. * @returns true if the object is in frustum otherwise false
  64485. */
  64486. isInFrustum(frustumPlanes: Plane[]): boolean;
  64487. /**
  64488. * Checks if a cullable object (mesh...) is in the camera frustum
  64489. * Unlike isInFrustum this cheks the full bounding box
  64490. * @param frustumPlanes Camera near/planes
  64491. * @returns true if the object is in frustum otherwise false
  64492. */
  64493. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  64494. }
  64495. /**
  64496. * Info for a bounding data of a mesh
  64497. */
  64498. export class BoundingInfo implements ICullable {
  64499. /**
  64500. * Bounding box for the mesh
  64501. */
  64502. readonly boundingBox: BoundingBox;
  64503. /**
  64504. * Bounding sphere for the mesh
  64505. */
  64506. readonly boundingSphere: BoundingSphere;
  64507. private _isLocked;
  64508. private static readonly TmpVector3;
  64509. /**
  64510. * Constructs bounding info
  64511. * @param minimum min vector of the bounding box/sphere
  64512. * @param maximum max vector of the bounding box/sphere
  64513. * @param worldMatrix defines the new world matrix
  64514. */
  64515. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  64516. /**
  64517. * Recreates the entire bounding info from scratch as if we call the constructor in place
  64518. * @param min defines the new minimum vector (in local space)
  64519. * @param max defines the new maximum vector (in local space)
  64520. * @param worldMatrix defines the new world matrix
  64521. */
  64522. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  64523. /**
  64524. * min vector of the bounding box/sphere
  64525. */
  64526. readonly minimum: Vector3;
  64527. /**
  64528. * max vector of the bounding box/sphere
  64529. */
  64530. readonly maximum: Vector3;
  64531. /**
  64532. * If the info is locked and won't be updated to avoid perf overhead
  64533. */
  64534. isLocked: boolean;
  64535. /**
  64536. * Updates the bounding sphere and box
  64537. * @param world world matrix to be used to update
  64538. */
  64539. update(world: DeepImmutable<Matrix>): void;
  64540. /**
  64541. * Recreate the bounding info to be centered around a specific point given a specific extend.
  64542. * @param center New center of the bounding info
  64543. * @param extend New extend of the bounding info
  64544. * @returns the current bounding info
  64545. */
  64546. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  64547. /**
  64548. * Scale the current bounding info by applying a scale factor
  64549. * @param factor defines the scale factor to apply
  64550. * @returns the current bounding info
  64551. */
  64552. scale(factor: number): BoundingInfo;
  64553. /**
  64554. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  64555. * @param frustumPlanes defines the frustum to test
  64556. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  64557. * @returns true if the bounding info is in the frustum planes
  64558. */
  64559. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  64560. /**
  64561. * Gets the world distance between the min and max points of the bounding box
  64562. */
  64563. readonly diagonalLength: number;
  64564. /**
  64565. * Checks if a cullable object (mesh...) is in the camera frustum
  64566. * Unlike isInFrustum this cheks the full bounding box
  64567. * @param frustumPlanes Camera near/planes
  64568. * @returns true if the object is in frustum otherwise false
  64569. */
  64570. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  64571. /** @hidden */
  64572. _checkCollision(collider: Collider): boolean;
  64573. /**
  64574. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  64575. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  64576. * @param point the point to check intersection with
  64577. * @returns if the point intersects
  64578. */
  64579. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  64580. /**
  64581. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  64582. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  64583. * @param boundingInfo the bounding info to check intersection with
  64584. * @param precise if the intersection should be done using OBB
  64585. * @returns if the bounding info intersects
  64586. */
  64587. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  64588. }
  64589. }
  64590. declare module BABYLON {
  64591. /**
  64592. * Defines an array and its length.
  64593. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  64594. */
  64595. export interface ISmartArrayLike<T> {
  64596. /**
  64597. * The data of the array.
  64598. */
  64599. data: Array<T>;
  64600. /**
  64601. * The active length of the array.
  64602. */
  64603. length: number;
  64604. }
  64605. /**
  64606. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  64607. */
  64608. export class SmartArray<T> implements ISmartArrayLike<T> {
  64609. /**
  64610. * The full set of data from the array.
  64611. */
  64612. data: Array<T>;
  64613. /**
  64614. * The active length of the array.
  64615. */
  64616. length: number;
  64617. protected _id: number;
  64618. /**
  64619. * Instantiates a Smart Array.
  64620. * @param capacity defines the default capacity of the array.
  64621. */
  64622. constructor(capacity: number);
  64623. /**
  64624. * Pushes a value at the end of the active data.
  64625. * @param value defines the object to push in the array.
  64626. */
  64627. push(value: T): void;
  64628. /**
  64629. * Iterates over the active data and apply the lambda to them.
  64630. * @param func defines the action to apply on each value.
  64631. */
  64632. forEach(func: (content: T) => void): void;
  64633. /**
  64634. * Sorts the full sets of data.
  64635. * @param compareFn defines the comparison function to apply.
  64636. */
  64637. sort(compareFn: (a: T, b: T) => number): void;
  64638. /**
  64639. * Resets the active data to an empty array.
  64640. */
  64641. reset(): void;
  64642. /**
  64643. * Releases all the data from the array as well as the array.
  64644. */
  64645. dispose(): void;
  64646. /**
  64647. * Concats the active data with a given array.
  64648. * @param array defines the data to concatenate with.
  64649. */
  64650. concat(array: any): void;
  64651. /**
  64652. * Returns the position of a value in the active data.
  64653. * @param value defines the value to find the index for
  64654. * @returns the index if found in the active data otherwise -1
  64655. */
  64656. indexOf(value: T): number;
  64657. /**
  64658. * Returns whether an element is part of the active data.
  64659. * @param value defines the value to look for
  64660. * @returns true if found in the active data otherwise false
  64661. */
  64662. contains(value: T): boolean;
  64663. private static _GlobalId;
  64664. }
  64665. /**
  64666. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  64667. * The data in this array can only be present once
  64668. */
  64669. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  64670. private _duplicateId;
  64671. /**
  64672. * Pushes a value at the end of the active data.
  64673. * THIS DOES NOT PREVENT DUPPLICATE DATA
  64674. * @param value defines the object to push in the array.
  64675. */
  64676. push(value: T): void;
  64677. /**
  64678. * Pushes a value at the end of the active data.
  64679. * If the data is already present, it won t be added again
  64680. * @param value defines the object to push in the array.
  64681. * @returns true if added false if it was already present
  64682. */
  64683. pushNoDuplicate(value: T): boolean;
  64684. /**
  64685. * Resets the active data to an empty array.
  64686. */
  64687. reset(): void;
  64688. /**
  64689. * Concats the active data with a given array.
  64690. * This ensures no dupplicate will be present in the result.
  64691. * @param array defines the data to concatenate with.
  64692. */
  64693. concatWithNoDuplicate(array: any): void;
  64694. }
  64695. }
  64696. declare module BABYLON {
  64697. /**
  64698. * A multi-material is used to apply different materials to different parts of the same object without the need of
  64699. * separate meshes. This can be use to improve performances.
  64700. * @see http://doc.babylonjs.com/how_to/multi_materials
  64701. */
  64702. export class MultiMaterial extends Material {
  64703. private _subMaterials;
  64704. /**
  64705. * Gets or Sets the list of Materials used within the multi material.
  64706. * They need to be ordered according to the submeshes order in the associated mesh
  64707. */
  64708. subMaterials: Nullable<Material>[];
  64709. /**
  64710. * Function used to align with Node.getChildren()
  64711. * @returns the list of Materials used within the multi material
  64712. */
  64713. getChildren(): Nullable<Material>[];
  64714. /**
  64715. * Instantiates a new Multi Material
  64716. * A multi-material is used to apply different materials to different parts of the same object without the need of
  64717. * separate meshes. This can be use to improve performances.
  64718. * @see http://doc.babylonjs.com/how_to/multi_materials
  64719. * @param name Define the name in the scene
  64720. * @param scene Define the scene the material belongs to
  64721. */
  64722. constructor(name: string, scene: Scene);
  64723. private _hookArray;
  64724. /**
  64725. * Get one of the submaterial by its index in the submaterials array
  64726. * @param index The index to look the sub material at
  64727. * @returns The Material if the index has been defined
  64728. */
  64729. getSubMaterial(index: number): Nullable<Material>;
  64730. /**
  64731. * Get the list of active textures for the whole sub materials list.
  64732. * @returns All the textures that will be used during the rendering
  64733. */
  64734. getActiveTextures(): BaseTexture[];
  64735. /**
  64736. * Gets the current class name of the material e.g. "MultiMaterial"
  64737. * Mainly use in serialization.
  64738. * @returns the class name
  64739. */
  64740. getClassName(): string;
  64741. /**
  64742. * Checks if the material is ready to render the requested sub mesh
  64743. * @param mesh Define the mesh the submesh belongs to
  64744. * @param subMesh Define the sub mesh to look readyness for
  64745. * @param useInstances Define whether or not the material is used with instances
  64746. * @returns true if ready, otherwise false
  64747. */
  64748. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  64749. /**
  64750. * Clones the current material and its related sub materials
  64751. * @param name Define the name of the newly cloned material
  64752. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  64753. * @returns the cloned material
  64754. */
  64755. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  64756. /**
  64757. * Serializes the materials into a JSON representation.
  64758. * @returns the JSON representation
  64759. */
  64760. serialize(): any;
  64761. /**
  64762. * Dispose the material and release its associated resources
  64763. * @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)
  64764. * @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)
  64765. * @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)
  64766. */
  64767. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  64768. /**
  64769. * Creates a MultiMaterial from parsed MultiMaterial data.
  64770. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  64771. * @param scene defines the hosting scene
  64772. * @returns a new MultiMaterial
  64773. */
  64774. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  64775. }
  64776. }
  64777. declare module BABYLON {
  64778. /**
  64779. * Class used to represent data loading progression
  64780. */
  64781. export class SceneLoaderFlags {
  64782. private static _ForceFullSceneLoadingForIncremental;
  64783. private static _ShowLoadingScreen;
  64784. private static _CleanBoneMatrixWeights;
  64785. private static _loggingLevel;
  64786. /**
  64787. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  64788. */
  64789. static ForceFullSceneLoadingForIncremental: boolean;
  64790. /**
  64791. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  64792. */
  64793. static ShowLoadingScreen: boolean;
  64794. /**
  64795. * Defines the current logging level (while loading the scene)
  64796. * @ignorenaming
  64797. */
  64798. static loggingLevel: number;
  64799. /**
  64800. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  64801. */
  64802. static CleanBoneMatrixWeights: boolean;
  64803. }
  64804. }
  64805. declare module BABYLON {
  64806. /**
  64807. * 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.
  64808. * @see https://doc.babylonjs.com/how_to/transformnode
  64809. */
  64810. export class TransformNode extends Node {
  64811. /**
  64812. * Object will not rotate to face the camera
  64813. */
  64814. static BILLBOARDMODE_NONE: number;
  64815. /**
  64816. * Object will rotate to face the camera but only on the x axis
  64817. */
  64818. static BILLBOARDMODE_X: number;
  64819. /**
  64820. * Object will rotate to face the camera but only on the y axis
  64821. */
  64822. static BILLBOARDMODE_Y: number;
  64823. /**
  64824. * Object will rotate to face the camera but only on the z axis
  64825. */
  64826. static BILLBOARDMODE_Z: number;
  64827. /**
  64828. * Object will rotate to face the camera
  64829. */
  64830. static BILLBOARDMODE_ALL: number;
  64831. private _forward;
  64832. private _forwardInverted;
  64833. private _up;
  64834. private _right;
  64835. private _rightInverted;
  64836. private _position;
  64837. private _rotation;
  64838. private _rotationQuaternion;
  64839. protected _scaling: Vector3;
  64840. protected _isDirty: boolean;
  64841. private _transformToBoneReferal;
  64842. /**
  64843. * Set the billboard mode. Default is 0.
  64844. *
  64845. * | Value | Type | Description |
  64846. * | --- | --- | --- |
  64847. * | 0 | BILLBOARDMODE_NONE | |
  64848. * | 1 | BILLBOARDMODE_X | |
  64849. * | 2 | BILLBOARDMODE_Y | |
  64850. * | 4 | BILLBOARDMODE_Z | |
  64851. * | 7 | BILLBOARDMODE_ALL | |
  64852. *
  64853. */
  64854. billboardMode: number;
  64855. /**
  64856. * 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
  64857. */
  64858. scalingDeterminant: number;
  64859. /**
  64860. * Sets the distance of the object to max, often used by skybox
  64861. */
  64862. infiniteDistance: boolean;
  64863. /**
  64864. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  64865. * By default the system will update normals to compensate
  64866. */
  64867. ignoreNonUniformScaling: boolean;
  64868. /** @hidden */
  64869. _poseMatrix: Matrix;
  64870. /** @hidden */
  64871. _localMatrix: Matrix;
  64872. private _absolutePosition;
  64873. private _pivotMatrix;
  64874. private _pivotMatrixInverse;
  64875. protected _postMultiplyPivotMatrix: boolean;
  64876. protected _isWorldMatrixFrozen: boolean;
  64877. /** @hidden */
  64878. _indexInSceneTransformNodesArray: number;
  64879. /**
  64880. * An event triggered after the world matrix is updated
  64881. */
  64882. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  64883. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  64884. /**
  64885. * Gets a string identifying the name of the class
  64886. * @returns "TransformNode" string
  64887. */
  64888. getClassName(): string;
  64889. /**
  64890. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  64891. */
  64892. position: Vector3;
  64893. /**
  64894. * 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)).
  64895. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  64896. */
  64897. rotation: Vector3;
  64898. /**
  64899. * 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)).
  64900. */
  64901. scaling: Vector3;
  64902. /**
  64903. * 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).
  64904. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  64905. */
  64906. rotationQuaternion: Nullable<Quaternion>;
  64907. /**
  64908. * The forward direction of that transform in world space.
  64909. */
  64910. readonly forward: Vector3;
  64911. /**
  64912. * The up direction of that transform in world space.
  64913. */
  64914. readonly up: Vector3;
  64915. /**
  64916. * The right direction of that transform in world space.
  64917. */
  64918. readonly right: Vector3;
  64919. /**
  64920. * Copies the parameter passed Matrix into the mesh Pose matrix.
  64921. * @param matrix the matrix to copy the pose from
  64922. * @returns this TransformNode.
  64923. */
  64924. updatePoseMatrix(matrix: Matrix): TransformNode;
  64925. /**
  64926. * Returns the mesh Pose matrix.
  64927. * @returns the pose matrix
  64928. */
  64929. getPoseMatrix(): Matrix;
  64930. /** @hidden */
  64931. _isSynchronized(): boolean;
  64932. /** @hidden */
  64933. _initCache(): void;
  64934. /**
  64935. * Flag the transform node as dirty (Forcing it to update everything)
  64936. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  64937. * @returns this transform node
  64938. */
  64939. markAsDirty(property: string): TransformNode;
  64940. /**
  64941. * Returns the current mesh absolute position.
  64942. * Returns a Vector3.
  64943. */
  64944. readonly absolutePosition: Vector3;
  64945. /**
  64946. * Sets a new matrix to apply before all other transformation
  64947. * @param matrix defines the transform matrix
  64948. * @returns the current TransformNode
  64949. */
  64950. setPreTransformMatrix(matrix: Matrix): TransformNode;
  64951. /**
  64952. * Sets a new pivot matrix to the current node
  64953. * @param matrix defines the new pivot matrix to use
  64954. * @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
  64955. * @returns the current TransformNode
  64956. */
  64957. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  64958. /**
  64959. * Returns the mesh pivot matrix.
  64960. * Default : Identity.
  64961. * @returns the matrix
  64962. */
  64963. getPivotMatrix(): Matrix;
  64964. /**
  64965. * Prevents the World matrix to be computed any longer.
  64966. * @returns the TransformNode.
  64967. */
  64968. freezeWorldMatrix(): TransformNode;
  64969. /**
  64970. * Allows back the World matrix computation.
  64971. * @returns the TransformNode.
  64972. */
  64973. unfreezeWorldMatrix(): this;
  64974. /**
  64975. * True if the World matrix has been frozen.
  64976. */
  64977. readonly isWorldMatrixFrozen: boolean;
  64978. /**
  64979. * Retuns the mesh absolute position in the World.
  64980. * @returns a Vector3.
  64981. */
  64982. getAbsolutePosition(): Vector3;
  64983. /**
  64984. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  64985. * @param absolutePosition the absolute position to set
  64986. * @returns the TransformNode.
  64987. */
  64988. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  64989. /**
  64990. * Sets the mesh position in its local space.
  64991. * @param vector3 the position to set in localspace
  64992. * @returns the TransformNode.
  64993. */
  64994. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  64995. /**
  64996. * Returns the mesh position in the local space from the current World matrix values.
  64997. * @returns a new Vector3.
  64998. */
  64999. getPositionExpressedInLocalSpace(): Vector3;
  65000. /**
  65001. * Translates the mesh along the passed Vector3 in its local space.
  65002. * @param vector3 the distance to translate in localspace
  65003. * @returns the TransformNode.
  65004. */
  65005. locallyTranslate(vector3: Vector3): TransformNode;
  65006. private static _lookAtVectorCache;
  65007. /**
  65008. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  65009. * @param targetPoint the position (must be in same space as current mesh) to look at
  65010. * @param yawCor optional yaw (y-axis) correction in radians
  65011. * @param pitchCor optional pitch (x-axis) correction in radians
  65012. * @param rollCor optional roll (z-axis) correction in radians
  65013. * @param space the choosen space of the target
  65014. * @returns the TransformNode.
  65015. */
  65016. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  65017. /**
  65018. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  65019. * This Vector3 is expressed in the World space.
  65020. * @param localAxis axis to rotate
  65021. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  65022. */
  65023. getDirection(localAxis: Vector3): Vector3;
  65024. /**
  65025. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  65026. * localAxis is expressed in the mesh local space.
  65027. * result is computed in the Wordl space from the mesh World matrix.
  65028. * @param localAxis axis to rotate
  65029. * @param result the resulting transformnode
  65030. * @returns this TransformNode.
  65031. */
  65032. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  65033. /**
  65034. * Sets this transform node rotation to the given local axis.
  65035. * @param localAxis the axis in local space
  65036. * @param yawCor optional yaw (y-axis) correction in radians
  65037. * @param pitchCor optional pitch (x-axis) correction in radians
  65038. * @param rollCor optional roll (z-axis) correction in radians
  65039. * @returns this TransformNode
  65040. */
  65041. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  65042. /**
  65043. * Sets a new pivot point to the current node
  65044. * @param point defines the new pivot point to use
  65045. * @param space defines if the point is in world or local space (local by default)
  65046. * @returns the current TransformNode
  65047. */
  65048. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  65049. /**
  65050. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  65051. * @returns the pivot point
  65052. */
  65053. getPivotPoint(): Vector3;
  65054. /**
  65055. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  65056. * @param result the vector3 to store the result
  65057. * @returns this TransformNode.
  65058. */
  65059. getPivotPointToRef(result: Vector3): TransformNode;
  65060. /**
  65061. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  65062. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  65063. */
  65064. getAbsolutePivotPoint(): Vector3;
  65065. /**
  65066. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  65067. * @param result vector3 to store the result
  65068. * @returns this TransformNode.
  65069. */
  65070. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  65071. /**
  65072. * Defines the passed node as the parent of the current node.
  65073. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  65074. * @param node the node ot set as the parent
  65075. * @returns this TransformNode.
  65076. */
  65077. setParent(node: Nullable<Node>): TransformNode;
  65078. private _nonUniformScaling;
  65079. /**
  65080. * True if the scaling property of this object is non uniform eg. (1,2,1)
  65081. */
  65082. readonly nonUniformScaling: boolean;
  65083. /** @hidden */
  65084. _updateNonUniformScalingState(value: boolean): boolean;
  65085. /**
  65086. * Attach the current TransformNode to another TransformNode associated with a bone
  65087. * @param bone Bone affecting the TransformNode
  65088. * @param affectedTransformNode TransformNode associated with the bone
  65089. * @returns this object
  65090. */
  65091. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  65092. /**
  65093. * Detach the transform node if its associated with a bone
  65094. * @returns this object
  65095. */
  65096. detachFromBone(): TransformNode;
  65097. private static _rotationAxisCache;
  65098. /**
  65099. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  65100. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  65101. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  65102. * The passed axis is also normalized.
  65103. * @param axis the axis to rotate around
  65104. * @param amount the amount to rotate in radians
  65105. * @param space Space to rotate in (Default: local)
  65106. * @returns the TransformNode.
  65107. */
  65108. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  65109. /**
  65110. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  65111. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  65112. * The passed axis is also normalized. .
  65113. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  65114. * @param point the point to rotate around
  65115. * @param axis the axis to rotate around
  65116. * @param amount the amount to rotate in radians
  65117. * @returns the TransformNode
  65118. */
  65119. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  65120. /**
  65121. * Translates the mesh along the axis vector for the passed distance in the given space.
  65122. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  65123. * @param axis the axis to translate in
  65124. * @param distance the distance to translate
  65125. * @param space Space to rotate in (Default: local)
  65126. * @returns the TransformNode.
  65127. */
  65128. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  65129. /**
  65130. * Adds a rotation step to the mesh current rotation.
  65131. * x, y, z are Euler angles expressed in radians.
  65132. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  65133. * This means this rotation is made in the mesh local space only.
  65134. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  65135. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  65136. * ```javascript
  65137. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  65138. * ```
  65139. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  65140. * 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.
  65141. * @param x Rotation to add
  65142. * @param y Rotation to add
  65143. * @param z Rotation to add
  65144. * @returns the TransformNode.
  65145. */
  65146. addRotation(x: number, y: number, z: number): TransformNode;
  65147. /**
  65148. * Computes the world matrix of the node
  65149. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  65150. * @returns the world matrix
  65151. */
  65152. computeWorldMatrix(force?: boolean): Matrix;
  65153. protected _afterComputeWorldMatrix(): void;
  65154. /**
  65155. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  65156. * @param func callback function to add
  65157. *
  65158. * @returns the TransformNode.
  65159. */
  65160. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  65161. /**
  65162. * Removes a registered callback function.
  65163. * @param func callback function to remove
  65164. * @returns the TransformNode.
  65165. */
  65166. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  65167. /**
  65168. * Gets the position of the current mesh in camera space
  65169. * @param camera defines the camera to use
  65170. * @returns a position
  65171. */
  65172. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  65173. /**
  65174. * Returns the distance from the mesh to the active camera
  65175. * @param camera defines the camera to use
  65176. * @returns the distance
  65177. */
  65178. getDistanceToCamera(camera?: Nullable<Camera>): number;
  65179. /**
  65180. * Clone the current transform node
  65181. * @param name Name of the new clone
  65182. * @param newParent New parent for the clone
  65183. * @param doNotCloneChildren Do not clone children hierarchy
  65184. * @returns the new transform node
  65185. */
  65186. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  65187. /**
  65188. * Serializes the objects information.
  65189. * @param currentSerializationObject defines the object to serialize in
  65190. * @returns the serialized object
  65191. */
  65192. serialize(currentSerializationObject?: any): any;
  65193. /**
  65194. * Returns a new TransformNode object parsed from the source provided.
  65195. * @param parsedTransformNode is the source.
  65196. * @param scene the scne the object belongs to
  65197. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  65198. * @returns a new TransformNode object parsed from the source provided.
  65199. */
  65200. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  65201. /**
  65202. * Get all child-transformNodes of this node
  65203. * @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
  65204. * @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
  65205. * @returns an array of TransformNode
  65206. */
  65207. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  65208. /**
  65209. * Releases resources associated with this transform node.
  65210. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  65211. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  65212. */
  65213. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  65214. }
  65215. }
  65216. declare module BABYLON {
  65217. /**
  65218. * Class used to override all child animations of a given target
  65219. */
  65220. export class AnimationPropertiesOverride {
  65221. /**
  65222. * Gets or sets a value indicating if animation blending must be used
  65223. */
  65224. enableBlending: boolean;
  65225. /**
  65226. * Gets or sets the blending speed to use when enableBlending is true
  65227. */
  65228. blendingSpeed: number;
  65229. /**
  65230. * Gets or sets the default loop mode to use
  65231. */
  65232. loopMode: number;
  65233. }
  65234. }
  65235. declare module BABYLON {
  65236. /**
  65237. * Class used to store bone information
  65238. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  65239. */
  65240. export class Bone extends Node {
  65241. /**
  65242. * defines the bone name
  65243. */
  65244. name: string;
  65245. private static _tmpVecs;
  65246. private static _tmpQuat;
  65247. private static _tmpMats;
  65248. /**
  65249. * Gets the list of child bones
  65250. */
  65251. children: Bone[];
  65252. /** Gets the animations associated with this bone */
  65253. animations: Animation[];
  65254. /**
  65255. * Gets or sets bone length
  65256. */
  65257. length: number;
  65258. /**
  65259. * @hidden Internal only
  65260. * Set this value to map this bone to a different index in the transform matrices
  65261. * Set this value to -1 to exclude the bone from the transform matrices
  65262. */
  65263. _index: Nullable<number>;
  65264. private _skeleton;
  65265. private _localMatrix;
  65266. private _restPose;
  65267. private _baseMatrix;
  65268. private _absoluteTransform;
  65269. private _invertedAbsoluteTransform;
  65270. private _parent;
  65271. private _scalingDeterminant;
  65272. private _worldTransform;
  65273. private _localScaling;
  65274. private _localRotation;
  65275. private _localPosition;
  65276. private _needToDecompose;
  65277. private _needToCompose;
  65278. /** @hidden */
  65279. _linkedTransformNode: Nullable<TransformNode>;
  65280. /** @hidden */
  65281. /** @hidden */
  65282. _matrix: Matrix;
  65283. /**
  65284. * Create a new bone
  65285. * @param name defines the bone name
  65286. * @param skeleton defines the parent skeleton
  65287. * @param parentBone defines the parent (can be null if the bone is the root)
  65288. * @param localMatrix defines the local matrix
  65289. * @param restPose defines the rest pose matrix
  65290. * @param baseMatrix defines the base matrix
  65291. * @param index defines index of the bone in the hiearchy
  65292. */
  65293. constructor(
  65294. /**
  65295. * defines the bone name
  65296. */
  65297. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  65298. /**
  65299. * Gets the current object class name.
  65300. * @return the class name
  65301. */
  65302. getClassName(): string;
  65303. /**
  65304. * Gets the parent skeleton
  65305. * @returns a skeleton
  65306. */
  65307. getSkeleton(): Skeleton;
  65308. /**
  65309. * Gets parent bone
  65310. * @returns a bone or null if the bone is the root of the bone hierarchy
  65311. */
  65312. getParent(): Nullable<Bone>;
  65313. /**
  65314. * Returns an array containing the root bones
  65315. * @returns an array containing the root bones
  65316. */
  65317. getChildren(): Array<Bone>;
  65318. /**
  65319. * Sets the parent bone
  65320. * @param parent defines the parent (can be null if the bone is the root)
  65321. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  65322. */
  65323. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  65324. /**
  65325. * Gets the local matrix
  65326. * @returns a matrix
  65327. */
  65328. getLocalMatrix(): Matrix;
  65329. /**
  65330. * Gets the base matrix (initial matrix which remains unchanged)
  65331. * @returns a matrix
  65332. */
  65333. getBaseMatrix(): Matrix;
  65334. /**
  65335. * Gets the rest pose matrix
  65336. * @returns a matrix
  65337. */
  65338. getRestPose(): Matrix;
  65339. /**
  65340. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  65341. */
  65342. getWorldMatrix(): Matrix;
  65343. /**
  65344. * Sets the local matrix to rest pose matrix
  65345. */
  65346. returnToRest(): void;
  65347. /**
  65348. * Gets the inverse of the absolute transform matrix.
  65349. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  65350. * @returns a matrix
  65351. */
  65352. getInvertedAbsoluteTransform(): Matrix;
  65353. /**
  65354. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  65355. * @returns a matrix
  65356. */
  65357. getAbsoluteTransform(): Matrix;
  65358. /**
  65359. * Links with the given transform node.
  65360. * The local matrix of this bone is copied from the transform node every frame.
  65361. * @param transformNode defines the transform node to link to
  65362. */
  65363. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  65364. /** Gets or sets current position (in local space) */
  65365. position: Vector3;
  65366. /** Gets or sets current rotation (in local space) */
  65367. rotation: Vector3;
  65368. /** Gets or sets current rotation quaternion (in local space) */
  65369. rotationQuaternion: Quaternion;
  65370. /** Gets or sets current scaling (in local space) */
  65371. scaling: Vector3;
  65372. /**
  65373. * Gets the animation properties override
  65374. */
  65375. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  65376. private _decompose;
  65377. private _compose;
  65378. /**
  65379. * Update the base and local matrices
  65380. * @param matrix defines the new base or local matrix
  65381. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  65382. * @param updateLocalMatrix defines if the local matrix should be updated
  65383. */
  65384. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  65385. /** @hidden */
  65386. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  65387. /**
  65388. * Flag the bone as dirty (Forcing it to update everything)
  65389. */
  65390. markAsDirty(): void;
  65391. private _markAsDirtyAndCompose;
  65392. private _markAsDirtyAndDecompose;
  65393. /**
  65394. * Translate the bone in local or world space
  65395. * @param vec The amount to translate the bone
  65396. * @param space The space that the translation is in
  65397. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65398. */
  65399. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  65400. /**
  65401. * Set the postion of the bone in local or world space
  65402. * @param position The position to set the bone
  65403. * @param space The space that the position is in
  65404. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65405. */
  65406. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  65407. /**
  65408. * Set the absolute position of the bone (world space)
  65409. * @param position The position to set the bone
  65410. * @param mesh The mesh that this bone is attached to
  65411. */
  65412. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  65413. /**
  65414. * Scale the bone on the x, y and z axes (in local space)
  65415. * @param x The amount to scale the bone on the x axis
  65416. * @param y The amount to scale the bone on the y axis
  65417. * @param z The amount to scale the bone on the z axis
  65418. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  65419. */
  65420. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  65421. /**
  65422. * Set the bone scaling in local space
  65423. * @param scale defines the scaling vector
  65424. */
  65425. setScale(scale: Vector3): void;
  65426. /**
  65427. * Gets the current scaling in local space
  65428. * @returns the current scaling vector
  65429. */
  65430. getScale(): Vector3;
  65431. /**
  65432. * Gets the current scaling in local space and stores it in a target vector
  65433. * @param result defines the target vector
  65434. */
  65435. getScaleToRef(result: Vector3): void;
  65436. /**
  65437. * Set the yaw, pitch, and roll of the bone in local or world space
  65438. * @param yaw The rotation of the bone on the y axis
  65439. * @param pitch The rotation of the bone on the x axis
  65440. * @param roll The rotation of the bone on the z axis
  65441. * @param space The space that the axes of rotation are in
  65442. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65443. */
  65444. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  65445. /**
  65446. * Add a rotation to the bone on an axis in local or world space
  65447. * @param axis The axis to rotate the bone on
  65448. * @param amount The amount to rotate the bone
  65449. * @param space The space that the axis is in
  65450. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65451. */
  65452. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  65453. /**
  65454. * Set the rotation of the bone to a particular axis angle in local or world space
  65455. * @param axis The axis to rotate the bone on
  65456. * @param angle The angle that the bone should be rotated to
  65457. * @param space The space that the axis is in
  65458. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65459. */
  65460. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  65461. /**
  65462. * Set the euler rotation of the bone in local of world space
  65463. * @param rotation The euler rotation that the bone should be set to
  65464. * @param space The space that the rotation is in
  65465. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65466. */
  65467. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  65468. /**
  65469. * Set the quaternion rotation of the bone in local of world space
  65470. * @param quat The quaternion rotation that the bone should be set to
  65471. * @param space The space that the rotation is in
  65472. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65473. */
  65474. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  65475. /**
  65476. * Set the rotation matrix of the bone in local of world space
  65477. * @param rotMat The rotation matrix that the bone should be set to
  65478. * @param space The space that the rotation is in
  65479. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65480. */
  65481. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  65482. private _rotateWithMatrix;
  65483. private _getNegativeRotationToRef;
  65484. /**
  65485. * Get the position of the bone in local or world space
  65486. * @param space The space that the returned position is in
  65487. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65488. * @returns The position of the bone
  65489. */
  65490. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  65491. /**
  65492. * Copy the position of the bone to a vector3 in local or world space
  65493. * @param space The space that the returned position is in
  65494. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65495. * @param result The vector3 to copy the position to
  65496. */
  65497. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  65498. /**
  65499. * Get the absolute position of the bone (world space)
  65500. * @param mesh The mesh that this bone is attached to
  65501. * @returns The absolute position of the bone
  65502. */
  65503. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  65504. /**
  65505. * Copy the absolute position of the bone (world space) to the result param
  65506. * @param mesh The mesh that this bone is attached to
  65507. * @param result The vector3 to copy the absolute position to
  65508. */
  65509. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  65510. /**
  65511. * Compute the absolute transforms of this bone and its children
  65512. */
  65513. computeAbsoluteTransforms(): void;
  65514. /**
  65515. * Get the world direction from an axis that is in the local space of the bone
  65516. * @param localAxis The local direction that is used to compute the world direction
  65517. * @param mesh The mesh that this bone is attached to
  65518. * @returns The world direction
  65519. */
  65520. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  65521. /**
  65522. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  65523. * @param localAxis The local direction that is used to compute the world direction
  65524. * @param mesh The mesh that this bone is attached to
  65525. * @param result The vector3 that the world direction will be copied to
  65526. */
  65527. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  65528. /**
  65529. * Get the euler rotation of the bone in local or world space
  65530. * @param space The space that the rotation should be in
  65531. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65532. * @returns The euler rotation
  65533. */
  65534. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  65535. /**
  65536. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  65537. * @param space The space that the rotation should be in
  65538. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65539. * @param result The vector3 that the rotation should be copied to
  65540. */
  65541. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  65542. /**
  65543. * Get the quaternion rotation of the bone in either local or world space
  65544. * @param space The space that the rotation should be in
  65545. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65546. * @returns The quaternion rotation
  65547. */
  65548. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  65549. /**
  65550. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  65551. * @param space The space that the rotation should be in
  65552. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65553. * @param result The quaternion that the rotation should be copied to
  65554. */
  65555. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  65556. /**
  65557. * Get the rotation matrix of the bone in local or world space
  65558. * @param space The space that the rotation should be in
  65559. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65560. * @returns The rotation matrix
  65561. */
  65562. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  65563. /**
  65564. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  65565. * @param space The space that the rotation should be in
  65566. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65567. * @param result The quaternion that the rotation should be copied to
  65568. */
  65569. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  65570. /**
  65571. * Get the world position of a point that is in the local space of the bone
  65572. * @param position The local position
  65573. * @param mesh The mesh that this bone is attached to
  65574. * @returns The world position
  65575. */
  65576. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  65577. /**
  65578. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  65579. * @param position The local position
  65580. * @param mesh The mesh that this bone is attached to
  65581. * @param result The vector3 that the world position should be copied to
  65582. */
  65583. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  65584. /**
  65585. * Get the local position of a point that is in world space
  65586. * @param position The world position
  65587. * @param mesh The mesh that this bone is attached to
  65588. * @returns The local position
  65589. */
  65590. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  65591. /**
  65592. * Get the local position of a point that is in world space and copy it to the result param
  65593. * @param position The world position
  65594. * @param mesh The mesh that this bone is attached to
  65595. * @param result The vector3 that the local position should be copied to
  65596. */
  65597. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  65598. }
  65599. }
  65600. declare module BABYLON {
  65601. /**
  65602. * Class for creating a cube texture
  65603. */
  65604. export class CubeTexture extends BaseTexture {
  65605. private _delayedOnLoad;
  65606. /**
  65607. * The url of the texture
  65608. */
  65609. url: string;
  65610. /**
  65611. * Gets or sets the center of the bounding box associated with the cube texture.
  65612. * It must define where the camera used to render the texture was set
  65613. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  65614. */
  65615. boundingBoxPosition: Vector3;
  65616. private _boundingBoxSize;
  65617. /**
  65618. * Gets or sets the size of the bounding box associated with the cube texture
  65619. * When defined, the cubemap will switch to local mode
  65620. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  65621. * @example https://www.babylonjs-playground.com/#RNASML
  65622. */
  65623. /**
  65624. * Returns the bounding box size
  65625. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  65626. */
  65627. boundingBoxSize: Vector3;
  65628. protected _rotationY: number;
  65629. /**
  65630. * Sets texture matrix rotation angle around Y axis in radians.
  65631. */
  65632. /**
  65633. * Gets texture matrix rotation angle around Y axis radians.
  65634. */
  65635. rotationY: number;
  65636. /**
  65637. * Are mip maps generated for this texture or not.
  65638. */
  65639. readonly noMipmap: boolean;
  65640. private _noMipmap;
  65641. private _files;
  65642. private _extensions;
  65643. private _textureMatrix;
  65644. private _format;
  65645. private _createPolynomials;
  65646. /** @hidden */
  65647. _prefiltered: boolean;
  65648. /**
  65649. * Creates a cube texture from an array of image urls
  65650. * @param files defines an array of image urls
  65651. * @param scene defines the hosting scene
  65652. * @param noMipmap specifies if mip maps are not used
  65653. * @returns a cube texture
  65654. */
  65655. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  65656. /**
  65657. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  65658. * @param url defines the url of the prefiltered texture
  65659. * @param scene defines the scene the texture is attached to
  65660. * @param forcedExtension defines the extension of the file if different from the url
  65661. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  65662. * @return the prefiltered texture
  65663. */
  65664. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  65665. /**
  65666. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  65667. * as prefiltered data.
  65668. * @param rootUrl defines the url of the texture or the root name of the six images
  65669. * @param scene defines the scene the texture is attached to
  65670. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  65671. * @param noMipmap defines if mipmaps should be created or not
  65672. * @param files defines the six files to load for the different faces
  65673. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  65674. * @param onError defines a callback triggered in case of error during load
  65675. * @param format defines the internal format to use for the texture once loaded
  65676. * @param prefiltered defines whether or not the texture is created from prefiltered data
  65677. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  65678. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  65679. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  65680. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  65681. * @return the cube texture
  65682. */
  65683. 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);
  65684. /**
  65685. * Get the current class name of the texture useful for serialization or dynamic coding.
  65686. * @returns "CubeTexture"
  65687. */
  65688. getClassName(): string;
  65689. /**
  65690. * Update the url (and optional buffer) of this texture if url was null during construction.
  65691. * @param url the url of the texture
  65692. * @param forcedExtension defines the extension to use
  65693. * @param onLoad callback called when the texture is loaded (defaults to null)
  65694. */
  65695. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  65696. /**
  65697. * Delays loading of the cube texture
  65698. * @param forcedExtension defines the extension to use
  65699. */
  65700. delayLoad(forcedExtension?: string): void;
  65701. /**
  65702. * Returns the reflection texture matrix
  65703. * @returns the reflection texture matrix
  65704. */
  65705. getReflectionTextureMatrix(): Matrix;
  65706. /**
  65707. * Sets the reflection texture matrix
  65708. * @param value Reflection texture matrix
  65709. */
  65710. setReflectionTextureMatrix(value: Matrix): void;
  65711. /**
  65712. * Parses text to create a cube texture
  65713. * @param parsedTexture define the serialized text to read from
  65714. * @param scene defines the hosting scene
  65715. * @param rootUrl defines the root url of the cube texture
  65716. * @returns a cube texture
  65717. */
  65718. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  65719. /**
  65720. * Makes a clone, or deep copy, of the cube texture
  65721. * @returns a new cube texture
  65722. */
  65723. clone(): CubeTexture;
  65724. }
  65725. }
  65726. declare module BABYLON {
  65727. /** @hidden */
  65728. export var postprocessVertexShader: {
  65729. name: string;
  65730. shader: string;
  65731. };
  65732. }
  65733. declare module BABYLON {
  65734. /**
  65735. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  65736. * This is the base of the follow, arc rotate cameras and Free camera
  65737. * @see http://doc.babylonjs.com/features/cameras
  65738. */
  65739. export class TargetCamera extends Camera {
  65740. private static _RigCamTransformMatrix;
  65741. private static _TargetTransformMatrix;
  65742. private static _TargetFocalPoint;
  65743. /**
  65744. * Define the current direction the camera is moving to
  65745. */
  65746. cameraDirection: Vector3;
  65747. /**
  65748. * Define the current rotation the camera is rotating to
  65749. */
  65750. cameraRotation: Vector2;
  65751. /**
  65752. * When set, the up vector of the camera will be updated by the rotation of the camera
  65753. */
  65754. updateUpVectorFromRotation: boolean;
  65755. private _tmpQuaternion;
  65756. /**
  65757. * Define the current rotation of the camera
  65758. */
  65759. rotation: Vector3;
  65760. /**
  65761. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  65762. */
  65763. rotationQuaternion: Quaternion;
  65764. /**
  65765. * Define the current speed of the camera
  65766. */
  65767. speed: number;
  65768. /**
  65769. * Add cconstraint to the camera to prevent it to move freely in all directions and
  65770. * around all axis.
  65771. */
  65772. noRotationConstraint: boolean;
  65773. /**
  65774. * Define the current target of the camera as an object or a position.
  65775. */
  65776. lockedTarget: any;
  65777. /** @hidden */
  65778. _currentTarget: Vector3;
  65779. /** @hidden */
  65780. _initialFocalDistance: number;
  65781. /** @hidden */
  65782. _viewMatrix: Matrix;
  65783. /** @hidden */
  65784. _camMatrix: Matrix;
  65785. /** @hidden */
  65786. _cameraTransformMatrix: Matrix;
  65787. /** @hidden */
  65788. _cameraRotationMatrix: Matrix;
  65789. /** @hidden */
  65790. _referencePoint: Vector3;
  65791. /** @hidden */
  65792. _transformedReferencePoint: Vector3;
  65793. protected _globalCurrentTarget: Vector3;
  65794. protected _globalCurrentUpVector: Vector3;
  65795. /** @hidden */
  65796. _reset: () => void;
  65797. private _defaultUp;
  65798. /**
  65799. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  65800. * This is the base of the follow, arc rotate cameras and Free camera
  65801. * @see http://doc.babylonjs.com/features/cameras
  65802. * @param name Defines the name of the camera in the scene
  65803. * @param position Defines the start position of the camera in the scene
  65804. * @param scene Defines the scene the camera belongs to
  65805. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  65806. */
  65807. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  65808. /**
  65809. * Gets the position in front of the camera at a given distance.
  65810. * @param distance The distance from the camera we want the position to be
  65811. * @returns the position
  65812. */
  65813. getFrontPosition(distance: number): Vector3;
  65814. /** @hidden */
  65815. _getLockedTargetPosition(): Nullable<Vector3>;
  65816. private _storedPosition;
  65817. private _storedRotation;
  65818. private _storedRotationQuaternion;
  65819. /**
  65820. * Store current camera state of the camera (fov, position, rotation, etc..)
  65821. * @returns the camera
  65822. */
  65823. storeState(): Camera;
  65824. /**
  65825. * Restored camera state. You must call storeState() first
  65826. * @returns whether it was successful or not
  65827. * @hidden
  65828. */
  65829. _restoreStateValues(): boolean;
  65830. /** @hidden */
  65831. _initCache(): void;
  65832. /** @hidden */
  65833. _updateCache(ignoreParentClass?: boolean): void;
  65834. /** @hidden */
  65835. _isSynchronizedViewMatrix(): boolean;
  65836. /** @hidden */
  65837. _computeLocalCameraSpeed(): number;
  65838. /**
  65839. * Defines the target the camera should look at.
  65840. * This will automatically adapt alpha beta and radius to fit within the new target.
  65841. * @param target Defines the new target as a Vector or a mesh
  65842. */
  65843. setTarget(target: Vector3): void;
  65844. /**
  65845. * Return the current target position of the camera. This value is expressed in local space.
  65846. * @returns the target position
  65847. */
  65848. getTarget(): Vector3;
  65849. /** @hidden */
  65850. _decideIfNeedsToMove(): boolean;
  65851. /** @hidden */
  65852. _updatePosition(): void;
  65853. /** @hidden */
  65854. _checkInputs(): void;
  65855. protected _updateCameraRotationMatrix(): void;
  65856. /**
  65857. * 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)
  65858. * @returns the current camera
  65859. */
  65860. private _rotateUpVectorWithCameraRotationMatrix;
  65861. private _cachedRotationZ;
  65862. private _cachedQuaternionRotationZ;
  65863. /** @hidden */
  65864. _getViewMatrix(): Matrix;
  65865. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  65866. /**
  65867. * @hidden
  65868. */
  65869. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  65870. /**
  65871. * @hidden
  65872. */
  65873. _updateRigCameras(): void;
  65874. private _getRigCamPositionAndTarget;
  65875. /**
  65876. * Gets the current object class name.
  65877. * @return the class name
  65878. */
  65879. getClassName(): string;
  65880. }
  65881. }
  65882. declare module BABYLON {
  65883. /**
  65884. * @ignore
  65885. * This is a list of all the different input types that are available in the application.
  65886. * Fo instance: ArcRotateCameraGamepadInput...
  65887. */
  65888. export var CameraInputTypes: {};
  65889. /**
  65890. * This is the contract to implement in order to create a new input class.
  65891. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  65892. */
  65893. export interface ICameraInput<TCamera extends Camera> {
  65894. /**
  65895. * Defines the camera the input is attached to.
  65896. */
  65897. camera: Nullable<TCamera>;
  65898. /**
  65899. * Gets the class name of the current intput.
  65900. * @returns the class name
  65901. */
  65902. getClassName(): string;
  65903. /**
  65904. * Get the friendly name associated with the input class.
  65905. * @returns the input friendly name
  65906. */
  65907. getSimpleName(): string;
  65908. /**
  65909. * Attach the input controls to a specific dom element to get the input from.
  65910. * @param element Defines the element the controls should be listened from
  65911. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  65912. */
  65913. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  65914. /**
  65915. * Detach the current controls from the specified dom element.
  65916. * @param element Defines the element to stop listening the inputs from
  65917. */
  65918. detachControl(element: Nullable<HTMLElement>): void;
  65919. /**
  65920. * Update the current camera state depending on the inputs that have been used this frame.
  65921. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  65922. */
  65923. checkInputs?: () => void;
  65924. }
  65925. /**
  65926. * Represents a map of input types to input instance or input index to input instance.
  65927. */
  65928. export interface CameraInputsMap<TCamera extends Camera> {
  65929. /**
  65930. * Accessor to the input by input type.
  65931. */
  65932. [name: string]: ICameraInput<TCamera>;
  65933. /**
  65934. * Accessor to the input by input index.
  65935. */
  65936. [idx: number]: ICameraInput<TCamera>;
  65937. }
  65938. /**
  65939. * This represents the input manager used within a camera.
  65940. * It helps dealing with all the different kind of input attached to a camera.
  65941. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  65942. */
  65943. export class CameraInputsManager<TCamera extends Camera> {
  65944. /**
  65945. * Defines the list of inputs attahed to the camera.
  65946. */
  65947. attached: CameraInputsMap<TCamera>;
  65948. /**
  65949. * Defines the dom element the camera is collecting inputs from.
  65950. * This is null if the controls have not been attached.
  65951. */
  65952. attachedElement: Nullable<HTMLElement>;
  65953. /**
  65954. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  65955. */
  65956. noPreventDefault: boolean;
  65957. /**
  65958. * Defined the camera the input manager belongs to.
  65959. */
  65960. camera: TCamera;
  65961. /**
  65962. * Update the current camera state depending on the inputs that have been used this frame.
  65963. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  65964. */
  65965. checkInputs: () => void;
  65966. /**
  65967. * Instantiate a new Camera Input Manager.
  65968. * @param camera Defines the camera the input manager blongs to
  65969. */
  65970. constructor(camera: TCamera);
  65971. /**
  65972. * Add an input method to a camera
  65973. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  65974. * @param input camera input method
  65975. */
  65976. add(input: ICameraInput<TCamera>): void;
  65977. /**
  65978. * Remove a specific input method from a camera
  65979. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  65980. * @param inputToRemove camera input method
  65981. */
  65982. remove(inputToRemove: ICameraInput<TCamera>): void;
  65983. /**
  65984. * Remove a specific input type from a camera
  65985. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  65986. * @param inputType the type of the input to remove
  65987. */
  65988. removeByType(inputType: string): void;
  65989. private _addCheckInputs;
  65990. /**
  65991. * Attach the input controls to the currently attached dom element to listen the events from.
  65992. * @param input Defines the input to attach
  65993. */
  65994. attachInput(input: ICameraInput<TCamera>): void;
  65995. /**
  65996. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  65997. * @param element Defines the dom element to collect the events from
  65998. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  65999. */
  66000. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  66001. /**
  66002. * Detach the current manager inputs controls from a specific dom element.
  66003. * @param element Defines the dom element to collect the events from
  66004. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  66005. */
  66006. detachElement(element: HTMLElement, disconnect?: boolean): void;
  66007. /**
  66008. * Rebuild the dynamic inputCheck function from the current list of
  66009. * defined inputs in the manager.
  66010. */
  66011. rebuildInputCheck(): void;
  66012. /**
  66013. * Remove all attached input methods from a camera
  66014. */
  66015. clear(): void;
  66016. /**
  66017. * Serialize the current input manager attached to a camera.
  66018. * This ensures than once parsed,
  66019. * the input associated to the camera will be identical to the current ones
  66020. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  66021. */
  66022. serialize(serializedCamera: any): void;
  66023. /**
  66024. * Parses an input manager serialized JSON to restore the previous list of inputs
  66025. * and states associated to a camera.
  66026. * @param parsedCamera Defines the JSON to parse
  66027. */
  66028. parse(parsedCamera: any): void;
  66029. }
  66030. }
  66031. declare module BABYLON {
  66032. /**
  66033. * Gather the list of keyboard event types as constants.
  66034. */
  66035. export class KeyboardEventTypes {
  66036. /**
  66037. * The keydown event is fired when a key becomes active (pressed).
  66038. */
  66039. static readonly KEYDOWN: number;
  66040. /**
  66041. * The keyup event is fired when a key has been released.
  66042. */
  66043. static readonly KEYUP: number;
  66044. }
  66045. /**
  66046. * This class is used to store keyboard related info for the onKeyboardObservable event.
  66047. */
  66048. export class KeyboardInfo {
  66049. /**
  66050. * Defines the type of event (KeyboardEventTypes)
  66051. */
  66052. type: number;
  66053. /**
  66054. * Defines the related dom event
  66055. */
  66056. event: KeyboardEvent;
  66057. /**
  66058. * Instantiates a new keyboard info.
  66059. * This class is used to store keyboard related info for the onKeyboardObservable event.
  66060. * @param type Defines the type of event (KeyboardEventTypes)
  66061. * @param event Defines the related dom event
  66062. */
  66063. constructor(
  66064. /**
  66065. * Defines the type of event (KeyboardEventTypes)
  66066. */
  66067. type: number,
  66068. /**
  66069. * Defines the related dom event
  66070. */
  66071. event: KeyboardEvent);
  66072. }
  66073. /**
  66074. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  66075. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  66076. */
  66077. export class KeyboardInfoPre extends KeyboardInfo {
  66078. /**
  66079. * Defines the type of event (KeyboardEventTypes)
  66080. */
  66081. type: number;
  66082. /**
  66083. * Defines the related dom event
  66084. */
  66085. event: KeyboardEvent;
  66086. /**
  66087. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  66088. */
  66089. skipOnPointerObservable: boolean;
  66090. /**
  66091. * Instantiates a new keyboard pre info.
  66092. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  66093. * @param type Defines the type of event (KeyboardEventTypes)
  66094. * @param event Defines the related dom event
  66095. */
  66096. constructor(
  66097. /**
  66098. * Defines the type of event (KeyboardEventTypes)
  66099. */
  66100. type: number,
  66101. /**
  66102. * Defines the related dom event
  66103. */
  66104. event: KeyboardEvent);
  66105. }
  66106. }
  66107. declare module BABYLON {
  66108. /**
  66109. * Manage the keyboard inputs to control the movement of a free camera.
  66110. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  66111. */
  66112. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  66113. /**
  66114. * Defines the camera the input is attached to.
  66115. */
  66116. camera: FreeCamera;
  66117. /**
  66118. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  66119. */
  66120. keysUp: number[];
  66121. /**
  66122. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  66123. */
  66124. keysDown: number[];
  66125. /**
  66126. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  66127. */
  66128. keysLeft: number[];
  66129. /**
  66130. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  66131. */
  66132. keysRight: number[];
  66133. private _keys;
  66134. private _onCanvasBlurObserver;
  66135. private _onKeyboardObserver;
  66136. private _engine;
  66137. private _scene;
  66138. /**
  66139. * Attach the input controls to a specific dom element to get the input from.
  66140. * @param element Defines the element the controls should be listened from
  66141. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  66142. */
  66143. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  66144. /**
  66145. * Detach the current controls from the specified dom element.
  66146. * @param element Defines the element to stop listening the inputs from
  66147. */
  66148. detachControl(element: Nullable<HTMLElement>): void;
  66149. /**
  66150. * Update the current camera state depending on the inputs that have been used this frame.
  66151. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  66152. */
  66153. checkInputs(): void;
  66154. /**
  66155. * Gets the class name of the current intput.
  66156. * @returns the class name
  66157. */
  66158. getClassName(): string;
  66159. /** @hidden */
  66160. _onLostFocus(): void;
  66161. /**
  66162. * Get the friendly name associated with the input class.
  66163. * @returns the input friendly name
  66164. */
  66165. getSimpleName(): string;
  66166. }
  66167. }
  66168. declare module BABYLON {
  66169. /**
  66170. * Interface describing all the common properties and methods a shadow light needs to implement.
  66171. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  66172. * as well as binding the different shadow properties to the effects.
  66173. */
  66174. export interface IShadowLight extends Light {
  66175. /**
  66176. * The light id in the scene (used in scene.findLighById for instance)
  66177. */
  66178. id: string;
  66179. /**
  66180. * The position the shdow will be casted from.
  66181. */
  66182. position: Vector3;
  66183. /**
  66184. * In 2d mode (needCube being false), the direction used to cast the shadow.
  66185. */
  66186. direction: Vector3;
  66187. /**
  66188. * The transformed position. Position of the light in world space taking parenting in account.
  66189. */
  66190. transformedPosition: Vector3;
  66191. /**
  66192. * The transformed direction. Direction of the light in world space taking parenting in account.
  66193. */
  66194. transformedDirection: Vector3;
  66195. /**
  66196. * The friendly name of the light in the scene.
  66197. */
  66198. name: string;
  66199. /**
  66200. * Defines the shadow projection clipping minimum z value.
  66201. */
  66202. shadowMinZ: number;
  66203. /**
  66204. * Defines the shadow projection clipping maximum z value.
  66205. */
  66206. shadowMaxZ: number;
  66207. /**
  66208. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  66209. * @returns true if the information has been computed, false if it does not need to (no parenting)
  66210. */
  66211. computeTransformedInformation(): boolean;
  66212. /**
  66213. * Gets the scene the light belongs to.
  66214. * @returns The scene
  66215. */
  66216. getScene(): Scene;
  66217. /**
  66218. * Callback defining a custom Projection Matrix Builder.
  66219. * This can be used to override the default projection matrix computation.
  66220. */
  66221. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  66222. /**
  66223. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  66224. * @param matrix The materix to updated with the projection information
  66225. * @param viewMatrix The transform matrix of the light
  66226. * @param renderList The list of mesh to render in the map
  66227. * @returns The current light
  66228. */
  66229. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  66230. /**
  66231. * Gets the current depth scale used in ESM.
  66232. * @returns The scale
  66233. */
  66234. getDepthScale(): number;
  66235. /**
  66236. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  66237. * @returns true if a cube texture needs to be use
  66238. */
  66239. needCube(): boolean;
  66240. /**
  66241. * Detects if the projection matrix requires to be recomputed this frame.
  66242. * @returns true if it requires to be recomputed otherwise, false.
  66243. */
  66244. needProjectionMatrixCompute(): boolean;
  66245. /**
  66246. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  66247. */
  66248. forceProjectionMatrixCompute(): void;
  66249. /**
  66250. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  66251. * @param faceIndex The index of the face we are computed the direction to generate shadow
  66252. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  66253. */
  66254. getShadowDirection(faceIndex?: number): Vector3;
  66255. /**
  66256. * Gets the minZ used for shadow according to both the scene and the light.
  66257. * @param activeCamera The camera we are returning the min for
  66258. * @returns the depth min z
  66259. */
  66260. getDepthMinZ(activeCamera: Camera): number;
  66261. /**
  66262. * Gets the maxZ used for shadow according to both the scene and the light.
  66263. * @param activeCamera The camera we are returning the max for
  66264. * @returns the depth max z
  66265. */
  66266. getDepthMaxZ(activeCamera: Camera): number;
  66267. }
  66268. /**
  66269. * Base implementation IShadowLight
  66270. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  66271. */
  66272. export abstract class ShadowLight extends Light implements IShadowLight {
  66273. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  66274. protected _position: Vector3;
  66275. protected _setPosition(value: Vector3): void;
  66276. /**
  66277. * Sets the position the shadow will be casted from. Also use as the light position for both
  66278. * point and spot lights.
  66279. */
  66280. /**
  66281. * Sets the position the shadow will be casted from. Also use as the light position for both
  66282. * point and spot lights.
  66283. */
  66284. position: Vector3;
  66285. protected _direction: Vector3;
  66286. protected _setDirection(value: Vector3): void;
  66287. /**
  66288. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  66289. * Also use as the light direction on spot and directional lights.
  66290. */
  66291. /**
  66292. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  66293. * Also use as the light direction on spot and directional lights.
  66294. */
  66295. direction: Vector3;
  66296. private _shadowMinZ;
  66297. /**
  66298. * Gets the shadow projection clipping minimum z value.
  66299. */
  66300. /**
  66301. * Sets the shadow projection clipping minimum z value.
  66302. */
  66303. shadowMinZ: number;
  66304. private _shadowMaxZ;
  66305. /**
  66306. * Sets the shadow projection clipping maximum z value.
  66307. */
  66308. /**
  66309. * Gets the shadow projection clipping maximum z value.
  66310. */
  66311. shadowMaxZ: number;
  66312. /**
  66313. * Callback defining a custom Projection Matrix Builder.
  66314. * This can be used to override the default projection matrix computation.
  66315. */
  66316. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  66317. /**
  66318. * The transformed position. Position of the light in world space taking parenting in account.
  66319. */
  66320. transformedPosition: Vector3;
  66321. /**
  66322. * The transformed direction. Direction of the light in world space taking parenting in account.
  66323. */
  66324. transformedDirection: Vector3;
  66325. private _needProjectionMatrixCompute;
  66326. /**
  66327. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  66328. * @returns true if the information has been computed, false if it does not need to (no parenting)
  66329. */
  66330. computeTransformedInformation(): boolean;
  66331. /**
  66332. * Return the depth scale used for the shadow map.
  66333. * @returns the depth scale.
  66334. */
  66335. getDepthScale(): number;
  66336. /**
  66337. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  66338. * @param faceIndex The index of the face we are computed the direction to generate shadow
  66339. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  66340. */
  66341. getShadowDirection(faceIndex?: number): Vector3;
  66342. /**
  66343. * Returns the ShadowLight absolute position in the World.
  66344. * @returns the position vector in world space
  66345. */
  66346. getAbsolutePosition(): Vector3;
  66347. /**
  66348. * Sets the ShadowLight direction toward the passed target.
  66349. * @param target The point to target in local space
  66350. * @returns the updated ShadowLight direction
  66351. */
  66352. setDirectionToTarget(target: Vector3): Vector3;
  66353. /**
  66354. * Returns the light rotation in euler definition.
  66355. * @returns the x y z rotation in local space.
  66356. */
  66357. getRotation(): Vector3;
  66358. /**
  66359. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  66360. * @returns true if a cube texture needs to be use
  66361. */
  66362. needCube(): boolean;
  66363. /**
  66364. * Detects if the projection matrix requires to be recomputed this frame.
  66365. * @returns true if it requires to be recomputed otherwise, false.
  66366. */
  66367. needProjectionMatrixCompute(): boolean;
  66368. /**
  66369. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  66370. */
  66371. forceProjectionMatrixCompute(): void;
  66372. /** @hidden */
  66373. _initCache(): void;
  66374. /** @hidden */
  66375. _isSynchronized(): boolean;
  66376. /**
  66377. * Computes the world matrix of the node
  66378. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  66379. * @returns the world matrix
  66380. */
  66381. computeWorldMatrix(force?: boolean): Matrix;
  66382. /**
  66383. * Gets the minZ used for shadow according to both the scene and the light.
  66384. * @param activeCamera The camera we are returning the min for
  66385. * @returns the depth min z
  66386. */
  66387. getDepthMinZ(activeCamera: Camera): number;
  66388. /**
  66389. * Gets the maxZ used for shadow according to both the scene and the light.
  66390. * @param activeCamera The camera we are returning the max for
  66391. * @returns the depth max z
  66392. */
  66393. getDepthMaxZ(activeCamera: Camera): number;
  66394. /**
  66395. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  66396. * @param matrix The materix to updated with the projection information
  66397. * @param viewMatrix The transform matrix of the light
  66398. * @param renderList The list of mesh to render in the map
  66399. * @returns The current light
  66400. */
  66401. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  66402. }
  66403. }
  66404. declare module BABYLON {
  66405. /**
  66406. * "Static Class" containing the most commonly used helper while dealing with material for
  66407. * rendering purpose.
  66408. *
  66409. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  66410. *
  66411. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  66412. */
  66413. export class MaterialHelper {
  66414. /**
  66415. * Bind the current view position to an effect.
  66416. * @param effect The effect to be bound
  66417. * @param scene The scene the eyes position is used from
  66418. */
  66419. static BindEyePosition(effect: Effect, scene: Scene): void;
  66420. /**
  66421. * Helps preparing the defines values about the UVs in used in the effect.
  66422. * UVs are shared as much as we can accross channels in the shaders.
  66423. * @param texture The texture we are preparing the UVs for
  66424. * @param defines The defines to update
  66425. * @param key The channel key "diffuse", "specular"... used in the shader
  66426. */
  66427. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  66428. /**
  66429. * Binds a texture matrix value to its corrsponding uniform
  66430. * @param texture The texture to bind the matrix for
  66431. * @param uniformBuffer The uniform buffer receivin the data
  66432. * @param key The channel key "diffuse", "specular"... used in the shader
  66433. */
  66434. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  66435. /**
  66436. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  66437. * @param mesh defines the current mesh
  66438. * @param scene defines the current scene
  66439. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  66440. * @param pointsCloud defines if point cloud rendering has to be turned on
  66441. * @param fogEnabled defines if fog has to be turned on
  66442. * @param alphaTest defines if alpha testing has to be turned on
  66443. * @param defines defines the current list of defines
  66444. */
  66445. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  66446. /**
  66447. * Helper used to prepare the list of defines associated with frame values for shader compilation
  66448. * @param scene defines the current scene
  66449. * @param engine defines the current engine
  66450. * @param defines specifies the list of active defines
  66451. * @param useInstances defines if instances have to be turned on
  66452. * @param useClipPlane defines if clip plane have to be turned on
  66453. */
  66454. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  66455. /**
  66456. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  66457. * @param mesh The mesh containing the geometry data we will draw
  66458. * @param defines The defines to update
  66459. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  66460. * @param useBones Precise whether bones should be used or not (override mesh info)
  66461. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  66462. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  66463. * @returns false if defines are considered not dirty and have not been checked
  66464. */
  66465. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  66466. /**
  66467. * Prepares the defines related to the light information passed in parameter
  66468. * @param scene The scene we are intending to draw
  66469. * @param mesh The mesh the effect is compiling for
  66470. * @param defines The defines to update
  66471. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  66472. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  66473. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  66474. * @returns true if normals will be required for the rest of the effect
  66475. */
  66476. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  66477. /**
  66478. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  66479. * that won t be acctive due to defines being turned off.
  66480. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  66481. * @param samplersList The samplers list
  66482. * @param defines The defines helping in the list generation
  66483. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  66484. */
  66485. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  66486. /**
  66487. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  66488. * @param defines The defines to update while falling back
  66489. * @param fallbacks The authorized effect fallbacks
  66490. * @param maxSimultaneousLights The maximum number of lights allowed
  66491. * @param rank the current rank of the Effect
  66492. * @returns The newly affected rank
  66493. */
  66494. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  66495. /**
  66496. * Prepares the list of attributes required for morph targets according to the effect defines.
  66497. * @param attribs The current list of supported attribs
  66498. * @param mesh The mesh to prepare the morph targets attributes for
  66499. * @param defines The current Defines of the effect
  66500. */
  66501. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  66502. /**
  66503. * Prepares the list of attributes required for bones according to the effect defines.
  66504. * @param attribs The current list of supported attribs
  66505. * @param mesh The mesh to prepare the bones attributes for
  66506. * @param defines The current Defines of the effect
  66507. * @param fallbacks The current efffect fallback strategy
  66508. */
  66509. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  66510. /**
  66511. * Prepares the list of attributes required for instances according to the effect defines.
  66512. * @param attribs The current list of supported attribs
  66513. * @param defines The current Defines of the effect
  66514. */
  66515. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  66516. /**
  66517. * Binds the light shadow information to the effect for the given mesh.
  66518. * @param light The light containing the generator
  66519. * @param scene The scene the lights belongs to
  66520. * @param mesh The mesh we are binding the information to render
  66521. * @param lightIndex The light index in the effect used to render the mesh
  66522. * @param effect The effect we are binding the data to
  66523. */
  66524. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  66525. /**
  66526. * Binds the light information to the effect.
  66527. * @param light The light containing the generator
  66528. * @param effect The effect we are binding the data to
  66529. * @param lightIndex The light index in the effect used to render
  66530. */
  66531. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  66532. /**
  66533. * Binds the lights information from the scene to the effect for the given mesh.
  66534. * @param scene The scene the lights belongs to
  66535. * @param mesh The mesh we are binding the information to render
  66536. * @param effect The effect we are binding the data to
  66537. * @param defines The generated defines for the effect
  66538. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  66539. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  66540. */
  66541. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  66542. private static _tempFogColor;
  66543. /**
  66544. * Binds the fog information from the scene to the effect for the given mesh.
  66545. * @param scene The scene the lights belongs to
  66546. * @param mesh The mesh we are binding the information to render
  66547. * @param effect The effect we are binding the data to
  66548. * @param linearSpace Defines if the fog effect is applied in linear space
  66549. */
  66550. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  66551. /**
  66552. * Binds the bones information from the mesh to the effect.
  66553. * @param mesh The mesh we are binding the information to render
  66554. * @param effect The effect we are binding the data to
  66555. */
  66556. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  66557. /**
  66558. * Binds the morph targets information from the mesh to the effect.
  66559. * @param abstractMesh The mesh we are binding the information to render
  66560. * @param effect The effect we are binding the data to
  66561. */
  66562. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  66563. /**
  66564. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  66565. * @param defines The generated defines used in the effect
  66566. * @param effect The effect we are binding the data to
  66567. * @param scene The scene we are willing to render with logarithmic scale for
  66568. */
  66569. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  66570. /**
  66571. * Binds the clip plane information from the scene to the effect.
  66572. * @param scene The scene the clip plane information are extracted from
  66573. * @param effect The effect we are binding the data to
  66574. */
  66575. static BindClipPlane(effect: Effect, scene: Scene): void;
  66576. }
  66577. }
  66578. declare module BABYLON {
  66579. /** @hidden */
  66580. export var kernelBlurVaryingDeclaration: {
  66581. name: string;
  66582. shader: string;
  66583. };
  66584. }
  66585. declare module BABYLON {
  66586. /** @hidden */
  66587. export var kernelBlurFragment: {
  66588. name: string;
  66589. shader: string;
  66590. };
  66591. }
  66592. declare module BABYLON {
  66593. /** @hidden */
  66594. export var kernelBlurFragment2: {
  66595. name: string;
  66596. shader: string;
  66597. };
  66598. }
  66599. declare module BABYLON {
  66600. /** @hidden */
  66601. export var kernelBlurPixelShader: {
  66602. name: string;
  66603. shader: string;
  66604. };
  66605. }
  66606. declare module BABYLON {
  66607. /** @hidden */
  66608. export var kernelBlurVertex: {
  66609. name: string;
  66610. shader: string;
  66611. };
  66612. }
  66613. declare module BABYLON {
  66614. /** @hidden */
  66615. export var kernelBlurVertexShader: {
  66616. name: string;
  66617. shader: string;
  66618. };
  66619. }
  66620. declare module BABYLON {
  66621. /**
  66622. * The Blur Post Process which blurs an image based on a kernel and direction.
  66623. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  66624. */
  66625. export class BlurPostProcess extends PostProcess {
  66626. /** The direction in which to blur the image. */
  66627. direction: Vector2;
  66628. private blockCompilation;
  66629. protected _kernel: number;
  66630. protected _idealKernel: number;
  66631. protected _packedFloat: boolean;
  66632. private _staticDefines;
  66633. /**
  66634. * Sets the length in pixels of the blur sample region
  66635. */
  66636. /**
  66637. * Gets the length in pixels of the blur sample region
  66638. */
  66639. kernel: number;
  66640. /**
  66641. * Sets wether or not the blur needs to unpack/repack floats
  66642. */
  66643. /**
  66644. * Gets wether or not the blur is unpacking/repacking floats
  66645. */
  66646. packedFloat: boolean;
  66647. /**
  66648. * Creates a new instance BlurPostProcess
  66649. * @param name The name of the effect.
  66650. * @param direction The direction in which to blur the image.
  66651. * @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.
  66652. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  66653. * @param camera The camera to apply the render pass to.
  66654. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  66655. * @param engine The engine which the post process will be applied. (default: current engine)
  66656. * @param reusable If the post process can be reused on the same frame. (default: false)
  66657. * @param textureType Type of textures used when performing the post process. (default: 0)
  66658. * @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)
  66659. */
  66660. constructor(name: string,
  66661. /** The direction in which to blur the image. */
  66662. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  66663. /**
  66664. * Updates the effect with the current post process compile time values and recompiles the shader.
  66665. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  66666. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  66667. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  66668. * @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
  66669. * @param onCompiled Called when the shader has been compiled.
  66670. * @param onError Called if there is an error when compiling a shader.
  66671. */
  66672. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  66673. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  66674. /**
  66675. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  66676. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  66677. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  66678. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  66679. * The gaps between physical kernels are compensated for in the weighting of the samples
  66680. * @param idealKernel Ideal blur kernel.
  66681. * @return Nearest best kernel.
  66682. */
  66683. protected _nearestBestKernel(idealKernel: number): number;
  66684. /**
  66685. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  66686. * @param x The point on the Gaussian distribution to sample.
  66687. * @return the value of the Gaussian function at x.
  66688. */
  66689. protected _gaussianWeight(x: number): number;
  66690. /**
  66691. * Generates a string that can be used as a floating point number in GLSL.
  66692. * @param x Value to print.
  66693. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  66694. * @return GLSL float string.
  66695. */
  66696. protected _glslFloat(x: number, decimalFigures?: number): string;
  66697. }
  66698. }
  66699. declare module BABYLON {
  66700. /** @hidden */
  66701. export var shadowMapPixelShader: {
  66702. name: string;
  66703. shader: string;
  66704. };
  66705. }
  66706. declare module BABYLON {
  66707. /** @hidden */
  66708. export var bonesDeclaration: {
  66709. name: string;
  66710. shader: string;
  66711. };
  66712. }
  66713. declare module BABYLON {
  66714. /** @hidden */
  66715. export var morphTargetsVertexGlobalDeclaration: {
  66716. name: string;
  66717. shader: string;
  66718. };
  66719. }
  66720. declare module BABYLON {
  66721. /** @hidden */
  66722. export var morphTargetsVertexDeclaration: {
  66723. name: string;
  66724. shader: string;
  66725. };
  66726. }
  66727. declare module BABYLON {
  66728. /** @hidden */
  66729. export var instancesDeclaration: {
  66730. name: string;
  66731. shader: string;
  66732. };
  66733. }
  66734. declare module BABYLON {
  66735. /** @hidden */
  66736. export var helperFunctions: {
  66737. name: string;
  66738. shader: string;
  66739. };
  66740. }
  66741. declare module BABYLON {
  66742. /** @hidden */
  66743. export var morphTargetsVertex: {
  66744. name: string;
  66745. shader: string;
  66746. };
  66747. }
  66748. declare module BABYLON {
  66749. /** @hidden */
  66750. export var instancesVertex: {
  66751. name: string;
  66752. shader: string;
  66753. };
  66754. }
  66755. declare module BABYLON {
  66756. /** @hidden */
  66757. export var bonesVertex: {
  66758. name: string;
  66759. shader: string;
  66760. };
  66761. }
  66762. declare module BABYLON {
  66763. /** @hidden */
  66764. export var shadowMapVertexShader: {
  66765. name: string;
  66766. shader: string;
  66767. };
  66768. }
  66769. declare module BABYLON {
  66770. /** @hidden */
  66771. export var depthBoxBlurPixelShader: {
  66772. name: string;
  66773. shader: string;
  66774. };
  66775. }
  66776. declare module BABYLON {
  66777. /**
  66778. * Defines the options associated with the creation of a custom shader for a shadow generator.
  66779. */
  66780. export interface ICustomShaderOptions {
  66781. /**
  66782. * Gets or sets the custom shader name to use
  66783. */
  66784. shaderName: string;
  66785. /**
  66786. * The list of attribute names used in the shader
  66787. */
  66788. attributes?: string[];
  66789. /**
  66790. * The list of unifrom names used in the shader
  66791. */
  66792. uniforms?: string[];
  66793. /**
  66794. * The list of sampler names used in the shader
  66795. */
  66796. samplers?: string[];
  66797. /**
  66798. * The list of defines used in the shader
  66799. */
  66800. defines?: string[];
  66801. }
  66802. /**
  66803. * Interface to implement to create a shadow generator compatible with BJS.
  66804. */
  66805. export interface IShadowGenerator {
  66806. /**
  66807. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  66808. * @returns The render target texture if present otherwise, null
  66809. */
  66810. getShadowMap(): Nullable<RenderTargetTexture>;
  66811. /**
  66812. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  66813. * @returns The render target texture if the shadow map is present otherwise, null
  66814. */
  66815. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  66816. /**
  66817. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  66818. * @param subMesh The submesh we want to render in the shadow map
  66819. * @param useInstances Defines wether will draw in the map using instances
  66820. * @returns true if ready otherwise, false
  66821. */
  66822. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  66823. /**
  66824. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  66825. * @param defines Defines of the material we want to update
  66826. * @param lightIndex Index of the light in the enabled light list of the material
  66827. */
  66828. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  66829. /**
  66830. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  66831. * defined in the generator but impacting the effect).
  66832. * It implies the unifroms available on the materials are the standard BJS ones.
  66833. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  66834. * @param effect The effect we are binfing the information for
  66835. */
  66836. bindShadowLight(lightIndex: string, effect: Effect): void;
  66837. /**
  66838. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  66839. * (eq to shadow prjection matrix * light transform matrix)
  66840. * @returns The transform matrix used to create the shadow map
  66841. */
  66842. getTransformMatrix(): Matrix;
  66843. /**
  66844. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  66845. * Cube and 2D textures for instance.
  66846. */
  66847. recreateShadowMap(): void;
  66848. /**
  66849. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  66850. * @param onCompiled Callback triggered at the and of the effects compilation
  66851. * @param options Sets of optional options forcing the compilation with different modes
  66852. */
  66853. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  66854. useInstances: boolean;
  66855. }>): void;
  66856. /**
  66857. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  66858. * @param options Sets of optional options forcing the compilation with different modes
  66859. * @returns A promise that resolves when the compilation completes
  66860. */
  66861. forceCompilationAsync(options?: Partial<{
  66862. useInstances: boolean;
  66863. }>): Promise<void>;
  66864. /**
  66865. * Serializes the shadow generator setup to a json object.
  66866. * @returns The serialized JSON object
  66867. */
  66868. serialize(): any;
  66869. /**
  66870. * Disposes the Shadow map and related Textures and effects.
  66871. */
  66872. dispose(): void;
  66873. }
  66874. /**
  66875. * Default implementation IShadowGenerator.
  66876. * This is the main object responsible of generating shadows in the framework.
  66877. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  66878. */
  66879. export class ShadowGenerator implements IShadowGenerator {
  66880. /**
  66881. * Shadow generator mode None: no filtering applied.
  66882. */
  66883. static readonly FILTER_NONE: number;
  66884. /**
  66885. * Shadow generator mode ESM: Exponential Shadow Mapping.
  66886. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  66887. */
  66888. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  66889. /**
  66890. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  66891. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  66892. */
  66893. static readonly FILTER_POISSONSAMPLING: number;
  66894. /**
  66895. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  66896. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  66897. */
  66898. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  66899. /**
  66900. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  66901. * edge artifacts on steep falloff.
  66902. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  66903. */
  66904. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  66905. /**
  66906. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  66907. * edge artifacts on steep falloff.
  66908. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  66909. */
  66910. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  66911. /**
  66912. * Shadow generator mode PCF: Percentage Closer Filtering
  66913. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  66914. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  66915. */
  66916. static readonly FILTER_PCF: number;
  66917. /**
  66918. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  66919. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  66920. * Contact Hardening
  66921. */
  66922. static readonly FILTER_PCSS: number;
  66923. /**
  66924. * Reserved for PCF and PCSS
  66925. * Highest Quality.
  66926. *
  66927. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  66928. *
  66929. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  66930. */
  66931. static readonly QUALITY_HIGH: number;
  66932. /**
  66933. * Reserved for PCF and PCSS
  66934. * Good tradeoff for quality/perf cross devices
  66935. *
  66936. * Execute PCF on a 3*3 kernel.
  66937. *
  66938. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  66939. */
  66940. static readonly QUALITY_MEDIUM: number;
  66941. /**
  66942. * Reserved for PCF and PCSS
  66943. * The lowest quality but the fastest.
  66944. *
  66945. * Execute PCF on a 1*1 kernel.
  66946. *
  66947. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  66948. */
  66949. static readonly QUALITY_LOW: number;
  66950. /** Gets or sets the custom shader name to use */
  66951. customShaderOptions: ICustomShaderOptions;
  66952. /**
  66953. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  66954. */
  66955. onBeforeShadowMapRenderObservable: Observable<Effect>;
  66956. /**
  66957. * Observable triggered before a mesh is rendered in the shadow map.
  66958. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  66959. */
  66960. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  66961. private _bias;
  66962. /**
  66963. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  66964. */
  66965. /**
  66966. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  66967. */
  66968. bias: number;
  66969. private _normalBias;
  66970. /**
  66971. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  66972. */
  66973. /**
  66974. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  66975. */
  66976. normalBias: number;
  66977. private _blurBoxOffset;
  66978. /**
  66979. * Gets the blur box offset: offset applied during the blur pass.
  66980. * Only useful if useKernelBlur = false
  66981. */
  66982. /**
  66983. * Sets the blur box offset: offset applied during the blur pass.
  66984. * Only useful if useKernelBlur = false
  66985. */
  66986. blurBoxOffset: number;
  66987. private _blurScale;
  66988. /**
  66989. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  66990. * 2 means half of the size.
  66991. */
  66992. /**
  66993. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  66994. * 2 means half of the size.
  66995. */
  66996. blurScale: number;
  66997. private _blurKernel;
  66998. /**
  66999. * Gets the blur kernel: kernel size of the blur pass.
  67000. * Only useful if useKernelBlur = true
  67001. */
  67002. /**
  67003. * Sets the blur kernel: kernel size of the blur pass.
  67004. * Only useful if useKernelBlur = true
  67005. */
  67006. blurKernel: number;
  67007. private _useKernelBlur;
  67008. /**
  67009. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  67010. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  67011. */
  67012. /**
  67013. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  67014. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  67015. */
  67016. useKernelBlur: boolean;
  67017. private _depthScale;
  67018. /**
  67019. * Gets the depth scale used in ESM mode.
  67020. */
  67021. /**
  67022. * Sets the depth scale used in ESM mode.
  67023. * This can override the scale stored on the light.
  67024. */
  67025. depthScale: number;
  67026. private _filter;
  67027. /**
  67028. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  67029. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  67030. */
  67031. /**
  67032. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  67033. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  67034. */
  67035. filter: number;
  67036. /**
  67037. * Gets if the current filter is set to Poisson Sampling.
  67038. */
  67039. /**
  67040. * Sets the current filter to Poisson Sampling.
  67041. */
  67042. usePoissonSampling: boolean;
  67043. /**
  67044. * Gets if the current filter is set to ESM.
  67045. */
  67046. /**
  67047. * Sets the current filter is to ESM.
  67048. */
  67049. useExponentialShadowMap: boolean;
  67050. /**
  67051. * Gets if the current filter is set to filtered ESM.
  67052. */
  67053. /**
  67054. * Gets if the current filter is set to filtered ESM.
  67055. */
  67056. useBlurExponentialShadowMap: boolean;
  67057. /**
  67058. * Gets if the current filter is set to "close ESM" (using the inverse of the
  67059. * exponential to prevent steep falloff artifacts).
  67060. */
  67061. /**
  67062. * Sets the current filter to "close ESM" (using the inverse of the
  67063. * exponential to prevent steep falloff artifacts).
  67064. */
  67065. useCloseExponentialShadowMap: boolean;
  67066. /**
  67067. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  67068. * exponential to prevent steep falloff artifacts).
  67069. */
  67070. /**
  67071. * Sets the current filter to filtered "close ESM" (using the inverse of the
  67072. * exponential to prevent steep falloff artifacts).
  67073. */
  67074. useBlurCloseExponentialShadowMap: boolean;
  67075. /**
  67076. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  67077. */
  67078. /**
  67079. * Sets the current filter to "PCF" (percentage closer filtering).
  67080. */
  67081. usePercentageCloserFiltering: boolean;
  67082. private _filteringQuality;
  67083. /**
  67084. * Gets the PCF or PCSS Quality.
  67085. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  67086. */
  67087. /**
  67088. * Sets the PCF or PCSS Quality.
  67089. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  67090. */
  67091. filteringQuality: number;
  67092. /**
  67093. * Gets if the current filter is set to "PCSS" (contact hardening).
  67094. */
  67095. /**
  67096. * Sets the current filter to "PCSS" (contact hardening).
  67097. */
  67098. useContactHardeningShadow: boolean;
  67099. private _contactHardeningLightSizeUVRatio;
  67100. /**
  67101. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  67102. * Using a ratio helps keeping shape stability independently of the map size.
  67103. *
  67104. * It does not account for the light projection as it was having too much
  67105. * instability during the light setup or during light position changes.
  67106. *
  67107. * Only valid if useContactHardeningShadow is true.
  67108. */
  67109. /**
  67110. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  67111. * Using a ratio helps keeping shape stability independently of the map size.
  67112. *
  67113. * It does not account for the light projection as it was having too much
  67114. * instability during the light setup or during light position changes.
  67115. *
  67116. * Only valid if useContactHardeningShadow is true.
  67117. */
  67118. contactHardeningLightSizeUVRatio: number;
  67119. private _darkness;
  67120. /**
  67121. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  67122. * 0 means strongest and 1 would means no shadow.
  67123. * @returns the darkness.
  67124. */
  67125. getDarkness(): number;
  67126. /**
  67127. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  67128. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  67129. * @returns the shadow generator allowing fluent coding.
  67130. */
  67131. setDarkness(darkness: number): ShadowGenerator;
  67132. private _transparencyShadow;
  67133. /**
  67134. * Sets the ability to have transparent shadow (boolean).
  67135. * @param transparent True if transparent else False
  67136. * @returns the shadow generator allowing fluent coding
  67137. */
  67138. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  67139. private _shadowMap;
  67140. private _shadowMap2;
  67141. /**
  67142. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  67143. * @returns The render target texture if present otherwise, null
  67144. */
  67145. getShadowMap(): Nullable<RenderTargetTexture>;
  67146. /**
  67147. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  67148. * @returns The render target texture if the shadow map is present otherwise, null
  67149. */
  67150. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  67151. /**
  67152. * Helper function to add a mesh and its descendants to the list of shadow casters.
  67153. * @param mesh Mesh to add
  67154. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  67155. * @returns the Shadow Generator itself
  67156. */
  67157. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  67158. /**
  67159. * Helper function to remove a mesh and its descendants from the list of shadow casters
  67160. * @param mesh Mesh to remove
  67161. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  67162. * @returns the Shadow Generator itself
  67163. */
  67164. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  67165. /**
  67166. * Controls the extent to which the shadows fade out at the edge of the frustum
  67167. * Used only by directionals and spots
  67168. */
  67169. frustumEdgeFalloff: number;
  67170. private _light;
  67171. /**
  67172. * Returns the associated light object.
  67173. * @returns the light generating the shadow
  67174. */
  67175. getLight(): IShadowLight;
  67176. /**
  67177. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  67178. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  67179. * It might on the other hand introduce peter panning.
  67180. */
  67181. forceBackFacesOnly: boolean;
  67182. private _scene;
  67183. private _lightDirection;
  67184. private _effect;
  67185. private _viewMatrix;
  67186. private _projectionMatrix;
  67187. private _transformMatrix;
  67188. private _cachedPosition;
  67189. private _cachedDirection;
  67190. private _cachedDefines;
  67191. private _currentRenderID;
  67192. private _boxBlurPostprocess;
  67193. private _kernelBlurXPostprocess;
  67194. private _kernelBlurYPostprocess;
  67195. private _blurPostProcesses;
  67196. private _mapSize;
  67197. private _currentFaceIndex;
  67198. private _currentFaceIndexCache;
  67199. private _textureType;
  67200. private _defaultTextureMatrix;
  67201. /** @hidden */
  67202. static _SceneComponentInitialization: (scene: Scene) => void;
  67203. /**
  67204. * Creates a ShadowGenerator object.
  67205. * A ShadowGenerator is the required tool to use the shadows.
  67206. * Each light casting shadows needs to use its own ShadowGenerator.
  67207. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  67208. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  67209. * @param light The light object generating the shadows.
  67210. * @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.
  67211. */
  67212. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  67213. private _initializeGenerator;
  67214. private _initializeShadowMap;
  67215. private _initializeBlurRTTAndPostProcesses;
  67216. private _renderForShadowMap;
  67217. private _renderSubMeshForShadowMap;
  67218. private _applyFilterValues;
  67219. /**
  67220. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  67221. * @param onCompiled Callback triggered at the and of the effects compilation
  67222. * @param options Sets of optional options forcing the compilation with different modes
  67223. */
  67224. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  67225. useInstances: boolean;
  67226. }>): void;
  67227. /**
  67228. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  67229. * @param options Sets of optional options forcing the compilation with different modes
  67230. * @returns A promise that resolves when the compilation completes
  67231. */
  67232. forceCompilationAsync(options?: Partial<{
  67233. useInstances: boolean;
  67234. }>): Promise<void>;
  67235. /**
  67236. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  67237. * @param subMesh The submesh we want to render in the shadow map
  67238. * @param useInstances Defines wether will draw in the map using instances
  67239. * @returns true if ready otherwise, false
  67240. */
  67241. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  67242. /**
  67243. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  67244. * @param defines Defines of the material we want to update
  67245. * @param lightIndex Index of the light in the enabled light list of the material
  67246. */
  67247. prepareDefines(defines: any, lightIndex: number): void;
  67248. /**
  67249. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  67250. * defined in the generator but impacting the effect).
  67251. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  67252. * @param effect The effect we are binfing the information for
  67253. */
  67254. bindShadowLight(lightIndex: string, effect: Effect): void;
  67255. /**
  67256. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  67257. * (eq to shadow prjection matrix * light transform matrix)
  67258. * @returns The transform matrix used to create the shadow map
  67259. */
  67260. getTransformMatrix(): Matrix;
  67261. /**
  67262. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  67263. * Cube and 2D textures for instance.
  67264. */
  67265. recreateShadowMap(): void;
  67266. private _disposeBlurPostProcesses;
  67267. private _disposeRTTandPostProcesses;
  67268. /**
  67269. * Disposes the ShadowGenerator.
  67270. * Returns nothing.
  67271. */
  67272. dispose(): void;
  67273. /**
  67274. * Serializes the shadow generator setup to a json object.
  67275. * @returns The serialized JSON object
  67276. */
  67277. serialize(): any;
  67278. /**
  67279. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  67280. * @param parsedShadowGenerator The JSON object to parse
  67281. * @param scene The scene to create the shadow map for
  67282. * @returns The parsed shadow generator
  67283. */
  67284. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  67285. }
  67286. }
  67287. declare module BABYLON {
  67288. /**
  67289. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  67290. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  67291. * 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.
  67292. */
  67293. export abstract class Light extends Node {
  67294. /**
  67295. * Falloff Default: light is falling off following the material specification:
  67296. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  67297. */
  67298. static readonly FALLOFF_DEFAULT: number;
  67299. /**
  67300. * Falloff Physical: light is falling off following the inverse squared distance law.
  67301. */
  67302. static readonly FALLOFF_PHYSICAL: number;
  67303. /**
  67304. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  67305. * to enhance interoperability with other engines.
  67306. */
  67307. static readonly FALLOFF_GLTF: number;
  67308. /**
  67309. * Falloff Standard: light is falling off like in the standard material
  67310. * to enhance interoperability with other materials.
  67311. */
  67312. static readonly FALLOFF_STANDARD: number;
  67313. /**
  67314. * If every light affecting the material is in this lightmapMode,
  67315. * material.lightmapTexture adds or multiplies
  67316. * (depends on material.useLightmapAsShadowmap)
  67317. * after every other light calculations.
  67318. */
  67319. static readonly LIGHTMAP_DEFAULT: number;
  67320. /**
  67321. * material.lightmapTexture as only diffuse lighting from this light
  67322. * adds only specular lighting from this light
  67323. * adds dynamic shadows
  67324. */
  67325. static readonly LIGHTMAP_SPECULAR: number;
  67326. /**
  67327. * material.lightmapTexture as only lighting
  67328. * no light calculation from this light
  67329. * only adds dynamic shadows from this light
  67330. */
  67331. static readonly LIGHTMAP_SHADOWSONLY: number;
  67332. /**
  67333. * Each light type uses the default quantity according to its type:
  67334. * point/spot lights use luminous intensity
  67335. * directional lights use illuminance
  67336. */
  67337. static readonly INTENSITYMODE_AUTOMATIC: number;
  67338. /**
  67339. * lumen (lm)
  67340. */
  67341. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  67342. /**
  67343. * candela (lm/sr)
  67344. */
  67345. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  67346. /**
  67347. * lux (lm/m^2)
  67348. */
  67349. static readonly INTENSITYMODE_ILLUMINANCE: number;
  67350. /**
  67351. * nit (cd/m^2)
  67352. */
  67353. static readonly INTENSITYMODE_LUMINANCE: number;
  67354. /**
  67355. * Light type const id of the point light.
  67356. */
  67357. static readonly LIGHTTYPEID_POINTLIGHT: number;
  67358. /**
  67359. * Light type const id of the directional light.
  67360. */
  67361. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  67362. /**
  67363. * Light type const id of the spot light.
  67364. */
  67365. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  67366. /**
  67367. * Light type const id of the hemispheric light.
  67368. */
  67369. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  67370. /**
  67371. * Diffuse gives the basic color to an object.
  67372. */
  67373. diffuse: Color3;
  67374. /**
  67375. * Specular produces a highlight color on an object.
  67376. * Note: This is note affecting PBR materials.
  67377. */
  67378. specular: Color3;
  67379. /**
  67380. * Defines the falloff type for this light. This lets overrriding how punctual light are
  67381. * falling off base on range or angle.
  67382. * This can be set to any values in Light.FALLOFF_x.
  67383. *
  67384. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  67385. * other types of materials.
  67386. */
  67387. falloffType: number;
  67388. /**
  67389. * Strength of the light.
  67390. * Note: By default it is define in the framework own unit.
  67391. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  67392. */
  67393. intensity: number;
  67394. private _range;
  67395. protected _inverseSquaredRange: number;
  67396. /**
  67397. * Defines how far from the source the light is impacting in scene units.
  67398. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  67399. */
  67400. /**
  67401. * Defines how far from the source the light is impacting in scene units.
  67402. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  67403. */
  67404. range: number;
  67405. /**
  67406. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  67407. * of light.
  67408. */
  67409. private _photometricScale;
  67410. private _intensityMode;
  67411. /**
  67412. * Gets the photometric scale used to interpret the intensity.
  67413. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  67414. */
  67415. /**
  67416. * Sets the photometric scale used to interpret the intensity.
  67417. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  67418. */
  67419. intensityMode: number;
  67420. private _radius;
  67421. /**
  67422. * Gets the light radius used by PBR Materials to simulate soft area lights.
  67423. */
  67424. /**
  67425. * sets the light radius used by PBR Materials to simulate soft area lights.
  67426. */
  67427. radius: number;
  67428. private _renderPriority;
  67429. /**
  67430. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  67431. * exceeding the number allowed of the materials.
  67432. */
  67433. renderPriority: number;
  67434. private _shadowEnabled;
  67435. /**
  67436. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  67437. * the current shadow generator.
  67438. */
  67439. /**
  67440. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  67441. * the current shadow generator.
  67442. */
  67443. shadowEnabled: boolean;
  67444. private _includedOnlyMeshes;
  67445. /**
  67446. * Gets the only meshes impacted by this light.
  67447. */
  67448. /**
  67449. * Sets the only meshes impacted by this light.
  67450. */
  67451. includedOnlyMeshes: AbstractMesh[];
  67452. private _excludedMeshes;
  67453. /**
  67454. * Gets the meshes not impacted by this light.
  67455. */
  67456. /**
  67457. * Sets the meshes not impacted by this light.
  67458. */
  67459. excludedMeshes: AbstractMesh[];
  67460. private _excludeWithLayerMask;
  67461. /**
  67462. * Gets the layer id use to find what meshes are not impacted by the light.
  67463. * Inactive if 0
  67464. */
  67465. /**
  67466. * Sets the layer id use to find what meshes are not impacted by the light.
  67467. * Inactive if 0
  67468. */
  67469. excludeWithLayerMask: number;
  67470. private _includeOnlyWithLayerMask;
  67471. /**
  67472. * Gets the layer id use to find what meshes are impacted by the light.
  67473. * Inactive if 0
  67474. */
  67475. /**
  67476. * Sets the layer id use to find what meshes are impacted by the light.
  67477. * Inactive if 0
  67478. */
  67479. includeOnlyWithLayerMask: number;
  67480. private _lightmapMode;
  67481. /**
  67482. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  67483. */
  67484. /**
  67485. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  67486. */
  67487. lightmapMode: number;
  67488. /**
  67489. * Shadow generator associted to the light.
  67490. * @hidden Internal use only.
  67491. */
  67492. _shadowGenerator: Nullable<IShadowGenerator>;
  67493. /**
  67494. * @hidden Internal use only.
  67495. */
  67496. _excludedMeshesIds: string[];
  67497. /**
  67498. * @hidden Internal use only.
  67499. */
  67500. _includedOnlyMeshesIds: string[];
  67501. /**
  67502. * The current light unifom buffer.
  67503. * @hidden Internal use only.
  67504. */
  67505. _uniformBuffer: UniformBuffer;
  67506. /**
  67507. * Creates a Light object in the scene.
  67508. * Documentation : https://doc.babylonjs.com/babylon101/lights
  67509. * @param name The firendly name of the light
  67510. * @param scene The scene the light belongs too
  67511. */
  67512. constructor(name: string, scene: Scene);
  67513. protected abstract _buildUniformLayout(): void;
  67514. /**
  67515. * Sets the passed Effect "effect" with the Light information.
  67516. * @param effect The effect to update
  67517. * @param lightIndex The index of the light in the effect to update
  67518. * @returns The light
  67519. */
  67520. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  67521. /**
  67522. * Returns the string "Light".
  67523. * @returns the class name
  67524. */
  67525. getClassName(): string;
  67526. /** @hidden */
  67527. readonly _isLight: boolean;
  67528. /**
  67529. * Converts the light information to a readable string for debug purpose.
  67530. * @param fullDetails Supports for multiple levels of logging within scene loading
  67531. * @returns the human readable light info
  67532. */
  67533. toString(fullDetails?: boolean): string;
  67534. /** @hidden */
  67535. protected _syncParentEnabledState(): void;
  67536. /**
  67537. * Set the enabled state of this node.
  67538. * @param value - the new enabled state
  67539. */
  67540. setEnabled(value: boolean): void;
  67541. /**
  67542. * Returns the Light associated shadow generator if any.
  67543. * @return the associated shadow generator.
  67544. */
  67545. getShadowGenerator(): Nullable<IShadowGenerator>;
  67546. /**
  67547. * Returns a Vector3, the absolute light position in the World.
  67548. * @returns the world space position of the light
  67549. */
  67550. getAbsolutePosition(): Vector3;
  67551. /**
  67552. * Specifies if the light will affect the passed mesh.
  67553. * @param mesh The mesh to test against the light
  67554. * @return true the mesh is affected otherwise, false.
  67555. */
  67556. canAffectMesh(mesh: AbstractMesh): boolean;
  67557. /**
  67558. * Sort function to order lights for rendering.
  67559. * @param a First Light object to compare to second.
  67560. * @param b Second Light object to compare first.
  67561. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  67562. */
  67563. static CompareLightsPriority(a: Light, b: Light): number;
  67564. /**
  67565. * Releases resources associated with this node.
  67566. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  67567. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  67568. */
  67569. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  67570. /**
  67571. * Returns the light type ID (integer).
  67572. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  67573. */
  67574. getTypeID(): number;
  67575. /**
  67576. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  67577. * @returns the scaled intensity in intensity mode unit
  67578. */
  67579. getScaledIntensity(): number;
  67580. /**
  67581. * Returns a new Light object, named "name", from the current one.
  67582. * @param name The name of the cloned light
  67583. * @returns the new created light
  67584. */
  67585. clone(name: string): Nullable<Light>;
  67586. /**
  67587. * Serializes the current light into a Serialization object.
  67588. * @returns the serialized object.
  67589. */
  67590. serialize(): any;
  67591. /**
  67592. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  67593. * This new light is named "name" and added to the passed scene.
  67594. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  67595. * @param name The friendly name of the light
  67596. * @param scene The scene the new light will belong to
  67597. * @returns the constructor function
  67598. */
  67599. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  67600. /**
  67601. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  67602. * @param parsedLight The JSON representation of the light
  67603. * @param scene The scene to create the parsed light in
  67604. * @returns the created light after parsing
  67605. */
  67606. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  67607. private _hookArrayForExcluded;
  67608. private _hookArrayForIncludedOnly;
  67609. private _resyncMeshes;
  67610. /**
  67611. * Forces the meshes to update their light related information in their rendering used effects
  67612. * @hidden Internal Use Only
  67613. */
  67614. _markMeshesAsLightDirty(): void;
  67615. /**
  67616. * Recomputes the cached photometric scale if needed.
  67617. */
  67618. private _computePhotometricScale;
  67619. /**
  67620. * Returns the Photometric Scale according to the light type and intensity mode.
  67621. */
  67622. private _getPhotometricScale;
  67623. /**
  67624. * Reorder the light in the scene according to their defined priority.
  67625. * @hidden Internal Use Only
  67626. */
  67627. _reorderLightsInScene(): void;
  67628. /**
  67629. * Prepares the list of defines specific to the light type.
  67630. * @param defines the list of defines
  67631. * @param lightIndex defines the index of the light for the effect
  67632. */
  67633. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  67634. }
  67635. }
  67636. declare module BABYLON {
  67637. /**
  67638. * Interface used to define Action
  67639. */
  67640. export interface IAction {
  67641. /**
  67642. * Trigger for the action
  67643. */
  67644. trigger: number;
  67645. /** Options of the trigger */
  67646. triggerOptions: any;
  67647. /**
  67648. * Gets the trigger parameters
  67649. * @returns the trigger parameters
  67650. */
  67651. getTriggerParameter(): any;
  67652. /**
  67653. * Internal only - executes current action event
  67654. * @hidden
  67655. */
  67656. _executeCurrent(evt?: ActionEvent): void;
  67657. /**
  67658. * Serialize placeholder for child classes
  67659. * @param parent of child
  67660. * @returns the serialized object
  67661. */
  67662. serialize(parent: any): any;
  67663. /**
  67664. * Internal only
  67665. * @hidden
  67666. */
  67667. _prepare(): void;
  67668. /**
  67669. * Internal only - manager for action
  67670. * @hidden
  67671. */
  67672. _actionManager: AbstractActionManager;
  67673. }
  67674. /**
  67675. * The action to be carried out following a trigger
  67676. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  67677. */
  67678. export class Action implements IAction {
  67679. /** the trigger, with or without parameters, for the action */
  67680. triggerOptions: any;
  67681. /**
  67682. * Trigger for the action
  67683. */
  67684. trigger: number;
  67685. /**
  67686. * Internal only - manager for action
  67687. * @hidden
  67688. */
  67689. _actionManager: ActionManager;
  67690. private _nextActiveAction;
  67691. private _child;
  67692. private _condition?;
  67693. private _triggerParameter;
  67694. /**
  67695. * An event triggered prior to action being executed.
  67696. */
  67697. onBeforeExecuteObservable: Observable<Action>;
  67698. /**
  67699. * Creates a new Action
  67700. * @param triggerOptions the trigger, with or without parameters, for the action
  67701. * @param condition an optional determinant of action
  67702. */
  67703. constructor(
  67704. /** the trigger, with or without parameters, for the action */
  67705. triggerOptions: any, condition?: Condition);
  67706. /**
  67707. * Internal only
  67708. * @hidden
  67709. */
  67710. _prepare(): void;
  67711. /**
  67712. * Gets the trigger parameters
  67713. * @returns the trigger parameters
  67714. */
  67715. getTriggerParameter(): any;
  67716. /**
  67717. * Internal only - executes current action event
  67718. * @hidden
  67719. */
  67720. _executeCurrent(evt?: ActionEvent): void;
  67721. /**
  67722. * Execute placeholder for child classes
  67723. * @param evt optional action event
  67724. */
  67725. execute(evt?: ActionEvent): void;
  67726. /**
  67727. * Skips to next active action
  67728. */
  67729. skipToNextActiveAction(): void;
  67730. /**
  67731. * Adds action to chain of actions, may be a DoNothingAction
  67732. * @param action defines the next action to execute
  67733. * @returns The action passed in
  67734. * @see https://www.babylonjs-playground.com/#1T30HR#0
  67735. */
  67736. then(action: Action): Action;
  67737. /**
  67738. * Internal only
  67739. * @hidden
  67740. */
  67741. _getProperty(propertyPath: string): string;
  67742. /**
  67743. * Internal only
  67744. * @hidden
  67745. */
  67746. _getEffectiveTarget(target: any, propertyPath: string): any;
  67747. /**
  67748. * Serialize placeholder for child classes
  67749. * @param parent of child
  67750. * @returns the serialized object
  67751. */
  67752. serialize(parent: any): any;
  67753. /**
  67754. * Internal only called by serialize
  67755. * @hidden
  67756. */
  67757. protected _serialize(serializedAction: any, parent?: any): any;
  67758. /**
  67759. * Internal only
  67760. * @hidden
  67761. */
  67762. static _SerializeValueAsString: (value: any) => string;
  67763. /**
  67764. * Internal only
  67765. * @hidden
  67766. */
  67767. static _GetTargetProperty: (target: Scene | Node) => {
  67768. name: string;
  67769. targetType: string;
  67770. value: string;
  67771. };
  67772. }
  67773. }
  67774. declare module BABYLON {
  67775. /**
  67776. * A Condition applied to an Action
  67777. */
  67778. export class Condition {
  67779. /**
  67780. * Internal only - manager for action
  67781. * @hidden
  67782. */
  67783. _actionManager: ActionManager;
  67784. /**
  67785. * Internal only
  67786. * @hidden
  67787. */
  67788. _evaluationId: number;
  67789. /**
  67790. * Internal only
  67791. * @hidden
  67792. */
  67793. _currentResult: boolean;
  67794. /**
  67795. * Creates a new Condition
  67796. * @param actionManager the manager of the action the condition is applied to
  67797. */
  67798. constructor(actionManager: ActionManager);
  67799. /**
  67800. * Check if the current condition is valid
  67801. * @returns a boolean
  67802. */
  67803. isValid(): boolean;
  67804. /**
  67805. * Internal only
  67806. * @hidden
  67807. */
  67808. _getProperty(propertyPath: string): string;
  67809. /**
  67810. * Internal only
  67811. * @hidden
  67812. */
  67813. _getEffectiveTarget(target: any, propertyPath: string): any;
  67814. /**
  67815. * Serialize placeholder for child classes
  67816. * @returns the serialized object
  67817. */
  67818. serialize(): any;
  67819. /**
  67820. * Internal only
  67821. * @hidden
  67822. */
  67823. protected _serialize(serializedCondition: any): any;
  67824. }
  67825. /**
  67826. * Defines specific conditional operators as extensions of Condition
  67827. */
  67828. export class ValueCondition extends Condition {
  67829. /** path to specify the property of the target the conditional operator uses */
  67830. propertyPath: string;
  67831. /** the value compared by the conditional operator against the current value of the property */
  67832. value: any;
  67833. /** the conditional operator, default ValueCondition.IsEqual */
  67834. operator: number;
  67835. /**
  67836. * Internal only
  67837. * @hidden
  67838. */
  67839. private static _IsEqual;
  67840. /**
  67841. * Internal only
  67842. * @hidden
  67843. */
  67844. private static _IsDifferent;
  67845. /**
  67846. * Internal only
  67847. * @hidden
  67848. */
  67849. private static _IsGreater;
  67850. /**
  67851. * Internal only
  67852. * @hidden
  67853. */
  67854. private static _IsLesser;
  67855. /**
  67856. * returns the number for IsEqual
  67857. */
  67858. static readonly IsEqual: number;
  67859. /**
  67860. * Returns the number for IsDifferent
  67861. */
  67862. static readonly IsDifferent: number;
  67863. /**
  67864. * Returns the number for IsGreater
  67865. */
  67866. static readonly IsGreater: number;
  67867. /**
  67868. * Returns the number for IsLesser
  67869. */
  67870. static readonly IsLesser: number;
  67871. /**
  67872. * Internal only The action manager for the condition
  67873. * @hidden
  67874. */
  67875. _actionManager: ActionManager;
  67876. /**
  67877. * Internal only
  67878. * @hidden
  67879. */
  67880. private _target;
  67881. /**
  67882. * Internal only
  67883. * @hidden
  67884. */
  67885. private _effectiveTarget;
  67886. /**
  67887. * Internal only
  67888. * @hidden
  67889. */
  67890. private _property;
  67891. /**
  67892. * Creates a new ValueCondition
  67893. * @param actionManager manager for the action the condition applies to
  67894. * @param target for the action
  67895. * @param propertyPath path to specify the property of the target the conditional operator uses
  67896. * @param value the value compared by the conditional operator against the current value of the property
  67897. * @param operator the conditional operator, default ValueCondition.IsEqual
  67898. */
  67899. constructor(actionManager: ActionManager, target: any,
  67900. /** path to specify the property of the target the conditional operator uses */
  67901. propertyPath: string,
  67902. /** the value compared by the conditional operator against the current value of the property */
  67903. value: any,
  67904. /** the conditional operator, default ValueCondition.IsEqual */
  67905. operator?: number);
  67906. /**
  67907. * Compares the given value with the property value for the specified conditional operator
  67908. * @returns the result of the comparison
  67909. */
  67910. isValid(): boolean;
  67911. /**
  67912. * Serialize the ValueCondition into a JSON compatible object
  67913. * @returns serialization object
  67914. */
  67915. serialize(): any;
  67916. /**
  67917. * Gets the name of the conditional operator for the ValueCondition
  67918. * @param operator the conditional operator
  67919. * @returns the name
  67920. */
  67921. static GetOperatorName(operator: number): string;
  67922. }
  67923. /**
  67924. * Defines a predicate condition as an extension of Condition
  67925. */
  67926. export class PredicateCondition extends Condition {
  67927. /** defines the predicate function used to validate the condition */
  67928. predicate: () => boolean;
  67929. /**
  67930. * Internal only - manager for action
  67931. * @hidden
  67932. */
  67933. _actionManager: ActionManager;
  67934. /**
  67935. * Creates a new PredicateCondition
  67936. * @param actionManager manager for the action the condition applies to
  67937. * @param predicate defines the predicate function used to validate the condition
  67938. */
  67939. constructor(actionManager: ActionManager,
  67940. /** defines the predicate function used to validate the condition */
  67941. predicate: () => boolean);
  67942. /**
  67943. * @returns the validity of the predicate condition
  67944. */
  67945. isValid(): boolean;
  67946. }
  67947. /**
  67948. * Defines a state condition as an extension of Condition
  67949. */
  67950. export class StateCondition extends Condition {
  67951. /** Value to compare with target state */
  67952. value: string;
  67953. /**
  67954. * Internal only - manager for action
  67955. * @hidden
  67956. */
  67957. _actionManager: ActionManager;
  67958. /**
  67959. * Internal only
  67960. * @hidden
  67961. */
  67962. private _target;
  67963. /**
  67964. * Creates a new StateCondition
  67965. * @param actionManager manager for the action the condition applies to
  67966. * @param target of the condition
  67967. * @param value to compare with target state
  67968. */
  67969. constructor(actionManager: ActionManager, target: any,
  67970. /** Value to compare with target state */
  67971. value: string);
  67972. /**
  67973. * Gets a boolean indicating if the current condition is met
  67974. * @returns the validity of the state
  67975. */
  67976. isValid(): boolean;
  67977. /**
  67978. * Serialize the StateCondition into a JSON compatible object
  67979. * @returns serialization object
  67980. */
  67981. serialize(): any;
  67982. }
  67983. }
  67984. declare module BABYLON {
  67985. /**
  67986. * This defines an action responsible to toggle a boolean once triggered.
  67987. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  67988. */
  67989. export class SwitchBooleanAction extends Action {
  67990. /**
  67991. * The path to the boolean property in the target object
  67992. */
  67993. propertyPath: string;
  67994. private _target;
  67995. private _effectiveTarget;
  67996. private _property;
  67997. /**
  67998. * Instantiate the action
  67999. * @param triggerOptions defines the trigger options
  68000. * @param target defines the object containing the boolean
  68001. * @param propertyPath defines the path to the boolean property in the target object
  68002. * @param condition defines the trigger related conditions
  68003. */
  68004. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  68005. /** @hidden */
  68006. _prepare(): void;
  68007. /**
  68008. * Execute the action toggle the boolean value.
  68009. */
  68010. execute(): void;
  68011. /**
  68012. * Serializes the actions and its related information.
  68013. * @param parent defines the object to serialize in
  68014. * @returns the serialized object
  68015. */
  68016. serialize(parent: any): any;
  68017. }
  68018. /**
  68019. * This defines an action responsible to set a the state field of the target
  68020. * to a desired value once triggered.
  68021. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  68022. */
  68023. export class SetStateAction extends Action {
  68024. /**
  68025. * The value to store in the state field.
  68026. */
  68027. value: string;
  68028. private _target;
  68029. /**
  68030. * Instantiate the action
  68031. * @param triggerOptions defines the trigger options
  68032. * @param target defines the object containing the state property
  68033. * @param value defines the value to store in the state field
  68034. * @param condition defines the trigger related conditions
  68035. */
  68036. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  68037. /**
  68038. * Execute the action and store the value on the target state property.
  68039. */
  68040. execute(): void;
  68041. /**
  68042. * Serializes the actions and its related information.
  68043. * @param parent defines the object to serialize in
  68044. * @returns the serialized object
  68045. */
  68046. serialize(parent: any): any;
  68047. }
  68048. /**
  68049. * This defines an action responsible to set a property of the target
  68050. * to a desired value once triggered.
  68051. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  68052. */
  68053. export class SetValueAction extends Action {
  68054. /**
  68055. * The path of the property to set in the target.
  68056. */
  68057. propertyPath: string;
  68058. /**
  68059. * The value to set in the property
  68060. */
  68061. value: any;
  68062. private _target;
  68063. private _effectiveTarget;
  68064. private _property;
  68065. /**
  68066. * Instantiate the action
  68067. * @param triggerOptions defines the trigger options
  68068. * @param target defines the object containing the property
  68069. * @param propertyPath defines the path of the property to set in the target
  68070. * @param value defines the value to set in the property
  68071. * @param condition defines the trigger related conditions
  68072. */
  68073. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  68074. /** @hidden */
  68075. _prepare(): void;
  68076. /**
  68077. * Execute the action and set the targetted property to the desired value.
  68078. */
  68079. execute(): void;
  68080. /**
  68081. * Serializes the actions and its related information.
  68082. * @param parent defines the object to serialize in
  68083. * @returns the serialized object
  68084. */
  68085. serialize(parent: any): any;
  68086. }
  68087. /**
  68088. * This defines an action responsible to increment the target value
  68089. * to a desired value once triggered.
  68090. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  68091. */
  68092. export class IncrementValueAction extends Action {
  68093. /**
  68094. * The path of the property to increment in the target.
  68095. */
  68096. propertyPath: string;
  68097. /**
  68098. * The value we should increment the property by.
  68099. */
  68100. value: any;
  68101. private _target;
  68102. private _effectiveTarget;
  68103. private _property;
  68104. /**
  68105. * Instantiate the action
  68106. * @param triggerOptions defines the trigger options
  68107. * @param target defines the object containing the property
  68108. * @param propertyPath defines the path of the property to increment in the target
  68109. * @param value defines the value value we should increment the property by
  68110. * @param condition defines the trigger related conditions
  68111. */
  68112. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  68113. /** @hidden */
  68114. _prepare(): void;
  68115. /**
  68116. * Execute the action and increment the target of the value amount.
  68117. */
  68118. execute(): void;
  68119. /**
  68120. * Serializes the actions and its related information.
  68121. * @param parent defines the object to serialize in
  68122. * @returns the serialized object
  68123. */
  68124. serialize(parent: any): any;
  68125. }
  68126. /**
  68127. * This defines an action responsible to start an animation once triggered.
  68128. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  68129. */
  68130. export class PlayAnimationAction extends Action {
  68131. /**
  68132. * Where the animation should start (animation frame)
  68133. */
  68134. from: number;
  68135. /**
  68136. * Where the animation should stop (animation frame)
  68137. */
  68138. to: number;
  68139. /**
  68140. * Define if the animation should loop or stop after the first play.
  68141. */
  68142. loop?: boolean;
  68143. private _target;
  68144. /**
  68145. * Instantiate the action
  68146. * @param triggerOptions defines the trigger options
  68147. * @param target defines the target animation or animation name
  68148. * @param from defines from where the animation should start (animation frame)
  68149. * @param end defines where the animation should stop (animation frame)
  68150. * @param loop defines if the animation should loop or stop after the first play
  68151. * @param condition defines the trigger related conditions
  68152. */
  68153. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  68154. /** @hidden */
  68155. _prepare(): void;
  68156. /**
  68157. * Execute the action and play the animation.
  68158. */
  68159. execute(): void;
  68160. /**
  68161. * Serializes the actions and its related information.
  68162. * @param parent defines the object to serialize in
  68163. * @returns the serialized object
  68164. */
  68165. serialize(parent: any): any;
  68166. }
  68167. /**
  68168. * This defines an action responsible to stop an animation once triggered.
  68169. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  68170. */
  68171. export class StopAnimationAction extends Action {
  68172. private _target;
  68173. /**
  68174. * Instantiate the action
  68175. * @param triggerOptions defines the trigger options
  68176. * @param target defines the target animation or animation name
  68177. * @param condition defines the trigger related conditions
  68178. */
  68179. constructor(triggerOptions: any, target: any, condition?: Condition);
  68180. /** @hidden */
  68181. _prepare(): void;
  68182. /**
  68183. * Execute the action and stop the animation.
  68184. */
  68185. execute(): void;
  68186. /**
  68187. * Serializes the actions and its related information.
  68188. * @param parent defines the object to serialize in
  68189. * @returns the serialized object
  68190. */
  68191. serialize(parent: any): any;
  68192. }
  68193. /**
  68194. * This defines an action responsible that does nothing once triggered.
  68195. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  68196. */
  68197. export class DoNothingAction extends Action {
  68198. /**
  68199. * Instantiate the action
  68200. * @param triggerOptions defines the trigger options
  68201. * @param condition defines the trigger related conditions
  68202. */
  68203. constructor(triggerOptions?: any, condition?: Condition);
  68204. /**
  68205. * Execute the action and do nothing.
  68206. */
  68207. execute(): void;
  68208. /**
  68209. * Serializes the actions and its related information.
  68210. * @param parent defines the object to serialize in
  68211. * @returns the serialized object
  68212. */
  68213. serialize(parent: any): any;
  68214. }
  68215. /**
  68216. * This defines an action responsible to trigger several actions once triggered.
  68217. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  68218. */
  68219. export class CombineAction extends Action {
  68220. /**
  68221. * The list of aggregated animations to run.
  68222. */
  68223. children: Action[];
  68224. /**
  68225. * Instantiate the action
  68226. * @param triggerOptions defines the trigger options
  68227. * @param children defines the list of aggregated animations to run
  68228. * @param condition defines the trigger related conditions
  68229. */
  68230. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  68231. /** @hidden */
  68232. _prepare(): void;
  68233. /**
  68234. * Execute the action and executes all the aggregated actions.
  68235. */
  68236. execute(evt: ActionEvent): void;
  68237. /**
  68238. * Serializes the actions and its related information.
  68239. * @param parent defines the object to serialize in
  68240. * @returns the serialized object
  68241. */
  68242. serialize(parent: any): any;
  68243. }
  68244. /**
  68245. * This defines an action responsible to run code (external event) once triggered.
  68246. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  68247. */
  68248. export class ExecuteCodeAction extends Action {
  68249. /**
  68250. * The callback function to run.
  68251. */
  68252. func: (evt: ActionEvent) => void;
  68253. /**
  68254. * Instantiate the action
  68255. * @param triggerOptions defines the trigger options
  68256. * @param func defines the callback function to run
  68257. * @param condition defines the trigger related conditions
  68258. */
  68259. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  68260. /**
  68261. * Execute the action and run the attached code.
  68262. */
  68263. execute(evt: ActionEvent): void;
  68264. }
  68265. /**
  68266. * This defines an action responsible to set the parent property of the target once triggered.
  68267. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  68268. */
  68269. export class SetParentAction extends Action {
  68270. private _parent;
  68271. private _target;
  68272. /**
  68273. * Instantiate the action
  68274. * @param triggerOptions defines the trigger options
  68275. * @param target defines the target containing the parent property
  68276. * @param parent defines from where the animation should start (animation frame)
  68277. * @param condition defines the trigger related conditions
  68278. */
  68279. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  68280. /** @hidden */
  68281. _prepare(): void;
  68282. /**
  68283. * Execute the action and set the parent property.
  68284. */
  68285. execute(): void;
  68286. /**
  68287. * Serializes the actions and its related information.
  68288. * @param parent defines the object to serialize in
  68289. * @returns the serialized object
  68290. */
  68291. serialize(parent: any): any;
  68292. }
  68293. }
  68294. declare module BABYLON {
  68295. /**
  68296. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  68297. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  68298. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  68299. */
  68300. export class ActionManager extends AbstractActionManager {
  68301. /**
  68302. * Nothing
  68303. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68304. */
  68305. static readonly NothingTrigger: number;
  68306. /**
  68307. * On pick
  68308. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68309. */
  68310. static readonly OnPickTrigger: number;
  68311. /**
  68312. * On left pick
  68313. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68314. */
  68315. static readonly OnLeftPickTrigger: number;
  68316. /**
  68317. * On right pick
  68318. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68319. */
  68320. static readonly OnRightPickTrigger: number;
  68321. /**
  68322. * On center pick
  68323. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68324. */
  68325. static readonly OnCenterPickTrigger: number;
  68326. /**
  68327. * On pick down
  68328. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68329. */
  68330. static readonly OnPickDownTrigger: number;
  68331. /**
  68332. * On double pick
  68333. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68334. */
  68335. static readonly OnDoublePickTrigger: number;
  68336. /**
  68337. * On pick up
  68338. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68339. */
  68340. static readonly OnPickUpTrigger: number;
  68341. /**
  68342. * On pick out.
  68343. * This trigger will only be raised if you also declared a OnPickDown
  68344. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68345. */
  68346. static readonly OnPickOutTrigger: number;
  68347. /**
  68348. * On long press
  68349. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68350. */
  68351. static readonly OnLongPressTrigger: number;
  68352. /**
  68353. * On pointer over
  68354. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68355. */
  68356. static readonly OnPointerOverTrigger: number;
  68357. /**
  68358. * On pointer out
  68359. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68360. */
  68361. static readonly OnPointerOutTrigger: number;
  68362. /**
  68363. * On every frame
  68364. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68365. */
  68366. static readonly OnEveryFrameTrigger: number;
  68367. /**
  68368. * On intersection enter
  68369. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68370. */
  68371. static readonly OnIntersectionEnterTrigger: number;
  68372. /**
  68373. * On intersection exit
  68374. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68375. */
  68376. static readonly OnIntersectionExitTrigger: number;
  68377. /**
  68378. * On key down
  68379. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68380. */
  68381. static readonly OnKeyDownTrigger: number;
  68382. /**
  68383. * On key up
  68384. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68385. */
  68386. static readonly OnKeyUpTrigger: number;
  68387. private _scene;
  68388. /**
  68389. * Creates a new action manager
  68390. * @param scene defines the hosting scene
  68391. */
  68392. constructor(scene: Scene);
  68393. /**
  68394. * Releases all associated resources
  68395. */
  68396. dispose(): void;
  68397. /**
  68398. * Gets hosting scene
  68399. * @returns the hosting scene
  68400. */
  68401. getScene(): Scene;
  68402. /**
  68403. * Does this action manager handles actions of any of the given triggers
  68404. * @param triggers defines the triggers to be tested
  68405. * @return a boolean indicating whether one (or more) of the triggers is handled
  68406. */
  68407. hasSpecificTriggers(triggers: number[]): boolean;
  68408. /**
  68409. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  68410. * speed.
  68411. * @param triggerA defines the trigger to be tested
  68412. * @param triggerB defines the trigger to be tested
  68413. * @return a boolean indicating whether one (or more) of the triggers is handled
  68414. */
  68415. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  68416. /**
  68417. * Does this action manager handles actions of a given trigger
  68418. * @param trigger defines the trigger to be tested
  68419. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  68420. * @return whether the trigger is handled
  68421. */
  68422. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  68423. /**
  68424. * Does this action manager has pointer triggers
  68425. */
  68426. readonly hasPointerTriggers: boolean;
  68427. /**
  68428. * Does this action manager has pick triggers
  68429. */
  68430. readonly hasPickTriggers: boolean;
  68431. /**
  68432. * Registers an action to this action manager
  68433. * @param action defines the action to be registered
  68434. * @return the action amended (prepared) after registration
  68435. */
  68436. registerAction(action: IAction): Nullable<IAction>;
  68437. /**
  68438. * Unregisters an action to this action manager
  68439. * @param action defines the action to be unregistered
  68440. * @return a boolean indicating whether the action has been unregistered
  68441. */
  68442. unregisterAction(action: IAction): Boolean;
  68443. /**
  68444. * Process a specific trigger
  68445. * @param trigger defines the trigger to process
  68446. * @param evt defines the event details to be processed
  68447. */
  68448. processTrigger(trigger: number, evt?: IActionEvent): void;
  68449. /** @hidden */
  68450. _getEffectiveTarget(target: any, propertyPath: string): any;
  68451. /** @hidden */
  68452. _getProperty(propertyPath: string): string;
  68453. /**
  68454. * Serialize this manager to a JSON object
  68455. * @param name defines the property name to store this manager
  68456. * @returns a JSON representation of this manager
  68457. */
  68458. serialize(name: string): any;
  68459. /**
  68460. * Creates a new ActionManager from a JSON data
  68461. * @param parsedActions defines the JSON data to read from
  68462. * @param object defines the hosting mesh
  68463. * @param scene defines the hosting scene
  68464. */
  68465. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  68466. /**
  68467. * Get a trigger name by index
  68468. * @param trigger defines the trigger index
  68469. * @returns a trigger name
  68470. */
  68471. static GetTriggerName(trigger: number): string;
  68472. }
  68473. }
  68474. declare module BABYLON {
  68475. /**
  68476. * Class representing a ray with position and direction
  68477. */
  68478. export class Ray {
  68479. /** origin point */
  68480. origin: Vector3;
  68481. /** direction */
  68482. direction: Vector3;
  68483. /** length of the ray */
  68484. length: number;
  68485. private static readonly TmpVector3;
  68486. private _tmpRay;
  68487. /**
  68488. * Creates a new ray
  68489. * @param origin origin point
  68490. * @param direction direction
  68491. * @param length length of the ray
  68492. */
  68493. constructor(
  68494. /** origin point */
  68495. origin: Vector3,
  68496. /** direction */
  68497. direction: Vector3,
  68498. /** length of the ray */
  68499. length?: number);
  68500. /**
  68501. * Checks if the ray intersects a box
  68502. * @param minimum bound of the box
  68503. * @param maximum bound of the box
  68504. * @param intersectionTreshold extra extend to be added to the box in all direction
  68505. * @returns if the box was hit
  68506. */
  68507. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  68508. /**
  68509. * Checks if the ray intersects a box
  68510. * @param box the bounding box to check
  68511. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  68512. * @returns if the box was hit
  68513. */
  68514. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  68515. /**
  68516. * If the ray hits a sphere
  68517. * @param sphere the bounding sphere to check
  68518. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  68519. * @returns true if it hits the sphere
  68520. */
  68521. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  68522. /**
  68523. * If the ray hits a triange
  68524. * @param vertex0 triangle vertex
  68525. * @param vertex1 triangle vertex
  68526. * @param vertex2 triangle vertex
  68527. * @returns intersection information if hit
  68528. */
  68529. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  68530. /**
  68531. * Checks if ray intersects a plane
  68532. * @param plane the plane to check
  68533. * @returns the distance away it was hit
  68534. */
  68535. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  68536. /**
  68537. * Checks if ray intersects a mesh
  68538. * @param mesh the mesh to check
  68539. * @param fastCheck if only the bounding box should checked
  68540. * @returns picking info of the intersecton
  68541. */
  68542. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  68543. /**
  68544. * Checks if ray intersects a mesh
  68545. * @param meshes the meshes to check
  68546. * @param fastCheck if only the bounding box should checked
  68547. * @param results array to store result in
  68548. * @returns Array of picking infos
  68549. */
  68550. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  68551. private _comparePickingInfo;
  68552. private static smallnum;
  68553. private static rayl;
  68554. /**
  68555. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  68556. * @param sega the first point of the segment to test the intersection against
  68557. * @param segb the second point of the segment to test the intersection against
  68558. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  68559. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  68560. */
  68561. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  68562. /**
  68563. * Update the ray from viewport position
  68564. * @param x position
  68565. * @param y y position
  68566. * @param viewportWidth viewport width
  68567. * @param viewportHeight viewport height
  68568. * @param world world matrix
  68569. * @param view view matrix
  68570. * @param projection projection matrix
  68571. * @returns this ray updated
  68572. */
  68573. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  68574. /**
  68575. * Creates a ray with origin and direction of 0,0,0
  68576. * @returns the new ray
  68577. */
  68578. static Zero(): Ray;
  68579. /**
  68580. * Creates a new ray from screen space and viewport
  68581. * @param x position
  68582. * @param y y position
  68583. * @param viewportWidth viewport width
  68584. * @param viewportHeight viewport height
  68585. * @param world world matrix
  68586. * @param view view matrix
  68587. * @param projection projection matrix
  68588. * @returns new ray
  68589. */
  68590. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  68591. /**
  68592. * 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
  68593. * transformed to the given world matrix.
  68594. * @param origin The origin point
  68595. * @param end The end point
  68596. * @param world a matrix to transform the ray to. Default is the identity matrix.
  68597. * @returns the new ray
  68598. */
  68599. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  68600. /**
  68601. * Transforms a ray by a matrix
  68602. * @param ray ray to transform
  68603. * @param matrix matrix to apply
  68604. * @returns the resulting new ray
  68605. */
  68606. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  68607. /**
  68608. * Transforms a ray by a matrix
  68609. * @param ray ray to transform
  68610. * @param matrix matrix to apply
  68611. * @param result ray to store result in
  68612. */
  68613. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  68614. /**
  68615. * Unproject a ray from screen space to object space
  68616. * @param sourceX defines the screen space x coordinate to use
  68617. * @param sourceY defines the screen space y coordinate to use
  68618. * @param viewportWidth defines the current width of the viewport
  68619. * @param viewportHeight defines the current height of the viewport
  68620. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  68621. * @param view defines the view matrix to use
  68622. * @param projection defines the projection matrix to use
  68623. */
  68624. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  68625. }
  68626. /**
  68627. * Type used to define predicate used to select faces when a mesh intersection is detected
  68628. */
  68629. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  68630. interface Scene {
  68631. /** @hidden */
  68632. _tempPickingRay: Nullable<Ray>;
  68633. /** @hidden */
  68634. _cachedRayForTransform: Ray;
  68635. /** @hidden */
  68636. _pickWithRayInverseMatrix: Matrix;
  68637. /** @hidden */
  68638. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  68639. /** @hidden */
  68640. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  68641. }
  68642. }
  68643. declare module BABYLON {
  68644. /**
  68645. * Groups all the scene component constants in one place to ease maintenance.
  68646. * @hidden
  68647. */
  68648. export class SceneComponentConstants {
  68649. static readonly NAME_EFFECTLAYER: string;
  68650. static readonly NAME_LAYER: string;
  68651. static readonly NAME_LENSFLARESYSTEM: string;
  68652. static readonly NAME_BOUNDINGBOXRENDERER: string;
  68653. static readonly NAME_PARTICLESYSTEM: string;
  68654. static readonly NAME_GAMEPAD: string;
  68655. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  68656. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  68657. static readonly NAME_DEPTHRENDERER: string;
  68658. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  68659. static readonly NAME_SPRITE: string;
  68660. static readonly NAME_OUTLINERENDERER: string;
  68661. static readonly NAME_PROCEDURALTEXTURE: string;
  68662. static readonly NAME_SHADOWGENERATOR: string;
  68663. static readonly NAME_OCTREE: string;
  68664. static readonly NAME_PHYSICSENGINE: string;
  68665. static readonly NAME_AUDIO: string;
  68666. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  68667. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  68668. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  68669. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  68670. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  68671. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  68672. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  68673. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  68674. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  68675. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  68676. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  68677. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  68678. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  68679. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  68680. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  68681. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  68682. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  68683. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  68684. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  68685. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  68686. static readonly STEP_AFTERRENDER_AUDIO: number;
  68687. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  68688. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  68689. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  68690. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  68691. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  68692. static readonly STEP_POINTERMOVE_SPRITE: number;
  68693. static readonly STEP_POINTERDOWN_SPRITE: number;
  68694. static readonly STEP_POINTERUP_SPRITE: number;
  68695. }
  68696. /**
  68697. * This represents a scene component.
  68698. *
  68699. * This is used to decouple the dependency the scene is having on the different workloads like
  68700. * layers, post processes...
  68701. */
  68702. export interface ISceneComponent {
  68703. /**
  68704. * The name of the component. Each component must have a unique name.
  68705. */
  68706. name: string;
  68707. /**
  68708. * The scene the component belongs to.
  68709. */
  68710. scene: Scene;
  68711. /**
  68712. * Register the component to one instance of a scene.
  68713. */
  68714. register(): void;
  68715. /**
  68716. * Rebuilds the elements related to this component in case of
  68717. * context lost for instance.
  68718. */
  68719. rebuild(): void;
  68720. /**
  68721. * Disposes the component and the associated ressources.
  68722. */
  68723. dispose(): void;
  68724. }
  68725. /**
  68726. * This represents a SERIALIZABLE scene component.
  68727. *
  68728. * This extends Scene Component to add Serialization methods on top.
  68729. */
  68730. export interface ISceneSerializableComponent extends ISceneComponent {
  68731. /**
  68732. * Adds all the element from the container to the scene
  68733. * @param container the container holding the elements
  68734. */
  68735. addFromContainer(container: AbstractScene): void;
  68736. /**
  68737. * Removes all the elements in the container from the scene
  68738. * @param container contains the elements to remove
  68739. */
  68740. removeFromContainer(container: AbstractScene): void;
  68741. /**
  68742. * Serializes the component data to the specified json object
  68743. * @param serializationObject The object to serialize to
  68744. */
  68745. serialize(serializationObject: any): void;
  68746. }
  68747. /**
  68748. * Strong typing of a Mesh related stage step action
  68749. */
  68750. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  68751. /**
  68752. * Strong typing of a Evaluate Sub Mesh related stage step action
  68753. */
  68754. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  68755. /**
  68756. * Strong typing of a Active Mesh related stage step action
  68757. */
  68758. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  68759. /**
  68760. * Strong typing of a Camera related stage step action
  68761. */
  68762. export type CameraStageAction = (camera: Camera) => void;
  68763. /**
  68764. * Strong typing of a Render Target related stage step action
  68765. */
  68766. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  68767. /**
  68768. * Strong typing of a RenderingGroup related stage step action
  68769. */
  68770. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  68771. /**
  68772. * Strong typing of a Mesh Render related stage step action
  68773. */
  68774. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  68775. /**
  68776. * Strong typing of a simple stage step action
  68777. */
  68778. export type SimpleStageAction = () => void;
  68779. /**
  68780. * Strong typing of a render target action.
  68781. */
  68782. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  68783. /**
  68784. * Strong typing of a pointer move action.
  68785. */
  68786. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  68787. /**
  68788. * Strong typing of a pointer up/down action.
  68789. */
  68790. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  68791. /**
  68792. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  68793. * @hidden
  68794. */
  68795. export class Stage<T extends Function> extends Array<{
  68796. index: number;
  68797. component: ISceneComponent;
  68798. action: T;
  68799. }> {
  68800. /**
  68801. * Hide ctor from the rest of the world.
  68802. * @param items The items to add.
  68803. */
  68804. private constructor();
  68805. /**
  68806. * Creates a new Stage.
  68807. * @returns A new instance of a Stage
  68808. */
  68809. static Create<T extends Function>(): Stage<T>;
  68810. /**
  68811. * Registers a step in an ordered way in the targeted stage.
  68812. * @param index Defines the position to register the step in
  68813. * @param component Defines the component attached to the step
  68814. * @param action Defines the action to launch during the step
  68815. */
  68816. registerStep(index: number, component: ISceneComponent, action: T): void;
  68817. /**
  68818. * Clears all the steps from the stage.
  68819. */
  68820. clear(): void;
  68821. }
  68822. }
  68823. declare module BABYLON {
  68824. interface Scene {
  68825. /** @hidden */
  68826. _pointerOverSprite: Nullable<Sprite>;
  68827. /** @hidden */
  68828. _pickedDownSprite: Nullable<Sprite>;
  68829. /** @hidden */
  68830. _tempSpritePickingRay: Nullable<Ray>;
  68831. /**
  68832. * All of the sprite managers added to this scene
  68833. * @see http://doc.babylonjs.com/babylon101/sprites
  68834. */
  68835. spriteManagers: Array<ISpriteManager>;
  68836. /**
  68837. * An event triggered when sprites rendering is about to start
  68838. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  68839. */
  68840. onBeforeSpritesRenderingObservable: Observable<Scene>;
  68841. /**
  68842. * An event triggered when sprites rendering is done
  68843. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  68844. */
  68845. onAfterSpritesRenderingObservable: Observable<Scene>;
  68846. /** @hidden */
  68847. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  68848. /** Launch a ray to try to pick a sprite in the scene
  68849. * @param x position on screen
  68850. * @param y position on screen
  68851. * @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
  68852. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  68853. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  68854. * @returns a PickingInfo
  68855. */
  68856. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  68857. /** Use the given ray to pick a sprite in the scene
  68858. * @param ray The ray (in world space) to use to pick meshes
  68859. * @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
  68860. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  68861. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  68862. * @returns a PickingInfo
  68863. */
  68864. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  68865. /**
  68866. * Force the sprite under the pointer
  68867. * @param sprite defines the sprite to use
  68868. */
  68869. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  68870. /**
  68871. * Gets the sprite under the pointer
  68872. * @returns a Sprite or null if no sprite is under the pointer
  68873. */
  68874. getPointerOverSprite(): Nullable<Sprite>;
  68875. }
  68876. /**
  68877. * Defines the sprite scene component responsible to manage sprites
  68878. * in a given scene.
  68879. */
  68880. export class SpriteSceneComponent implements ISceneComponent {
  68881. /**
  68882. * The component name helpfull to identify the component in the list of scene components.
  68883. */
  68884. readonly name: string;
  68885. /**
  68886. * The scene the component belongs to.
  68887. */
  68888. scene: Scene;
  68889. /** @hidden */
  68890. private _spritePredicate;
  68891. /**
  68892. * Creates a new instance of the component for the given scene
  68893. * @param scene Defines the scene to register the component in
  68894. */
  68895. constructor(scene: Scene);
  68896. /**
  68897. * Registers the component in a given scene
  68898. */
  68899. register(): void;
  68900. /**
  68901. * Rebuilds the elements related to this component in case of
  68902. * context lost for instance.
  68903. */
  68904. rebuild(): void;
  68905. /**
  68906. * Disposes the component and the associated ressources.
  68907. */
  68908. dispose(): void;
  68909. private _pickSpriteButKeepRay;
  68910. private _pointerMove;
  68911. private _pointerDown;
  68912. private _pointerUp;
  68913. }
  68914. }
  68915. declare module BABYLON {
  68916. /** @hidden */
  68917. export var fogFragmentDeclaration: {
  68918. name: string;
  68919. shader: string;
  68920. };
  68921. }
  68922. declare module BABYLON {
  68923. /** @hidden */
  68924. export var fogFragment: {
  68925. name: string;
  68926. shader: string;
  68927. };
  68928. }
  68929. declare module BABYLON {
  68930. /** @hidden */
  68931. export var spritesPixelShader: {
  68932. name: string;
  68933. shader: string;
  68934. };
  68935. }
  68936. declare module BABYLON {
  68937. /** @hidden */
  68938. export var fogVertexDeclaration: {
  68939. name: string;
  68940. shader: string;
  68941. };
  68942. }
  68943. declare module BABYLON {
  68944. /** @hidden */
  68945. export var spritesVertexShader: {
  68946. name: string;
  68947. shader: string;
  68948. };
  68949. }
  68950. declare module BABYLON {
  68951. /**
  68952. * Defines the minimum interface to fullfil in order to be a sprite manager.
  68953. */
  68954. export interface ISpriteManager extends IDisposable {
  68955. /**
  68956. * Restricts the camera to viewing objects with the same layerMask.
  68957. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  68958. */
  68959. layerMask: number;
  68960. /**
  68961. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  68962. */
  68963. isPickable: boolean;
  68964. /**
  68965. * Specifies the rendering group id for this mesh (0 by default)
  68966. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  68967. */
  68968. renderingGroupId: number;
  68969. /**
  68970. * Defines the list of sprites managed by the manager.
  68971. */
  68972. sprites: Array<Sprite>;
  68973. /**
  68974. * Tests the intersection of a sprite with a specific ray.
  68975. * @param ray The ray we are sending to test the collision
  68976. * @param camera The camera space we are sending rays in
  68977. * @param predicate A predicate allowing excluding sprites from the list of object to test
  68978. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  68979. * @returns picking info or null.
  68980. */
  68981. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  68982. /**
  68983. * Renders the list of sprites on screen.
  68984. */
  68985. render(): void;
  68986. }
  68987. /**
  68988. * Class used to manage multiple sprites on the same spritesheet
  68989. * @see http://doc.babylonjs.com/babylon101/sprites
  68990. */
  68991. export class SpriteManager implements ISpriteManager {
  68992. /** defines the manager's name */
  68993. name: string;
  68994. /** Gets the list of sprites */
  68995. sprites: Sprite[];
  68996. /** Gets or sets the rendering group id (0 by default) */
  68997. renderingGroupId: number;
  68998. /** Gets or sets camera layer mask */
  68999. layerMask: number;
  69000. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  69001. fogEnabled: boolean;
  69002. /** Gets or sets a boolean indicating if the sprites are pickable */
  69003. isPickable: boolean;
  69004. /** Defines the default width of a cell in the spritesheet */
  69005. cellWidth: number;
  69006. /** Defines the default height of a cell in the spritesheet */
  69007. cellHeight: number;
  69008. /**
  69009. * An event triggered when the manager is disposed.
  69010. */
  69011. onDisposeObservable: Observable<SpriteManager>;
  69012. private _onDisposeObserver;
  69013. /**
  69014. * Callback called when the manager is disposed
  69015. */
  69016. onDispose: () => void;
  69017. private _capacity;
  69018. private _spriteTexture;
  69019. private _epsilon;
  69020. private _scene;
  69021. private _vertexData;
  69022. private _buffer;
  69023. private _vertexBuffers;
  69024. private _indexBuffer;
  69025. private _effectBase;
  69026. private _effectFog;
  69027. /**
  69028. * Gets or sets the spritesheet texture
  69029. */
  69030. texture: Texture;
  69031. /**
  69032. * Creates a new sprite manager
  69033. * @param name defines the manager's name
  69034. * @param imgUrl defines the sprite sheet url
  69035. * @param capacity defines the maximum allowed number of sprites
  69036. * @param cellSize defines the size of a sprite cell
  69037. * @param scene defines the hosting scene
  69038. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  69039. * @param samplingMode defines the smapling mode to use with spritesheet
  69040. */
  69041. constructor(
  69042. /** defines the manager's name */
  69043. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  69044. private _appendSpriteVertex;
  69045. /**
  69046. * Intersects the sprites with a ray
  69047. * @param ray defines the ray to intersect with
  69048. * @param camera defines the current active camera
  69049. * @param predicate defines a predicate used to select candidate sprites
  69050. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  69051. * @returns null if no hit or a PickingInfo
  69052. */
  69053. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  69054. /**
  69055. * Render all child sprites
  69056. */
  69057. render(): void;
  69058. /**
  69059. * Release associated resources
  69060. */
  69061. dispose(): void;
  69062. }
  69063. }
  69064. declare module BABYLON {
  69065. /**
  69066. * Class used to represent a sprite
  69067. * @see http://doc.babylonjs.com/babylon101/sprites
  69068. */
  69069. export class Sprite {
  69070. /** defines the name */
  69071. name: string;
  69072. /** Gets or sets the current world position */
  69073. position: Vector3;
  69074. /** Gets or sets the main color */
  69075. color: Color4;
  69076. /** Gets or sets the width */
  69077. width: number;
  69078. /** Gets or sets the height */
  69079. height: number;
  69080. /** Gets or sets rotation angle */
  69081. angle: number;
  69082. /** Gets or sets the cell index in the sprite sheet */
  69083. cellIndex: number;
  69084. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  69085. invertU: number;
  69086. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  69087. invertV: number;
  69088. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  69089. disposeWhenFinishedAnimating: boolean;
  69090. /** Gets the list of attached animations */
  69091. animations: Animation[];
  69092. /** Gets or sets a boolean indicating if the sprite can be picked */
  69093. isPickable: boolean;
  69094. /**
  69095. * Gets or sets the associated action manager
  69096. */
  69097. actionManager: Nullable<ActionManager>;
  69098. private _animationStarted;
  69099. private _loopAnimation;
  69100. private _fromIndex;
  69101. private _toIndex;
  69102. private _delay;
  69103. private _direction;
  69104. private _manager;
  69105. private _time;
  69106. private _onAnimationEnd;
  69107. /**
  69108. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  69109. */
  69110. isVisible: boolean;
  69111. /**
  69112. * Gets or sets the sprite size
  69113. */
  69114. size: number;
  69115. /**
  69116. * Creates a new Sprite
  69117. * @param name defines the name
  69118. * @param manager defines the manager
  69119. */
  69120. constructor(
  69121. /** defines the name */
  69122. name: string, manager: ISpriteManager);
  69123. /**
  69124. * Starts an animation
  69125. * @param from defines the initial key
  69126. * @param to defines the end key
  69127. * @param loop defines if the animation must loop
  69128. * @param delay defines the start delay (in ms)
  69129. * @param onAnimationEnd defines a callback to call when animation ends
  69130. */
  69131. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  69132. /** Stops current animation (if any) */
  69133. stopAnimation(): void;
  69134. /** @hidden */
  69135. _animate(deltaTime: number): void;
  69136. /** Release associated resources */
  69137. dispose(): void;
  69138. }
  69139. }
  69140. declare module BABYLON {
  69141. /**
  69142. * Information about the result of picking within a scene
  69143. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  69144. */
  69145. export class PickingInfo {
  69146. /** @hidden */
  69147. _pickingUnavailable: boolean;
  69148. /**
  69149. * If the pick collided with an object
  69150. */
  69151. hit: boolean;
  69152. /**
  69153. * Distance away where the pick collided
  69154. */
  69155. distance: number;
  69156. /**
  69157. * The location of pick collision
  69158. */
  69159. pickedPoint: Nullable<Vector3>;
  69160. /**
  69161. * The mesh corresponding the the pick collision
  69162. */
  69163. pickedMesh: Nullable<AbstractMesh>;
  69164. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  69165. bu: number;
  69166. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  69167. bv: number;
  69168. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  69169. faceId: number;
  69170. /** Id of the the submesh that was picked */
  69171. subMeshId: number;
  69172. /** If a sprite was picked, this will be the sprite the pick collided with */
  69173. pickedSprite: Nullable<Sprite>;
  69174. /**
  69175. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  69176. */
  69177. originMesh: Nullable<AbstractMesh>;
  69178. /**
  69179. * The ray that was used to perform the picking.
  69180. */
  69181. ray: Nullable<Ray>;
  69182. /**
  69183. * Gets the normal correspodning to the face the pick collided with
  69184. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  69185. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  69186. * @returns The normal correspodning to the face the pick collided with
  69187. */
  69188. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  69189. /**
  69190. * Gets the texture coordinates of where the pick occured
  69191. * @returns the vector containing the coordnates of the texture
  69192. */
  69193. getTextureCoordinates(): Nullable<Vector2>;
  69194. }
  69195. }
  69196. declare module BABYLON {
  69197. /**
  69198. * Gather the list of pointer event types as constants.
  69199. */
  69200. export class PointerEventTypes {
  69201. /**
  69202. * 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.
  69203. */
  69204. static readonly POINTERDOWN: number;
  69205. /**
  69206. * The pointerup event is fired when a pointer is no longer active.
  69207. */
  69208. static readonly POINTERUP: number;
  69209. /**
  69210. * The pointermove event is fired when a pointer changes coordinates.
  69211. */
  69212. static readonly POINTERMOVE: number;
  69213. /**
  69214. * The pointerwheel event is fired when a mouse wheel has been rotated.
  69215. */
  69216. static readonly POINTERWHEEL: number;
  69217. /**
  69218. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  69219. */
  69220. static readonly POINTERPICK: number;
  69221. /**
  69222. * The pointertap event is fired when a the object has been touched and released without drag.
  69223. */
  69224. static readonly POINTERTAP: number;
  69225. /**
  69226. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  69227. */
  69228. static readonly POINTERDOUBLETAP: number;
  69229. }
  69230. /**
  69231. * Base class of pointer info types.
  69232. */
  69233. export class PointerInfoBase {
  69234. /**
  69235. * Defines the type of event (PointerEventTypes)
  69236. */
  69237. type: number;
  69238. /**
  69239. * Defines the related dom event
  69240. */
  69241. event: PointerEvent | MouseWheelEvent;
  69242. /**
  69243. * Instantiates the base class of pointers info.
  69244. * @param type Defines the type of event (PointerEventTypes)
  69245. * @param event Defines the related dom event
  69246. */
  69247. constructor(
  69248. /**
  69249. * Defines the type of event (PointerEventTypes)
  69250. */
  69251. type: number,
  69252. /**
  69253. * Defines the related dom event
  69254. */
  69255. event: PointerEvent | MouseWheelEvent);
  69256. }
  69257. /**
  69258. * This class is used to store pointer related info for the onPrePointerObservable event.
  69259. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  69260. */
  69261. export class PointerInfoPre extends PointerInfoBase {
  69262. /**
  69263. * Ray from a pointer if availible (eg. 6dof controller)
  69264. */
  69265. ray: Nullable<Ray>;
  69266. /**
  69267. * Defines the local position of the pointer on the canvas.
  69268. */
  69269. localPosition: Vector2;
  69270. /**
  69271. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  69272. */
  69273. skipOnPointerObservable: boolean;
  69274. /**
  69275. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  69276. * @param type Defines the type of event (PointerEventTypes)
  69277. * @param event Defines the related dom event
  69278. * @param localX Defines the local x coordinates of the pointer when the event occured
  69279. * @param localY Defines the local y coordinates of the pointer when the event occured
  69280. */
  69281. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  69282. }
  69283. /**
  69284. * This type contains all the data related to a pointer event in Babylon.js.
  69285. * 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.
  69286. */
  69287. export class PointerInfo extends PointerInfoBase {
  69288. /**
  69289. * Defines the picking info associated to the info (if any)\
  69290. */
  69291. pickInfo: Nullable<PickingInfo>;
  69292. /**
  69293. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  69294. * @param type Defines the type of event (PointerEventTypes)
  69295. * @param event Defines the related dom event
  69296. * @param pickInfo Defines the picking info associated to the info (if any)\
  69297. */
  69298. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  69299. /**
  69300. * Defines the picking info associated to the info (if any)\
  69301. */
  69302. pickInfo: Nullable<PickingInfo>);
  69303. }
  69304. /**
  69305. * Data relating to a touch event on the screen.
  69306. */
  69307. export interface PointerTouch {
  69308. /**
  69309. * X coordinate of touch.
  69310. */
  69311. x: number;
  69312. /**
  69313. * Y coordinate of touch.
  69314. */
  69315. y: number;
  69316. /**
  69317. * Id of touch. Unique for each finger.
  69318. */
  69319. pointerId: number;
  69320. /**
  69321. * Event type passed from DOM.
  69322. */
  69323. type: any;
  69324. }
  69325. }
  69326. declare module BABYLON {
  69327. /**
  69328. * Manage the mouse inputs to control the movement of a free camera.
  69329. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  69330. */
  69331. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  69332. /**
  69333. * Define if touch is enabled in the mouse input
  69334. */
  69335. touchEnabled: boolean;
  69336. /**
  69337. * Defines the camera the input is attached to.
  69338. */
  69339. camera: FreeCamera;
  69340. /**
  69341. * Defines the buttons associated with the input to handle camera move.
  69342. */
  69343. buttons: number[];
  69344. /**
  69345. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  69346. */
  69347. angularSensibility: number;
  69348. private _pointerInput;
  69349. private _onMouseMove;
  69350. private _observer;
  69351. private previousPosition;
  69352. /**
  69353. * Manage the mouse inputs to control the movement of a free camera.
  69354. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  69355. * @param touchEnabled Defines if touch is enabled or not
  69356. */
  69357. constructor(
  69358. /**
  69359. * Define if touch is enabled in the mouse input
  69360. */
  69361. touchEnabled?: boolean);
  69362. /**
  69363. * Attach the input controls to a specific dom element to get the input from.
  69364. * @param element Defines the element the controls should be listened from
  69365. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  69366. */
  69367. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  69368. /**
  69369. * Detach the current controls from the specified dom element.
  69370. * @param element Defines the element to stop listening the inputs from
  69371. */
  69372. detachControl(element: Nullable<HTMLElement>): void;
  69373. /**
  69374. * Gets the class name of the current intput.
  69375. * @returns the class name
  69376. */
  69377. getClassName(): string;
  69378. /**
  69379. * Get the friendly name associated with the input class.
  69380. * @returns the input friendly name
  69381. */
  69382. getSimpleName(): string;
  69383. }
  69384. }
  69385. declare module BABYLON {
  69386. /**
  69387. * Manage the touch inputs to control the movement of a free camera.
  69388. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  69389. */
  69390. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  69391. /**
  69392. * Defines the camera the input is attached to.
  69393. */
  69394. camera: FreeCamera;
  69395. /**
  69396. * Defines the touch sensibility for rotation.
  69397. * The higher the faster.
  69398. */
  69399. touchAngularSensibility: number;
  69400. /**
  69401. * Defines the touch sensibility for move.
  69402. * The higher the faster.
  69403. */
  69404. touchMoveSensibility: number;
  69405. private _offsetX;
  69406. private _offsetY;
  69407. private _pointerPressed;
  69408. private _pointerInput;
  69409. private _observer;
  69410. private _onLostFocus;
  69411. /**
  69412. * Attach the input controls to a specific dom element to get the input from.
  69413. * @param element Defines the element the controls should be listened from
  69414. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  69415. */
  69416. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  69417. /**
  69418. * Detach the current controls from the specified dom element.
  69419. * @param element Defines the element to stop listening the inputs from
  69420. */
  69421. detachControl(element: Nullable<HTMLElement>): void;
  69422. /**
  69423. * Update the current camera state depending on the inputs that have been used this frame.
  69424. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  69425. */
  69426. checkInputs(): void;
  69427. /**
  69428. * Gets the class name of the current intput.
  69429. * @returns the class name
  69430. */
  69431. getClassName(): string;
  69432. /**
  69433. * Get the friendly name associated with the input class.
  69434. * @returns the input friendly name
  69435. */
  69436. getSimpleName(): string;
  69437. }
  69438. }
  69439. declare module BABYLON {
  69440. /**
  69441. * Default Inputs manager for the FreeCamera.
  69442. * It groups all the default supported inputs for ease of use.
  69443. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  69444. */
  69445. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  69446. /**
  69447. * Instantiates a new FreeCameraInputsManager.
  69448. * @param camera Defines the camera the inputs belong to
  69449. */
  69450. constructor(camera: FreeCamera);
  69451. /**
  69452. * Add keyboard input support to the input manager.
  69453. * @returns the current input manager
  69454. */
  69455. addKeyboard(): FreeCameraInputsManager;
  69456. /**
  69457. * Add mouse input support to the input manager.
  69458. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  69459. * @returns the current input manager
  69460. */
  69461. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  69462. /**
  69463. * Add touch input support to the input manager.
  69464. * @returns the current input manager
  69465. */
  69466. addTouch(): FreeCameraInputsManager;
  69467. }
  69468. }
  69469. declare module BABYLON {
  69470. /**
  69471. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  69472. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  69473. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  69474. */
  69475. export class FreeCamera extends TargetCamera {
  69476. /**
  69477. * Define the collision ellipsoid of the camera.
  69478. * This is helpful to simulate a camera body like the player body around the camera
  69479. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  69480. */
  69481. ellipsoid: Vector3;
  69482. /**
  69483. * Define an offset for the position of the ellipsoid around the camera.
  69484. * This can be helpful to determine the center of the body near the gravity center of the body
  69485. * instead of its head.
  69486. */
  69487. ellipsoidOffset: Vector3;
  69488. /**
  69489. * Enable or disable collisions of the camera with the rest of the scene objects.
  69490. */
  69491. checkCollisions: boolean;
  69492. /**
  69493. * Enable or disable gravity on the camera.
  69494. */
  69495. applyGravity: boolean;
  69496. /**
  69497. * Define the input manager associated to the camera.
  69498. */
  69499. inputs: FreeCameraInputsManager;
  69500. /**
  69501. * Gets the input sensibility for a mouse input. (default is 2000.0)
  69502. * Higher values reduce sensitivity.
  69503. */
  69504. /**
  69505. * Sets the input sensibility for a mouse input. (default is 2000.0)
  69506. * Higher values reduce sensitivity.
  69507. */
  69508. angularSensibility: number;
  69509. /**
  69510. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  69511. */
  69512. keysUp: number[];
  69513. /**
  69514. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  69515. */
  69516. keysDown: number[];
  69517. /**
  69518. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  69519. */
  69520. keysLeft: number[];
  69521. /**
  69522. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  69523. */
  69524. keysRight: number[];
  69525. /**
  69526. * Event raised when the camera collide with a mesh in the scene.
  69527. */
  69528. onCollide: (collidedMesh: AbstractMesh) => void;
  69529. private _collider;
  69530. private _needMoveForGravity;
  69531. private _oldPosition;
  69532. private _diffPosition;
  69533. private _newPosition;
  69534. /** @hidden */
  69535. _localDirection: Vector3;
  69536. /** @hidden */
  69537. _transformedDirection: Vector3;
  69538. /**
  69539. * Instantiates a Free Camera.
  69540. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  69541. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  69542. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  69543. * @param name Define the name of the camera in the scene
  69544. * @param position Define the start position of the camera in the scene
  69545. * @param scene Define the scene the camera belongs to
  69546. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  69547. */
  69548. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  69549. /**
  69550. * Attached controls to the current camera.
  69551. * @param element Defines the element the controls should be listened from
  69552. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  69553. */
  69554. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  69555. /**
  69556. * Detach the current controls from the camera.
  69557. * The camera will stop reacting to inputs.
  69558. * @param element Defines the element to stop listening the inputs from
  69559. */
  69560. detachControl(element: HTMLElement): void;
  69561. private _collisionMask;
  69562. /**
  69563. * Define a collision mask to limit the list of object the camera can collide with
  69564. */
  69565. collisionMask: number;
  69566. /** @hidden */
  69567. _collideWithWorld(displacement: Vector3): void;
  69568. private _onCollisionPositionChange;
  69569. /** @hidden */
  69570. _checkInputs(): void;
  69571. /** @hidden */
  69572. _decideIfNeedsToMove(): boolean;
  69573. /** @hidden */
  69574. _updatePosition(): void;
  69575. /**
  69576. * Destroy the camera and release the current resources hold by it.
  69577. */
  69578. dispose(): void;
  69579. /**
  69580. * Gets the current object class name.
  69581. * @return the class name
  69582. */
  69583. getClassName(): string;
  69584. }
  69585. }
  69586. declare module BABYLON {
  69587. /**
  69588. * Represents a gamepad control stick position
  69589. */
  69590. export class StickValues {
  69591. /**
  69592. * The x component of the control stick
  69593. */
  69594. x: number;
  69595. /**
  69596. * The y component of the control stick
  69597. */
  69598. y: number;
  69599. /**
  69600. * Initializes the gamepad x and y control stick values
  69601. * @param x The x component of the gamepad control stick value
  69602. * @param y The y component of the gamepad control stick value
  69603. */
  69604. constructor(
  69605. /**
  69606. * The x component of the control stick
  69607. */
  69608. x: number,
  69609. /**
  69610. * The y component of the control stick
  69611. */
  69612. y: number);
  69613. }
  69614. /**
  69615. * An interface which manages callbacks for gamepad button changes
  69616. */
  69617. export interface GamepadButtonChanges {
  69618. /**
  69619. * Called when a gamepad has been changed
  69620. */
  69621. changed: boolean;
  69622. /**
  69623. * Called when a gamepad press event has been triggered
  69624. */
  69625. pressChanged: boolean;
  69626. /**
  69627. * Called when a touch event has been triggered
  69628. */
  69629. touchChanged: boolean;
  69630. /**
  69631. * Called when a value has changed
  69632. */
  69633. valueChanged: boolean;
  69634. }
  69635. /**
  69636. * Represents a gamepad
  69637. */
  69638. export class Gamepad {
  69639. /**
  69640. * The id of the gamepad
  69641. */
  69642. id: string;
  69643. /**
  69644. * The index of the gamepad
  69645. */
  69646. index: number;
  69647. /**
  69648. * The browser gamepad
  69649. */
  69650. browserGamepad: any;
  69651. /**
  69652. * Specifies what type of gamepad this represents
  69653. */
  69654. type: number;
  69655. private _leftStick;
  69656. private _rightStick;
  69657. /** @hidden */
  69658. _isConnected: boolean;
  69659. private _leftStickAxisX;
  69660. private _leftStickAxisY;
  69661. private _rightStickAxisX;
  69662. private _rightStickAxisY;
  69663. /**
  69664. * Triggered when the left control stick has been changed
  69665. */
  69666. private _onleftstickchanged;
  69667. /**
  69668. * Triggered when the right control stick has been changed
  69669. */
  69670. private _onrightstickchanged;
  69671. /**
  69672. * Represents a gamepad controller
  69673. */
  69674. static GAMEPAD: number;
  69675. /**
  69676. * Represents a generic controller
  69677. */
  69678. static GENERIC: number;
  69679. /**
  69680. * Represents an XBox controller
  69681. */
  69682. static XBOX: number;
  69683. /**
  69684. * Represents a pose-enabled controller
  69685. */
  69686. static POSE_ENABLED: number;
  69687. /**
  69688. * Specifies whether the left control stick should be Y-inverted
  69689. */
  69690. protected _invertLeftStickY: boolean;
  69691. /**
  69692. * Specifies if the gamepad has been connected
  69693. */
  69694. readonly isConnected: boolean;
  69695. /**
  69696. * Initializes the gamepad
  69697. * @param id The id of the gamepad
  69698. * @param index The index of the gamepad
  69699. * @param browserGamepad The browser gamepad
  69700. * @param leftStickX The x component of the left joystick
  69701. * @param leftStickY The y component of the left joystick
  69702. * @param rightStickX The x component of the right joystick
  69703. * @param rightStickY The y component of the right joystick
  69704. */
  69705. constructor(
  69706. /**
  69707. * The id of the gamepad
  69708. */
  69709. id: string,
  69710. /**
  69711. * The index of the gamepad
  69712. */
  69713. index: number,
  69714. /**
  69715. * The browser gamepad
  69716. */
  69717. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  69718. /**
  69719. * Callback triggered when the left joystick has changed
  69720. * @param callback
  69721. */
  69722. onleftstickchanged(callback: (values: StickValues) => void): void;
  69723. /**
  69724. * Callback triggered when the right joystick has changed
  69725. * @param callback
  69726. */
  69727. onrightstickchanged(callback: (values: StickValues) => void): void;
  69728. /**
  69729. * Gets the left joystick
  69730. */
  69731. /**
  69732. * Sets the left joystick values
  69733. */
  69734. leftStick: StickValues;
  69735. /**
  69736. * Gets the right joystick
  69737. */
  69738. /**
  69739. * Sets the right joystick value
  69740. */
  69741. rightStick: StickValues;
  69742. /**
  69743. * Updates the gamepad joystick positions
  69744. */
  69745. update(): void;
  69746. /**
  69747. * Disposes the gamepad
  69748. */
  69749. dispose(): void;
  69750. }
  69751. /**
  69752. * Represents a generic gamepad
  69753. */
  69754. export class GenericPad extends Gamepad {
  69755. private _buttons;
  69756. private _onbuttondown;
  69757. private _onbuttonup;
  69758. /**
  69759. * Observable triggered when a button has been pressed
  69760. */
  69761. onButtonDownObservable: Observable<number>;
  69762. /**
  69763. * Observable triggered when a button has been released
  69764. */
  69765. onButtonUpObservable: Observable<number>;
  69766. /**
  69767. * Callback triggered when a button has been pressed
  69768. * @param callback Called when a button has been pressed
  69769. */
  69770. onbuttondown(callback: (buttonPressed: number) => void): void;
  69771. /**
  69772. * Callback triggered when a button has been released
  69773. * @param callback Called when a button has been released
  69774. */
  69775. onbuttonup(callback: (buttonReleased: number) => void): void;
  69776. /**
  69777. * Initializes the generic gamepad
  69778. * @param id The id of the generic gamepad
  69779. * @param index The index of the generic gamepad
  69780. * @param browserGamepad The browser gamepad
  69781. */
  69782. constructor(id: string, index: number, browserGamepad: any);
  69783. private _setButtonValue;
  69784. /**
  69785. * Updates the generic gamepad
  69786. */
  69787. update(): void;
  69788. /**
  69789. * Disposes the generic gamepad
  69790. */
  69791. dispose(): void;
  69792. }
  69793. }
  69794. declare module BABYLON {
  69795. /**
  69796. * Defines the types of pose enabled controllers that are supported
  69797. */
  69798. export enum PoseEnabledControllerType {
  69799. /**
  69800. * HTC Vive
  69801. */
  69802. VIVE = 0,
  69803. /**
  69804. * Oculus Rift
  69805. */
  69806. OCULUS = 1,
  69807. /**
  69808. * Windows mixed reality
  69809. */
  69810. WINDOWS = 2,
  69811. /**
  69812. * Samsung gear VR
  69813. */
  69814. GEAR_VR = 3,
  69815. /**
  69816. * Google Daydream
  69817. */
  69818. DAYDREAM = 4,
  69819. /**
  69820. * Generic
  69821. */
  69822. GENERIC = 5
  69823. }
  69824. /**
  69825. * Defines the MutableGamepadButton interface for the state of a gamepad button
  69826. */
  69827. export interface MutableGamepadButton {
  69828. /**
  69829. * Value of the button/trigger
  69830. */
  69831. value: number;
  69832. /**
  69833. * If the button/trigger is currently touched
  69834. */
  69835. touched: boolean;
  69836. /**
  69837. * If the button/trigger is currently pressed
  69838. */
  69839. pressed: boolean;
  69840. }
  69841. /**
  69842. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  69843. * @hidden
  69844. */
  69845. export interface ExtendedGamepadButton extends GamepadButton {
  69846. /**
  69847. * If the button/trigger is currently pressed
  69848. */
  69849. readonly pressed: boolean;
  69850. /**
  69851. * If the button/trigger is currently touched
  69852. */
  69853. readonly touched: boolean;
  69854. /**
  69855. * Value of the button/trigger
  69856. */
  69857. readonly value: number;
  69858. }
  69859. /** @hidden */
  69860. export interface _GamePadFactory {
  69861. /**
  69862. * Returns wether or not the current gamepad can be created for this type of controller.
  69863. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  69864. * @returns true if it can be created, otherwise false
  69865. */
  69866. canCreate(gamepadInfo: any): boolean;
  69867. /**
  69868. * Creates a new instance of the Gamepad.
  69869. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  69870. * @returns the new gamepad instance
  69871. */
  69872. create(gamepadInfo: any): Gamepad;
  69873. }
  69874. /**
  69875. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  69876. */
  69877. export class PoseEnabledControllerHelper {
  69878. /** @hidden */
  69879. static _ControllerFactories: _GamePadFactory[];
  69880. /** @hidden */
  69881. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  69882. /**
  69883. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  69884. * @param vrGamepad the gamepad to initialized
  69885. * @returns a vr controller of the type the gamepad identified as
  69886. */
  69887. static InitiateController(vrGamepad: any): Gamepad;
  69888. }
  69889. /**
  69890. * Defines the PoseEnabledController object that contains state of a vr capable controller
  69891. */
  69892. export class PoseEnabledController extends Gamepad implements PoseControlled {
  69893. private _deviceRoomPosition;
  69894. private _deviceRoomRotationQuaternion;
  69895. /**
  69896. * The device position in babylon space
  69897. */
  69898. devicePosition: Vector3;
  69899. /**
  69900. * The device rotation in babylon space
  69901. */
  69902. deviceRotationQuaternion: Quaternion;
  69903. /**
  69904. * The scale factor of the device in babylon space
  69905. */
  69906. deviceScaleFactor: number;
  69907. /**
  69908. * (Likely devicePosition should be used instead) The device position in its room space
  69909. */
  69910. position: Vector3;
  69911. /**
  69912. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  69913. */
  69914. rotationQuaternion: Quaternion;
  69915. /**
  69916. * The type of controller (Eg. Windows mixed reality)
  69917. */
  69918. controllerType: PoseEnabledControllerType;
  69919. protected _calculatedPosition: Vector3;
  69920. private _calculatedRotation;
  69921. /**
  69922. * The raw pose from the device
  69923. */
  69924. rawPose: DevicePose;
  69925. private _trackPosition;
  69926. private _maxRotationDistFromHeadset;
  69927. private _draggedRoomRotation;
  69928. /**
  69929. * @hidden
  69930. */
  69931. _disableTrackPosition(fixedPosition: Vector3): void;
  69932. /**
  69933. * Internal, the mesh attached to the controller
  69934. * @hidden
  69935. */
  69936. _mesh: Nullable<AbstractMesh>;
  69937. private _poseControlledCamera;
  69938. private _leftHandSystemQuaternion;
  69939. /**
  69940. * Internal, matrix used to convert room space to babylon space
  69941. * @hidden
  69942. */
  69943. _deviceToWorld: Matrix;
  69944. /**
  69945. * Node to be used when casting a ray from the controller
  69946. * @hidden
  69947. */
  69948. _pointingPoseNode: Nullable<TransformNode>;
  69949. /**
  69950. * Name of the child mesh that can be used to cast a ray from the controller
  69951. */
  69952. static readonly POINTING_POSE: string;
  69953. /**
  69954. * Creates a new PoseEnabledController from a gamepad
  69955. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  69956. */
  69957. constructor(browserGamepad: any);
  69958. private _workingMatrix;
  69959. /**
  69960. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  69961. */
  69962. update(): void;
  69963. /**
  69964. * Updates only the pose device and mesh without doing any button event checking
  69965. */
  69966. protected _updatePoseAndMesh(): void;
  69967. /**
  69968. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  69969. * @param poseData raw pose fromthe device
  69970. */
  69971. updateFromDevice(poseData: DevicePose): void;
  69972. /**
  69973. * @hidden
  69974. */
  69975. _meshAttachedObservable: Observable<AbstractMesh>;
  69976. /**
  69977. * Attaches a mesh to the controller
  69978. * @param mesh the mesh to be attached
  69979. */
  69980. attachToMesh(mesh: AbstractMesh): void;
  69981. /**
  69982. * Attaches the controllers mesh to a camera
  69983. * @param camera the camera the mesh should be attached to
  69984. */
  69985. attachToPoseControlledCamera(camera: TargetCamera): void;
  69986. /**
  69987. * Disposes of the controller
  69988. */
  69989. dispose(): void;
  69990. /**
  69991. * The mesh that is attached to the controller
  69992. */
  69993. readonly mesh: Nullable<AbstractMesh>;
  69994. /**
  69995. * Gets the ray of the controller in the direction the controller is pointing
  69996. * @param length the length the resulting ray should be
  69997. * @returns a ray in the direction the controller is pointing
  69998. */
  69999. getForwardRay(length?: number): Ray;
  70000. }
  70001. }
  70002. declare module BABYLON {
  70003. /**
  70004. * Defines the WebVRController object that represents controllers tracked in 3D space
  70005. */
  70006. export abstract class WebVRController extends PoseEnabledController {
  70007. /**
  70008. * Internal, the default controller model for the controller
  70009. */
  70010. protected _defaultModel: AbstractMesh;
  70011. /**
  70012. * Fired when the trigger state has changed
  70013. */
  70014. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  70015. /**
  70016. * Fired when the main button state has changed
  70017. */
  70018. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  70019. /**
  70020. * Fired when the secondary button state has changed
  70021. */
  70022. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  70023. /**
  70024. * Fired when the pad state has changed
  70025. */
  70026. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  70027. /**
  70028. * Fired when controllers stick values have changed
  70029. */
  70030. onPadValuesChangedObservable: Observable<StickValues>;
  70031. /**
  70032. * Array of button availible on the controller
  70033. */
  70034. protected _buttons: Array<MutableGamepadButton>;
  70035. private _onButtonStateChange;
  70036. /**
  70037. * Fired when a controller button's state has changed
  70038. * @param callback the callback containing the button that was modified
  70039. */
  70040. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  70041. /**
  70042. * X and Y axis corrisponding to the controllers joystick
  70043. */
  70044. pad: StickValues;
  70045. /**
  70046. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  70047. */
  70048. hand: string;
  70049. /**
  70050. * The default controller model for the controller
  70051. */
  70052. readonly defaultModel: AbstractMesh;
  70053. /**
  70054. * Creates a new WebVRController from a gamepad
  70055. * @param vrGamepad the gamepad that the WebVRController should be created from
  70056. */
  70057. constructor(vrGamepad: any);
  70058. /**
  70059. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  70060. */
  70061. update(): void;
  70062. /**
  70063. * Function to be called when a button is modified
  70064. */
  70065. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  70066. /**
  70067. * Loads a mesh and attaches it to the controller
  70068. * @param scene the scene the mesh should be added to
  70069. * @param meshLoaded callback for when the mesh has been loaded
  70070. */
  70071. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  70072. private _setButtonValue;
  70073. private _changes;
  70074. private _checkChanges;
  70075. /**
  70076. * Disposes of th webVRCOntroller
  70077. */
  70078. dispose(): void;
  70079. }
  70080. }
  70081. declare module BABYLON {
  70082. /**
  70083. * The HemisphericLight simulates the ambient environment light,
  70084. * so the passed direction is the light reflection direction, not the incoming direction.
  70085. */
  70086. export class HemisphericLight extends Light {
  70087. /**
  70088. * The groundColor is the light in the opposite direction to the one specified during creation.
  70089. * 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.
  70090. */
  70091. groundColor: Color3;
  70092. /**
  70093. * The light reflection direction, not the incoming direction.
  70094. */
  70095. direction: Vector3;
  70096. /**
  70097. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  70098. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  70099. * The HemisphericLight can't cast shadows.
  70100. * Documentation : https://doc.babylonjs.com/babylon101/lights
  70101. * @param name The friendly name of the light
  70102. * @param direction The direction of the light reflection
  70103. * @param scene The scene the light belongs to
  70104. */
  70105. constructor(name: string, direction: Vector3, scene: Scene);
  70106. protected _buildUniformLayout(): void;
  70107. /**
  70108. * Returns the string "HemisphericLight".
  70109. * @return The class name
  70110. */
  70111. getClassName(): string;
  70112. /**
  70113. * Sets the HemisphericLight direction towards the passed target (Vector3).
  70114. * Returns the updated direction.
  70115. * @param target The target the direction should point to
  70116. * @return The computed direction
  70117. */
  70118. setDirectionToTarget(target: Vector3): Vector3;
  70119. /**
  70120. * Returns the shadow generator associated to the light.
  70121. * @returns Always null for hemispheric lights because it does not support shadows.
  70122. */
  70123. getShadowGenerator(): Nullable<IShadowGenerator>;
  70124. /**
  70125. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  70126. * @param effect The effect to update
  70127. * @param lightIndex The index of the light in the effect to update
  70128. * @returns The hemispheric light
  70129. */
  70130. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  70131. /**
  70132. * Computes the world matrix of the node
  70133. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  70134. * @param useWasUpdatedFlag defines a reserved property
  70135. * @returns the world matrix
  70136. */
  70137. computeWorldMatrix(): Matrix;
  70138. /**
  70139. * Returns the integer 3.
  70140. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  70141. */
  70142. getTypeID(): number;
  70143. /**
  70144. * Prepares the list of defines specific to the light type.
  70145. * @param defines the list of defines
  70146. * @param lightIndex defines the index of the light for the effect
  70147. */
  70148. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  70149. }
  70150. }
  70151. declare module BABYLON {
  70152. /**
  70153. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  70154. * IMPORTANT!! The data is right-hand data.
  70155. * @export
  70156. * @interface DevicePose
  70157. */
  70158. export interface DevicePose {
  70159. /**
  70160. * The position of the device, values in array are [x,y,z].
  70161. */
  70162. readonly position: Nullable<Float32Array>;
  70163. /**
  70164. * The linearVelocity of the device, values in array are [x,y,z].
  70165. */
  70166. readonly linearVelocity: Nullable<Float32Array>;
  70167. /**
  70168. * The linearAcceleration of the device, values in array are [x,y,z].
  70169. */
  70170. readonly linearAcceleration: Nullable<Float32Array>;
  70171. /**
  70172. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  70173. */
  70174. readonly orientation: Nullable<Float32Array>;
  70175. /**
  70176. * The angularVelocity of the device, values in array are [x,y,z].
  70177. */
  70178. readonly angularVelocity: Nullable<Float32Array>;
  70179. /**
  70180. * The angularAcceleration of the device, values in array are [x,y,z].
  70181. */
  70182. readonly angularAcceleration: Nullable<Float32Array>;
  70183. }
  70184. /**
  70185. * Interface representing a pose controlled object in Babylon.
  70186. * A pose controlled object has both regular pose values as well as pose values
  70187. * from an external device such as a VR head mounted display
  70188. */
  70189. export interface PoseControlled {
  70190. /**
  70191. * The position of the object in babylon space.
  70192. */
  70193. position: Vector3;
  70194. /**
  70195. * The rotation quaternion of the object in babylon space.
  70196. */
  70197. rotationQuaternion: Quaternion;
  70198. /**
  70199. * The position of the device in babylon space.
  70200. */
  70201. devicePosition?: Vector3;
  70202. /**
  70203. * The rotation quaternion of the device in babylon space.
  70204. */
  70205. deviceRotationQuaternion: Quaternion;
  70206. /**
  70207. * The raw pose coming from the device.
  70208. */
  70209. rawPose: Nullable<DevicePose>;
  70210. /**
  70211. * The scale of the device to be used when translating from device space to babylon space.
  70212. */
  70213. deviceScaleFactor: number;
  70214. /**
  70215. * Updates the poseControlled values based on the input device pose.
  70216. * @param poseData the pose data to update the object with
  70217. */
  70218. updateFromDevice(poseData: DevicePose): void;
  70219. }
  70220. /**
  70221. * Set of options to customize the webVRCamera
  70222. */
  70223. export interface WebVROptions {
  70224. /**
  70225. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  70226. */
  70227. trackPosition?: boolean;
  70228. /**
  70229. * Sets the scale of the vrDevice in babylon space. (default: 1)
  70230. */
  70231. positionScale?: number;
  70232. /**
  70233. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  70234. */
  70235. displayName?: string;
  70236. /**
  70237. * Should the native controller meshes be initialized. (default: true)
  70238. */
  70239. controllerMeshes?: boolean;
  70240. /**
  70241. * Creating a default HemiLight only on controllers. (default: true)
  70242. */
  70243. defaultLightingOnControllers?: boolean;
  70244. /**
  70245. * If you don't want to use the default VR button of the helper. (default: false)
  70246. */
  70247. useCustomVRButton?: boolean;
  70248. /**
  70249. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  70250. */
  70251. customVRButton?: HTMLButtonElement;
  70252. /**
  70253. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  70254. */
  70255. rayLength?: number;
  70256. /**
  70257. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  70258. */
  70259. defaultHeight?: number;
  70260. }
  70261. /**
  70262. * This represents a WebVR camera.
  70263. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  70264. * @example http://doc.babylonjs.com/how_to/webvr_camera
  70265. */
  70266. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  70267. private webVROptions;
  70268. /**
  70269. * @hidden
  70270. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  70271. */
  70272. _vrDevice: any;
  70273. /**
  70274. * The rawPose of the vrDevice.
  70275. */
  70276. rawPose: Nullable<DevicePose>;
  70277. private _onVREnabled;
  70278. private _specsVersion;
  70279. private _attached;
  70280. private _frameData;
  70281. protected _descendants: Array<Node>;
  70282. private _deviceRoomPosition;
  70283. /** @hidden */
  70284. _deviceRoomRotationQuaternion: Quaternion;
  70285. private _standingMatrix;
  70286. /**
  70287. * Represents device position in babylon space.
  70288. */
  70289. devicePosition: Vector3;
  70290. /**
  70291. * Represents device rotation in babylon space.
  70292. */
  70293. deviceRotationQuaternion: Quaternion;
  70294. /**
  70295. * The scale of the device to be used when translating from device space to babylon space.
  70296. */
  70297. deviceScaleFactor: number;
  70298. private _deviceToWorld;
  70299. private _worldToDevice;
  70300. /**
  70301. * References to the webVR controllers for the vrDevice.
  70302. */
  70303. controllers: Array<WebVRController>;
  70304. /**
  70305. * Emits an event when a controller is attached.
  70306. */
  70307. onControllersAttachedObservable: Observable<WebVRController[]>;
  70308. /**
  70309. * Emits an event when a controller's mesh has been loaded;
  70310. */
  70311. onControllerMeshLoadedObservable: Observable<WebVRController>;
  70312. /**
  70313. * Emits an event when the HMD's pose has been updated.
  70314. */
  70315. onPoseUpdatedFromDeviceObservable: Observable<any>;
  70316. private _poseSet;
  70317. /**
  70318. * If the rig cameras be used as parent instead of this camera.
  70319. */
  70320. rigParenting: boolean;
  70321. private _lightOnControllers;
  70322. private _defaultHeight?;
  70323. /**
  70324. * Instantiates a WebVRFreeCamera.
  70325. * @param name The name of the WebVRFreeCamera
  70326. * @param position The starting anchor position for the camera
  70327. * @param scene The scene the camera belongs to
  70328. * @param webVROptions a set of customizable options for the webVRCamera
  70329. */
  70330. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  70331. /**
  70332. * Gets the device distance from the ground in meters.
  70333. * @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.
  70334. */
  70335. deviceDistanceToRoomGround(): number;
  70336. /**
  70337. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  70338. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  70339. */
  70340. useStandingMatrix(callback?: (bool: boolean) => void): void;
  70341. /**
  70342. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  70343. * @returns A promise with a boolean set to if the standing matrix is supported.
  70344. */
  70345. useStandingMatrixAsync(): Promise<boolean>;
  70346. /**
  70347. * Disposes the camera
  70348. */
  70349. dispose(): void;
  70350. /**
  70351. * Gets a vrController by name.
  70352. * @param name The name of the controller to retreive
  70353. * @returns the controller matching the name specified or null if not found
  70354. */
  70355. getControllerByName(name: string): Nullable<WebVRController>;
  70356. private _leftController;
  70357. /**
  70358. * The controller corrisponding to the users left hand.
  70359. */
  70360. readonly leftController: Nullable<WebVRController>;
  70361. private _rightController;
  70362. /**
  70363. * The controller corrisponding to the users right hand.
  70364. */
  70365. readonly rightController: Nullable<WebVRController>;
  70366. /**
  70367. * Casts a ray forward from the vrCamera's gaze.
  70368. * @param length Length of the ray (default: 100)
  70369. * @returns the ray corrisponding to the gaze
  70370. */
  70371. getForwardRay(length?: number): Ray;
  70372. /**
  70373. * @hidden
  70374. * Updates the camera based on device's frame data
  70375. */
  70376. _checkInputs(): void;
  70377. /**
  70378. * Updates the poseControlled values based on the input device pose.
  70379. * @param poseData Pose coming from the device
  70380. */
  70381. updateFromDevice(poseData: DevicePose): void;
  70382. private _htmlElementAttached;
  70383. private _detachIfAttached;
  70384. /**
  70385. * WebVR's attach control will start broadcasting frames to the device.
  70386. * Note that in certain browsers (chrome for example) this function must be called
  70387. * within a user-interaction callback. Example:
  70388. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  70389. *
  70390. * @param element html element to attach the vrDevice to
  70391. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  70392. */
  70393. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  70394. /**
  70395. * Detaches the camera from the html element and disables VR
  70396. *
  70397. * @param element html element to detach from
  70398. */
  70399. detachControl(element: HTMLElement): void;
  70400. /**
  70401. * @returns the name of this class
  70402. */
  70403. getClassName(): string;
  70404. /**
  70405. * Calls resetPose on the vrDisplay
  70406. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  70407. */
  70408. resetToCurrentRotation(): void;
  70409. /**
  70410. * @hidden
  70411. * Updates the rig cameras (left and right eye)
  70412. */
  70413. _updateRigCameras(): void;
  70414. private _workingVector;
  70415. private _oneVector;
  70416. private _workingMatrix;
  70417. private updateCacheCalled;
  70418. private _correctPositionIfNotTrackPosition;
  70419. /**
  70420. * @hidden
  70421. * Updates the cached values of the camera
  70422. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  70423. */
  70424. _updateCache(ignoreParentClass?: boolean): void;
  70425. /**
  70426. * @hidden
  70427. * Get current device position in babylon world
  70428. */
  70429. _computeDevicePosition(): void;
  70430. /**
  70431. * Updates the current device position and rotation in the babylon world
  70432. */
  70433. update(): void;
  70434. /**
  70435. * @hidden
  70436. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  70437. * @returns an identity matrix
  70438. */
  70439. _getViewMatrix(): Matrix;
  70440. private _tmpMatrix;
  70441. /**
  70442. * This function is called by the two RIG cameras.
  70443. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  70444. * @hidden
  70445. */
  70446. _getWebVRViewMatrix(): Matrix;
  70447. /** @hidden */
  70448. _getWebVRProjectionMatrix(): Matrix;
  70449. private _onGamepadConnectedObserver;
  70450. private _onGamepadDisconnectedObserver;
  70451. private _updateCacheWhenTrackingDisabledObserver;
  70452. /**
  70453. * Initializes the controllers and their meshes
  70454. */
  70455. initControllers(): void;
  70456. }
  70457. }
  70458. declare module BABYLON {
  70459. /**
  70460. * Size options for a post process
  70461. */
  70462. export type PostProcessOptions = {
  70463. width: number;
  70464. height: number;
  70465. };
  70466. /**
  70467. * PostProcess can be used to apply a shader to a texture after it has been rendered
  70468. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  70469. */
  70470. export class PostProcess {
  70471. /** Name of the PostProcess. */
  70472. name: string;
  70473. /**
  70474. * Gets or sets the unique id of the post process
  70475. */
  70476. uniqueId: number;
  70477. /**
  70478. * Width of the texture to apply the post process on
  70479. */
  70480. width: number;
  70481. /**
  70482. * Height of the texture to apply the post process on
  70483. */
  70484. height: number;
  70485. /**
  70486. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  70487. * @hidden
  70488. */
  70489. _outputTexture: Nullable<InternalTexture>;
  70490. /**
  70491. * Sampling mode used by the shader
  70492. * See https://doc.babylonjs.com/classes/3.1/texture
  70493. */
  70494. renderTargetSamplingMode: number;
  70495. /**
  70496. * Clear color to use when screen clearing
  70497. */
  70498. clearColor: Color4;
  70499. /**
  70500. * If the buffer needs to be cleared before applying the post process. (default: true)
  70501. * Should be set to false if shader will overwrite all previous pixels.
  70502. */
  70503. autoClear: boolean;
  70504. /**
  70505. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  70506. */
  70507. alphaMode: number;
  70508. /**
  70509. * Sets the setAlphaBlendConstants of the babylon engine
  70510. */
  70511. alphaConstants: Color4;
  70512. /**
  70513. * Animations to be used for the post processing
  70514. */
  70515. animations: Animation[];
  70516. /**
  70517. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  70518. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  70519. */
  70520. enablePixelPerfectMode: boolean;
  70521. /**
  70522. * Force the postprocess to be applied without taking in account viewport
  70523. */
  70524. forceFullscreenViewport: boolean;
  70525. /**
  70526. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  70527. *
  70528. * | Value | Type | Description |
  70529. * | ----- | ----------------------------------- | ----------- |
  70530. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  70531. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  70532. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  70533. *
  70534. */
  70535. scaleMode: number;
  70536. /**
  70537. * Force textures to be a power of two (default: false)
  70538. */
  70539. alwaysForcePOT: boolean;
  70540. private _samples;
  70541. /**
  70542. * Number of sample textures (default: 1)
  70543. */
  70544. samples: number;
  70545. /**
  70546. * Modify the scale of the post process to be the same as the viewport (default: false)
  70547. */
  70548. adaptScaleToCurrentViewport: boolean;
  70549. private _camera;
  70550. private _scene;
  70551. private _engine;
  70552. private _options;
  70553. private _reusable;
  70554. private _textureType;
  70555. /**
  70556. * Smart array of input and output textures for the post process.
  70557. * @hidden
  70558. */
  70559. _textures: SmartArray<InternalTexture>;
  70560. /**
  70561. * The index in _textures that corresponds to the output texture.
  70562. * @hidden
  70563. */
  70564. _currentRenderTextureInd: number;
  70565. private _effect;
  70566. private _samplers;
  70567. private _fragmentUrl;
  70568. private _vertexUrl;
  70569. private _parameters;
  70570. private _scaleRatio;
  70571. protected _indexParameters: any;
  70572. private _shareOutputWithPostProcess;
  70573. private _texelSize;
  70574. private _forcedOutputTexture;
  70575. /**
  70576. * Returns the fragment url or shader name used in the post process.
  70577. * @returns the fragment url or name in the shader store.
  70578. */
  70579. getEffectName(): string;
  70580. /**
  70581. * An event triggered when the postprocess is activated.
  70582. */
  70583. onActivateObservable: Observable<Camera>;
  70584. private _onActivateObserver;
  70585. /**
  70586. * A function that is added to the onActivateObservable
  70587. */
  70588. onActivate: Nullable<(camera: Camera) => void>;
  70589. /**
  70590. * An event triggered when the postprocess changes its size.
  70591. */
  70592. onSizeChangedObservable: Observable<PostProcess>;
  70593. private _onSizeChangedObserver;
  70594. /**
  70595. * A function that is added to the onSizeChangedObservable
  70596. */
  70597. onSizeChanged: (postProcess: PostProcess) => void;
  70598. /**
  70599. * An event triggered when the postprocess applies its effect.
  70600. */
  70601. onApplyObservable: Observable<Effect>;
  70602. private _onApplyObserver;
  70603. /**
  70604. * A function that is added to the onApplyObservable
  70605. */
  70606. onApply: (effect: Effect) => void;
  70607. /**
  70608. * An event triggered before rendering the postprocess
  70609. */
  70610. onBeforeRenderObservable: Observable<Effect>;
  70611. private _onBeforeRenderObserver;
  70612. /**
  70613. * A function that is added to the onBeforeRenderObservable
  70614. */
  70615. onBeforeRender: (effect: Effect) => void;
  70616. /**
  70617. * An event triggered after rendering the postprocess
  70618. */
  70619. onAfterRenderObservable: Observable<Effect>;
  70620. private _onAfterRenderObserver;
  70621. /**
  70622. * A function that is added to the onAfterRenderObservable
  70623. */
  70624. onAfterRender: (efect: Effect) => void;
  70625. /**
  70626. * 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
  70627. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  70628. */
  70629. inputTexture: InternalTexture;
  70630. /**
  70631. * Gets the camera which post process is applied to.
  70632. * @returns The camera the post process is applied to.
  70633. */
  70634. getCamera(): Camera;
  70635. /**
  70636. * Gets the texel size of the postprocess.
  70637. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  70638. */
  70639. readonly texelSize: Vector2;
  70640. /**
  70641. * Creates a new instance PostProcess
  70642. * @param name The name of the PostProcess.
  70643. * @param fragmentUrl The url of the fragment shader to be used.
  70644. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  70645. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  70646. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  70647. * @param camera The camera to apply the render pass to.
  70648. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70649. * @param engine The engine which the post process will be applied. (default: current engine)
  70650. * @param reusable If the post process can be reused on the same frame. (default: false)
  70651. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  70652. * @param textureType Type of textures used when performing the post process. (default: 0)
  70653. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  70654. * @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
  70655. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  70656. */
  70657. constructor(
  70658. /** Name of the PostProcess. */
  70659. 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);
  70660. /**
  70661. * Gets a string idenfifying the name of the class
  70662. * @returns "PostProcess" string
  70663. */
  70664. getClassName(): string;
  70665. /**
  70666. * Gets the engine which this post process belongs to.
  70667. * @returns The engine the post process was enabled with.
  70668. */
  70669. getEngine(): Engine;
  70670. /**
  70671. * The effect that is created when initializing the post process.
  70672. * @returns The created effect corrisponding the the postprocess.
  70673. */
  70674. getEffect(): Effect;
  70675. /**
  70676. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  70677. * @param postProcess The post process to share the output with.
  70678. * @returns This post process.
  70679. */
  70680. shareOutputWith(postProcess: PostProcess): PostProcess;
  70681. /**
  70682. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  70683. * This should be called if the post process that shares output with this post process is disabled/disposed.
  70684. */
  70685. useOwnOutput(): void;
  70686. /**
  70687. * Updates the effect with the current post process compile time values and recompiles the shader.
  70688. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  70689. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  70690. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  70691. * @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
  70692. * @param onCompiled Called when the shader has been compiled.
  70693. * @param onError Called if there is an error when compiling a shader.
  70694. */
  70695. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  70696. /**
  70697. * The post process is reusable if it can be used multiple times within one frame.
  70698. * @returns If the post process is reusable
  70699. */
  70700. isReusable(): boolean;
  70701. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  70702. markTextureDirty(): void;
  70703. /**
  70704. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  70705. * 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.
  70706. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  70707. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  70708. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  70709. * @returns The target texture that was bound to be written to.
  70710. */
  70711. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  70712. /**
  70713. * If the post process is supported.
  70714. */
  70715. readonly isSupported: boolean;
  70716. /**
  70717. * The aspect ratio of the output texture.
  70718. */
  70719. readonly aspectRatio: number;
  70720. /**
  70721. * Get a value indicating if the post-process is ready to be used
  70722. * @returns true if the post-process is ready (shader is compiled)
  70723. */
  70724. isReady(): boolean;
  70725. /**
  70726. * Binds all textures and uniforms to the shader, this will be run on every pass.
  70727. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  70728. */
  70729. apply(): Nullable<Effect>;
  70730. private _disposeTextures;
  70731. /**
  70732. * Disposes the post process.
  70733. * @param camera The camera to dispose the post process on.
  70734. */
  70735. dispose(camera?: Camera): void;
  70736. }
  70737. }
  70738. declare module BABYLON {
  70739. /**
  70740. * PostProcessManager is used to manage one or more post processes or post process pipelines
  70741. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  70742. */
  70743. export class PostProcessManager {
  70744. private _scene;
  70745. private _indexBuffer;
  70746. private _vertexBuffers;
  70747. /**
  70748. * Creates a new instance PostProcess
  70749. * @param scene The scene that the post process is associated with.
  70750. */
  70751. constructor(scene: Scene);
  70752. private _prepareBuffers;
  70753. private _buildIndexBuffer;
  70754. /**
  70755. * Rebuilds the vertex buffers of the manager.
  70756. * @hidden
  70757. */
  70758. _rebuild(): void;
  70759. /**
  70760. * Prepares a frame to be run through a post process.
  70761. * @param sourceTexture The input texture to the post procesess. (default: null)
  70762. * @param postProcesses An array of post processes to be run. (default: null)
  70763. * @returns True if the post processes were able to be run.
  70764. * @hidden
  70765. */
  70766. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  70767. /**
  70768. * Manually render a set of post processes to a texture.
  70769. * @param postProcesses An array of post processes to be run.
  70770. * @param targetTexture The target texture to render to.
  70771. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  70772. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  70773. * @param lodLevel defines which lod of the texture to render to
  70774. */
  70775. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  70776. /**
  70777. * Finalize the result of the output of the postprocesses.
  70778. * @param doNotPresent If true the result will not be displayed to the screen.
  70779. * @param targetTexture The target texture to render to.
  70780. * @param faceIndex The index of the face to bind the target texture to.
  70781. * @param postProcesses The array of post processes to render.
  70782. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  70783. * @hidden
  70784. */
  70785. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  70786. /**
  70787. * Disposes of the post process manager.
  70788. */
  70789. dispose(): void;
  70790. }
  70791. }
  70792. declare module BABYLON {
  70793. interface AbstractScene {
  70794. /**
  70795. * The list of layers (background and foreground) of the scene
  70796. */
  70797. layers: Array<Layer>;
  70798. }
  70799. /**
  70800. * Defines the layer scene component responsible to manage any layers
  70801. * in a given scene.
  70802. */
  70803. export class LayerSceneComponent implements ISceneComponent {
  70804. /**
  70805. * The component name helpfull to identify the component in the list of scene components.
  70806. */
  70807. readonly name: string;
  70808. /**
  70809. * The scene the component belongs to.
  70810. */
  70811. scene: Scene;
  70812. private _engine;
  70813. /**
  70814. * Creates a new instance of the component for the given scene
  70815. * @param scene Defines the scene to register the component in
  70816. */
  70817. constructor(scene: Scene);
  70818. /**
  70819. * Registers the component in a given scene
  70820. */
  70821. register(): void;
  70822. /**
  70823. * Rebuilds the elements related to this component in case of
  70824. * context lost for instance.
  70825. */
  70826. rebuild(): void;
  70827. /**
  70828. * Disposes the component and the associated ressources.
  70829. */
  70830. dispose(): void;
  70831. private _draw;
  70832. private _drawCameraPredicate;
  70833. private _drawCameraBackground;
  70834. private _drawCameraForeground;
  70835. private _drawRenderTargetPredicate;
  70836. private _drawRenderTargetBackground;
  70837. private _drawRenderTargetForeground;
  70838. }
  70839. }
  70840. declare module BABYLON {
  70841. /** @hidden */
  70842. export var layerPixelShader: {
  70843. name: string;
  70844. shader: string;
  70845. };
  70846. }
  70847. declare module BABYLON {
  70848. /** @hidden */
  70849. export var layerVertexShader: {
  70850. name: string;
  70851. shader: string;
  70852. };
  70853. }
  70854. declare module BABYLON {
  70855. /**
  70856. * This represents a full screen 2d layer.
  70857. * This can be useful to display a picture in the background of your scene for instance.
  70858. * @see https://www.babylonjs-playground.com/#08A2BS#1
  70859. */
  70860. export class Layer {
  70861. /**
  70862. * Define the name of the layer.
  70863. */
  70864. name: string;
  70865. /**
  70866. * Define the texture the layer should display.
  70867. */
  70868. texture: Nullable<Texture>;
  70869. /**
  70870. * Is the layer in background or foreground.
  70871. */
  70872. isBackground: boolean;
  70873. /**
  70874. * Define the color of the layer (instead of texture).
  70875. */
  70876. color: Color4;
  70877. /**
  70878. * Define the scale of the layer in order to zoom in out of the texture.
  70879. */
  70880. scale: Vector2;
  70881. /**
  70882. * Define an offset for the layer in order to shift the texture.
  70883. */
  70884. offset: Vector2;
  70885. /**
  70886. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  70887. */
  70888. alphaBlendingMode: number;
  70889. /**
  70890. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  70891. * Alpha test will not mix with the background color in case of transparency.
  70892. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  70893. */
  70894. alphaTest: boolean;
  70895. /**
  70896. * Define a mask to restrict the layer to only some of the scene cameras.
  70897. */
  70898. layerMask: number;
  70899. /**
  70900. * Define the list of render target the layer is visible into.
  70901. */
  70902. renderTargetTextures: RenderTargetTexture[];
  70903. /**
  70904. * Define if the layer is only used in renderTarget or if it also
  70905. * renders in the main frame buffer of the canvas.
  70906. */
  70907. renderOnlyInRenderTargetTextures: boolean;
  70908. private _scene;
  70909. private _vertexBuffers;
  70910. private _indexBuffer;
  70911. private _effect;
  70912. private _alphaTestEffect;
  70913. /**
  70914. * An event triggered when the layer is disposed.
  70915. */
  70916. onDisposeObservable: Observable<Layer>;
  70917. private _onDisposeObserver;
  70918. /**
  70919. * Back compatibility with callback before the onDisposeObservable existed.
  70920. * The set callback will be triggered when the layer has been disposed.
  70921. */
  70922. onDispose: () => void;
  70923. /**
  70924. * An event triggered before rendering the scene
  70925. */
  70926. onBeforeRenderObservable: Observable<Layer>;
  70927. private _onBeforeRenderObserver;
  70928. /**
  70929. * Back compatibility with callback before the onBeforeRenderObservable existed.
  70930. * The set callback will be triggered just before rendering the layer.
  70931. */
  70932. onBeforeRender: () => void;
  70933. /**
  70934. * An event triggered after rendering the scene
  70935. */
  70936. onAfterRenderObservable: Observable<Layer>;
  70937. private _onAfterRenderObserver;
  70938. /**
  70939. * Back compatibility with callback before the onAfterRenderObservable existed.
  70940. * The set callback will be triggered just after rendering the layer.
  70941. */
  70942. onAfterRender: () => void;
  70943. /**
  70944. * Instantiates a new layer.
  70945. * This represents a full screen 2d layer.
  70946. * This can be useful to display a picture in the background of your scene for instance.
  70947. * @see https://www.babylonjs-playground.com/#08A2BS#1
  70948. * @param name Define the name of the layer in the scene
  70949. * @param imgUrl Define the url of the texture to display in the layer
  70950. * @param scene Define the scene the layer belongs to
  70951. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  70952. * @param color Defines a color for the layer
  70953. */
  70954. constructor(
  70955. /**
  70956. * Define the name of the layer.
  70957. */
  70958. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  70959. private _createIndexBuffer;
  70960. /** @hidden */
  70961. _rebuild(): void;
  70962. /**
  70963. * Renders the layer in the scene.
  70964. */
  70965. render(): void;
  70966. /**
  70967. * Disposes and releases the associated ressources.
  70968. */
  70969. dispose(): void;
  70970. }
  70971. }
  70972. declare module BABYLON {
  70973. interface AbstractScene {
  70974. /**
  70975. * The list of procedural textures added to the scene
  70976. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  70977. */
  70978. proceduralTextures: Array<ProceduralTexture>;
  70979. }
  70980. /**
  70981. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  70982. * in a given scene.
  70983. */
  70984. export class ProceduralTextureSceneComponent implements ISceneComponent {
  70985. /**
  70986. * The component name helpfull to identify the component in the list of scene components.
  70987. */
  70988. readonly name: string;
  70989. /**
  70990. * The scene the component belongs to.
  70991. */
  70992. scene: Scene;
  70993. /**
  70994. * Creates a new instance of the component for the given scene
  70995. * @param scene Defines the scene to register the component in
  70996. */
  70997. constructor(scene: Scene);
  70998. /**
  70999. * Registers the component in a given scene
  71000. */
  71001. register(): void;
  71002. /**
  71003. * Rebuilds the elements related to this component in case of
  71004. * context lost for instance.
  71005. */
  71006. rebuild(): void;
  71007. /**
  71008. * Disposes the component and the associated ressources.
  71009. */
  71010. dispose(): void;
  71011. private _beforeClear;
  71012. }
  71013. }
  71014. declare module BABYLON {
  71015. /** @hidden */
  71016. export var proceduralVertexShader: {
  71017. name: string;
  71018. shader: string;
  71019. };
  71020. }
  71021. declare module BABYLON {
  71022. /**
  71023. * 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.
  71024. * This is the base class of any Procedural texture and contains most of the shareable code.
  71025. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  71026. */
  71027. export class ProceduralTexture extends Texture {
  71028. isCube: boolean;
  71029. /**
  71030. * Define if the texture is enabled or not (disabled texture will not render)
  71031. */
  71032. isEnabled: boolean;
  71033. /**
  71034. * Define if the texture must be cleared before rendering (default is true)
  71035. */
  71036. autoClear: boolean;
  71037. /**
  71038. * Callback called when the texture is generated
  71039. */
  71040. onGenerated: () => void;
  71041. /**
  71042. * Event raised when the texture is generated
  71043. */
  71044. onGeneratedObservable: Observable<ProceduralTexture>;
  71045. /** @hidden */
  71046. _generateMipMaps: boolean;
  71047. /** @hidden **/
  71048. _effect: Effect;
  71049. /** @hidden */
  71050. _textures: {
  71051. [key: string]: Texture;
  71052. };
  71053. private _size;
  71054. private _currentRefreshId;
  71055. private _refreshRate;
  71056. private _vertexBuffers;
  71057. private _indexBuffer;
  71058. private _uniforms;
  71059. private _samplers;
  71060. private _fragment;
  71061. private _floats;
  71062. private _ints;
  71063. private _floatsArrays;
  71064. private _colors3;
  71065. private _colors4;
  71066. private _vectors2;
  71067. private _vectors3;
  71068. private _matrices;
  71069. private _fallbackTexture;
  71070. private _fallbackTextureUsed;
  71071. private _engine;
  71072. private _cachedDefines;
  71073. private _contentUpdateId;
  71074. private _contentData;
  71075. /**
  71076. * Instantiates a new procedural texture.
  71077. * 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.
  71078. * This is the base class of any Procedural texture and contains most of the shareable code.
  71079. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  71080. * @param name Define the name of the texture
  71081. * @param size Define the size of the texture to create
  71082. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  71083. * @param scene Define the scene the texture belongs to
  71084. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  71085. * @param generateMipMaps Define if the texture should creates mip maps or not
  71086. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  71087. */
  71088. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  71089. /**
  71090. * The effect that is created when initializing the post process.
  71091. * @returns The created effect corrisponding the the postprocess.
  71092. */
  71093. getEffect(): Effect;
  71094. /**
  71095. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  71096. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  71097. */
  71098. getContent(): Nullable<ArrayBufferView>;
  71099. private _createIndexBuffer;
  71100. /** @hidden */
  71101. _rebuild(): void;
  71102. /**
  71103. * Resets the texture in order to recreate its associated resources.
  71104. * This can be called in case of context loss
  71105. */
  71106. reset(): void;
  71107. protected _getDefines(): string;
  71108. /**
  71109. * Is the texture ready to be used ? (rendered at least once)
  71110. * @returns true if ready, otherwise, false.
  71111. */
  71112. isReady(): boolean;
  71113. /**
  71114. * Resets the refresh counter of the texture and start bak from scratch.
  71115. * Could be useful to regenerate the texture if it is setup to render only once.
  71116. */
  71117. resetRefreshCounter(): void;
  71118. /**
  71119. * Set the fragment shader to use in order to render the texture.
  71120. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  71121. */
  71122. setFragment(fragment: any): void;
  71123. /**
  71124. * Define the refresh rate of the texture or the rendering frequency.
  71125. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  71126. */
  71127. refreshRate: number;
  71128. /** @hidden */
  71129. _shouldRender(): boolean;
  71130. /**
  71131. * Get the size the texture is rendering at.
  71132. * @returns the size (texture is always squared)
  71133. */
  71134. getRenderSize(): number;
  71135. /**
  71136. * Resize the texture to new value.
  71137. * @param size Define the new size the texture should have
  71138. * @param generateMipMaps Define whether the new texture should create mip maps
  71139. */
  71140. resize(size: number, generateMipMaps: boolean): void;
  71141. private _checkUniform;
  71142. /**
  71143. * Set a texture in the shader program used to render.
  71144. * @param name Define the name of the uniform samplers as defined in the shader
  71145. * @param texture Define the texture to bind to this sampler
  71146. * @return the texture itself allowing "fluent" like uniform updates
  71147. */
  71148. setTexture(name: string, texture: Texture): ProceduralTexture;
  71149. /**
  71150. * Set a float in the shader.
  71151. * @param name Define the name of the uniform as defined in the shader
  71152. * @param value Define the value to give to the uniform
  71153. * @return the texture itself allowing "fluent" like uniform updates
  71154. */
  71155. setFloat(name: string, value: number): ProceduralTexture;
  71156. /**
  71157. * Set a int in the shader.
  71158. * @param name Define the name of the uniform as defined in the shader
  71159. * @param value Define the value to give to the uniform
  71160. * @return the texture itself allowing "fluent" like uniform updates
  71161. */
  71162. setInt(name: string, value: number): ProceduralTexture;
  71163. /**
  71164. * Set an array of floats in the shader.
  71165. * @param name Define the name of the uniform as defined in the shader
  71166. * @param value Define the value to give to the uniform
  71167. * @return the texture itself allowing "fluent" like uniform updates
  71168. */
  71169. setFloats(name: string, value: number[]): ProceduralTexture;
  71170. /**
  71171. * Set a vec3 in the shader from a Color3.
  71172. * @param name Define the name of the uniform as defined in the shader
  71173. * @param value Define the value to give to the uniform
  71174. * @return the texture itself allowing "fluent" like uniform updates
  71175. */
  71176. setColor3(name: string, value: Color3): ProceduralTexture;
  71177. /**
  71178. * Set a vec4 in the shader from a Color4.
  71179. * @param name Define the name of the uniform as defined in the shader
  71180. * @param value Define the value to give to the uniform
  71181. * @return the texture itself allowing "fluent" like uniform updates
  71182. */
  71183. setColor4(name: string, value: Color4): ProceduralTexture;
  71184. /**
  71185. * Set a vec2 in the shader from a Vector2.
  71186. * @param name Define the name of the uniform as defined in the shader
  71187. * @param value Define the value to give to the uniform
  71188. * @return the texture itself allowing "fluent" like uniform updates
  71189. */
  71190. setVector2(name: string, value: Vector2): ProceduralTexture;
  71191. /**
  71192. * Set a vec3 in the shader from a Vector3.
  71193. * @param name Define the name of the uniform as defined in the shader
  71194. * @param value Define the value to give to the uniform
  71195. * @return the texture itself allowing "fluent" like uniform updates
  71196. */
  71197. setVector3(name: string, value: Vector3): ProceduralTexture;
  71198. /**
  71199. * Set a mat4 in the shader from a MAtrix.
  71200. * @param name Define the name of the uniform as defined in the shader
  71201. * @param value Define the value to give to the uniform
  71202. * @return the texture itself allowing "fluent" like uniform updates
  71203. */
  71204. setMatrix(name: string, value: Matrix): ProceduralTexture;
  71205. /**
  71206. * Render the texture to its associated render target.
  71207. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  71208. */
  71209. render(useCameraPostProcess?: boolean): void;
  71210. /**
  71211. * Clone the texture.
  71212. * @returns the cloned texture
  71213. */
  71214. clone(): ProceduralTexture;
  71215. /**
  71216. * Dispose the texture and release its asoociated resources.
  71217. */
  71218. dispose(): void;
  71219. }
  71220. }
  71221. declare module BABYLON {
  71222. /**
  71223. * This represents the base class for particle system in Babylon.
  71224. * 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.
  71225. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  71226. * @example https://doc.babylonjs.com/babylon101/particles
  71227. */
  71228. export class BaseParticleSystem {
  71229. /**
  71230. * Source color is added to the destination color without alpha affecting the result
  71231. */
  71232. static BLENDMODE_ONEONE: number;
  71233. /**
  71234. * Blend current color and particle color using particle’s alpha
  71235. */
  71236. static BLENDMODE_STANDARD: number;
  71237. /**
  71238. * Add current color and particle color multiplied by particle’s alpha
  71239. */
  71240. static BLENDMODE_ADD: number;
  71241. /**
  71242. * Multiply current color with particle color
  71243. */
  71244. static BLENDMODE_MULTIPLY: number;
  71245. /**
  71246. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  71247. */
  71248. static BLENDMODE_MULTIPLYADD: number;
  71249. /**
  71250. * List of animations used by the particle system.
  71251. */
  71252. animations: Animation[];
  71253. /**
  71254. * The id of the Particle system.
  71255. */
  71256. id: string;
  71257. /**
  71258. * The friendly name of the Particle system.
  71259. */
  71260. name: string;
  71261. /**
  71262. * The rendering group used by the Particle system to chose when to render.
  71263. */
  71264. renderingGroupId: number;
  71265. /**
  71266. * The emitter represents the Mesh or position we are attaching the particle system to.
  71267. */
  71268. emitter: Nullable<AbstractMesh | Vector3>;
  71269. /**
  71270. * The maximum number of particles to emit per frame
  71271. */
  71272. emitRate: number;
  71273. /**
  71274. * If you want to launch only a few particles at once, that can be done, as well.
  71275. */
  71276. manualEmitCount: number;
  71277. /**
  71278. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  71279. */
  71280. updateSpeed: number;
  71281. /**
  71282. * The amount of time the particle system is running (depends of the overall update speed).
  71283. */
  71284. targetStopDuration: number;
  71285. /**
  71286. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  71287. */
  71288. disposeOnStop: boolean;
  71289. /**
  71290. * Minimum power of emitting particles.
  71291. */
  71292. minEmitPower: number;
  71293. /**
  71294. * Maximum power of emitting particles.
  71295. */
  71296. maxEmitPower: number;
  71297. /**
  71298. * Minimum life time of emitting particles.
  71299. */
  71300. minLifeTime: number;
  71301. /**
  71302. * Maximum life time of emitting particles.
  71303. */
  71304. maxLifeTime: number;
  71305. /**
  71306. * Minimum Size of emitting particles.
  71307. */
  71308. minSize: number;
  71309. /**
  71310. * Maximum Size of emitting particles.
  71311. */
  71312. maxSize: number;
  71313. /**
  71314. * Minimum scale of emitting particles on X axis.
  71315. */
  71316. minScaleX: number;
  71317. /**
  71318. * Maximum scale of emitting particles on X axis.
  71319. */
  71320. maxScaleX: number;
  71321. /**
  71322. * Minimum scale of emitting particles on Y axis.
  71323. */
  71324. minScaleY: number;
  71325. /**
  71326. * Maximum scale of emitting particles on Y axis.
  71327. */
  71328. maxScaleY: number;
  71329. /**
  71330. * Gets or sets the minimal initial rotation in radians.
  71331. */
  71332. minInitialRotation: number;
  71333. /**
  71334. * Gets or sets the maximal initial rotation in radians.
  71335. */
  71336. maxInitialRotation: number;
  71337. /**
  71338. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  71339. */
  71340. minAngularSpeed: number;
  71341. /**
  71342. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  71343. */
  71344. maxAngularSpeed: number;
  71345. /**
  71346. * The texture used to render each particle. (this can be a spritesheet)
  71347. */
  71348. particleTexture: Nullable<Texture>;
  71349. /**
  71350. * The layer mask we are rendering the particles through.
  71351. */
  71352. layerMask: number;
  71353. /**
  71354. * This can help using your own shader to render the particle system.
  71355. * The according effect will be created
  71356. */
  71357. customShader: any;
  71358. /**
  71359. * By default particle system starts as soon as they are created. This prevents the
  71360. * automatic start to happen and let you decide when to start emitting particles.
  71361. */
  71362. preventAutoStart: boolean;
  71363. private _noiseTexture;
  71364. /**
  71365. * Gets or sets a texture used to add random noise to particle positions
  71366. */
  71367. noiseTexture: Nullable<ProceduralTexture>;
  71368. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  71369. noiseStrength: Vector3;
  71370. /**
  71371. * Callback triggered when the particle animation is ending.
  71372. */
  71373. onAnimationEnd: Nullable<() => void>;
  71374. /**
  71375. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  71376. */
  71377. blendMode: number;
  71378. /**
  71379. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  71380. * to override the particles.
  71381. */
  71382. forceDepthWrite: boolean;
  71383. /** 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 */
  71384. preWarmCycles: number;
  71385. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  71386. preWarmStepOffset: number;
  71387. /**
  71388. * 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)
  71389. */
  71390. spriteCellChangeSpeed: number;
  71391. /**
  71392. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  71393. */
  71394. startSpriteCellID: number;
  71395. /**
  71396. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  71397. */
  71398. endSpriteCellID: number;
  71399. /**
  71400. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  71401. */
  71402. spriteCellWidth: number;
  71403. /**
  71404. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  71405. */
  71406. spriteCellHeight: number;
  71407. /**
  71408. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  71409. */
  71410. spriteRandomStartCell: boolean;
  71411. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  71412. translationPivot: Vector2;
  71413. /** @hidden */
  71414. protected _isAnimationSheetEnabled: boolean;
  71415. /**
  71416. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  71417. */
  71418. beginAnimationOnStart: boolean;
  71419. /**
  71420. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  71421. */
  71422. beginAnimationFrom: number;
  71423. /**
  71424. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  71425. */
  71426. beginAnimationTo: number;
  71427. /**
  71428. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  71429. */
  71430. beginAnimationLoop: boolean;
  71431. /**
  71432. * Gets or sets a world offset applied to all particles
  71433. */
  71434. worldOffset: Vector3;
  71435. /**
  71436. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  71437. */
  71438. isAnimationSheetEnabled: boolean;
  71439. /**
  71440. * Get hosting scene
  71441. * @returns the scene
  71442. */
  71443. getScene(): Scene;
  71444. /**
  71445. * You can use gravity if you want to give an orientation to your particles.
  71446. */
  71447. gravity: Vector3;
  71448. protected _colorGradients: Nullable<Array<ColorGradient>>;
  71449. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  71450. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  71451. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  71452. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  71453. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  71454. protected _dragGradients: Nullable<Array<FactorGradient>>;
  71455. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  71456. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  71457. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  71458. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  71459. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  71460. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  71461. /**
  71462. * Defines the delay in milliseconds before starting the system (0 by default)
  71463. */
  71464. startDelay: number;
  71465. /**
  71466. * Gets the current list of drag gradients.
  71467. * You must use addDragGradient and removeDragGradient to udpate this list
  71468. * @returns the list of drag gradients
  71469. */
  71470. getDragGradients(): Nullable<Array<FactorGradient>>;
  71471. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  71472. limitVelocityDamping: number;
  71473. /**
  71474. * Gets the current list of limit velocity gradients.
  71475. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  71476. * @returns the list of limit velocity gradients
  71477. */
  71478. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  71479. /**
  71480. * Gets the current list of color gradients.
  71481. * You must use addColorGradient and removeColorGradient to udpate this list
  71482. * @returns the list of color gradients
  71483. */
  71484. getColorGradients(): Nullable<Array<ColorGradient>>;
  71485. /**
  71486. * Gets the current list of size gradients.
  71487. * You must use addSizeGradient and removeSizeGradient to udpate this list
  71488. * @returns the list of size gradients
  71489. */
  71490. getSizeGradients(): Nullable<Array<FactorGradient>>;
  71491. /**
  71492. * Gets the current list of color remap gradients.
  71493. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  71494. * @returns the list of color remap gradients
  71495. */
  71496. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  71497. /**
  71498. * Gets the current list of alpha remap gradients.
  71499. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  71500. * @returns the list of alpha remap gradients
  71501. */
  71502. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  71503. /**
  71504. * Gets the current list of life time gradients.
  71505. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  71506. * @returns the list of life time gradients
  71507. */
  71508. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  71509. /**
  71510. * Gets the current list of angular speed gradients.
  71511. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  71512. * @returns the list of angular speed gradients
  71513. */
  71514. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  71515. /**
  71516. * Gets the current list of velocity gradients.
  71517. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  71518. * @returns the list of velocity gradients
  71519. */
  71520. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  71521. /**
  71522. * Gets the current list of start size gradients.
  71523. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  71524. * @returns the list of start size gradients
  71525. */
  71526. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  71527. /**
  71528. * Gets the current list of emit rate gradients.
  71529. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  71530. * @returns the list of emit rate gradients
  71531. */
  71532. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  71533. /**
  71534. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  71535. * This only works when particleEmitterTyps is a BoxParticleEmitter
  71536. */
  71537. direction1: Vector3;
  71538. /**
  71539. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  71540. * This only works when particleEmitterTyps is a BoxParticleEmitter
  71541. */
  71542. direction2: Vector3;
  71543. /**
  71544. * 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.
  71545. * This only works when particleEmitterTyps is a BoxParticleEmitter
  71546. */
  71547. minEmitBox: Vector3;
  71548. /**
  71549. * 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.
  71550. * This only works when particleEmitterTyps is a BoxParticleEmitter
  71551. */
  71552. maxEmitBox: Vector3;
  71553. /**
  71554. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  71555. */
  71556. color1: Color4;
  71557. /**
  71558. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  71559. */
  71560. color2: Color4;
  71561. /**
  71562. * Color the particle will have at the end of its lifetime
  71563. */
  71564. colorDead: Color4;
  71565. /**
  71566. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  71567. */
  71568. textureMask: Color4;
  71569. /**
  71570. * The particle emitter type defines the emitter used by the particle system.
  71571. * It can be for example box, sphere, or cone...
  71572. */
  71573. particleEmitterType: IParticleEmitterType;
  71574. /** @hidden */
  71575. _isSubEmitter: boolean;
  71576. /**
  71577. * Gets or sets the billboard mode to use when isBillboardBased = true.
  71578. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  71579. */
  71580. billboardMode: number;
  71581. protected _isBillboardBased: boolean;
  71582. /**
  71583. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  71584. */
  71585. isBillboardBased: boolean;
  71586. /**
  71587. * The scene the particle system belongs to.
  71588. */
  71589. protected _scene: Scene;
  71590. /**
  71591. * Local cache of defines for image processing.
  71592. */
  71593. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  71594. /**
  71595. * Default configuration related to image processing available in the standard Material.
  71596. */
  71597. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  71598. /**
  71599. * Gets the image processing configuration used either in this material.
  71600. */
  71601. /**
  71602. * Sets the Default image processing configuration used either in the this material.
  71603. *
  71604. * If sets to null, the scene one is in use.
  71605. */
  71606. imageProcessingConfiguration: ImageProcessingConfiguration;
  71607. /**
  71608. * Attaches a new image processing configuration to the Standard Material.
  71609. * @param configuration
  71610. */
  71611. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  71612. /** @hidden */
  71613. protected _reset(): void;
  71614. /** @hidden */
  71615. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  71616. /**
  71617. * Instantiates a particle system.
  71618. * 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.
  71619. * @param name The name of the particle system
  71620. */
  71621. constructor(name: string);
  71622. /**
  71623. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  71624. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  71625. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  71626. * @returns the emitter
  71627. */
  71628. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  71629. /**
  71630. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  71631. * @param radius The radius of the hemisphere to emit from
  71632. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  71633. * @returns the emitter
  71634. */
  71635. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  71636. /**
  71637. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  71638. * @param radius The radius of the sphere to emit from
  71639. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  71640. * @returns the emitter
  71641. */
  71642. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  71643. /**
  71644. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  71645. * @param radius The radius of the sphere to emit from
  71646. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  71647. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  71648. * @returns the emitter
  71649. */
  71650. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  71651. /**
  71652. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  71653. * @param radius The radius of the emission cylinder
  71654. * @param height The height of the emission cylinder
  71655. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  71656. * @param directionRandomizer How much to randomize the particle direction [0-1]
  71657. * @returns the emitter
  71658. */
  71659. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  71660. /**
  71661. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  71662. * @param radius The radius of the cylinder to emit from
  71663. * @param height The height of the emission cylinder
  71664. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  71665. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  71666. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  71667. * @returns the emitter
  71668. */
  71669. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  71670. /**
  71671. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  71672. * @param radius The radius of the cone to emit from
  71673. * @param angle The base angle of the cone
  71674. * @returns the emitter
  71675. */
  71676. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  71677. /**
  71678. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  71679. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  71680. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  71681. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  71682. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  71683. * @returns the emitter
  71684. */
  71685. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  71686. }
  71687. }
  71688. declare module BABYLON {
  71689. /**
  71690. * Type of sub emitter
  71691. */
  71692. export enum SubEmitterType {
  71693. /**
  71694. * Attached to the particle over it's lifetime
  71695. */
  71696. ATTACHED = 0,
  71697. /**
  71698. * Created when the particle dies
  71699. */
  71700. END = 1
  71701. }
  71702. /**
  71703. * Sub emitter class used to emit particles from an existing particle
  71704. */
  71705. export class SubEmitter {
  71706. /**
  71707. * the particle system to be used by the sub emitter
  71708. */
  71709. particleSystem: ParticleSystem;
  71710. /**
  71711. * Type of the submitter (Default: END)
  71712. */
  71713. type: SubEmitterType;
  71714. /**
  71715. * 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)
  71716. * Note: This only is supported when using an emitter of type Mesh
  71717. */
  71718. inheritDirection: boolean;
  71719. /**
  71720. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  71721. */
  71722. inheritedVelocityAmount: number;
  71723. /**
  71724. * Creates a sub emitter
  71725. * @param particleSystem the particle system to be used by the sub emitter
  71726. */
  71727. constructor(
  71728. /**
  71729. * the particle system to be used by the sub emitter
  71730. */
  71731. particleSystem: ParticleSystem);
  71732. /**
  71733. * Clones the sub emitter
  71734. * @returns the cloned sub emitter
  71735. */
  71736. clone(): SubEmitter;
  71737. /**
  71738. * Serialize current object to a JSON object
  71739. * @returns the serialized object
  71740. */
  71741. serialize(): any;
  71742. /** @hidden */
  71743. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  71744. /**
  71745. * Creates a new SubEmitter from a serialized JSON version
  71746. * @param serializationObject defines the JSON object to read from
  71747. * @param scene defines the hosting scene
  71748. * @param rootUrl defines the rootUrl for data loading
  71749. * @returns a new SubEmitter
  71750. */
  71751. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  71752. /** Release associated resources */
  71753. dispose(): void;
  71754. }
  71755. }
  71756. declare module BABYLON {
  71757. /** @hidden */
  71758. export var clipPlaneFragmentDeclaration: {
  71759. name: string;
  71760. shader: string;
  71761. };
  71762. }
  71763. declare module BABYLON {
  71764. /** @hidden */
  71765. export var imageProcessingDeclaration: {
  71766. name: string;
  71767. shader: string;
  71768. };
  71769. }
  71770. declare module BABYLON {
  71771. /** @hidden */
  71772. export var imageProcessingFunctions: {
  71773. name: string;
  71774. shader: string;
  71775. };
  71776. }
  71777. declare module BABYLON {
  71778. /** @hidden */
  71779. export var clipPlaneFragment: {
  71780. name: string;
  71781. shader: string;
  71782. };
  71783. }
  71784. declare module BABYLON {
  71785. /** @hidden */
  71786. export var particlesPixelShader: {
  71787. name: string;
  71788. shader: string;
  71789. };
  71790. }
  71791. declare module BABYLON {
  71792. /** @hidden */
  71793. export var clipPlaneVertexDeclaration: {
  71794. name: string;
  71795. shader: string;
  71796. };
  71797. }
  71798. declare module BABYLON {
  71799. /** @hidden */
  71800. export var clipPlaneVertex: {
  71801. name: string;
  71802. shader: string;
  71803. };
  71804. }
  71805. declare module BABYLON {
  71806. /** @hidden */
  71807. export var particlesVertexShader: {
  71808. name: string;
  71809. shader: string;
  71810. };
  71811. }
  71812. declare module BABYLON {
  71813. /**
  71814. * This represents a particle system in Babylon.
  71815. * 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.
  71816. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  71817. * @example https://doc.babylonjs.com/babylon101/particles
  71818. */
  71819. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  71820. /**
  71821. * Billboard mode will only apply to Y axis
  71822. */
  71823. static readonly BILLBOARDMODE_Y: number;
  71824. /**
  71825. * Billboard mode will apply to all axes
  71826. */
  71827. static readonly BILLBOARDMODE_ALL: number;
  71828. /**
  71829. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  71830. */
  71831. static readonly BILLBOARDMODE_STRETCHED: number;
  71832. /**
  71833. * This function can be defined to provide custom update for active particles.
  71834. * This function will be called instead of regular update (age, position, color, etc.).
  71835. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  71836. */
  71837. updateFunction: (particles: Particle[]) => void;
  71838. private _emitterWorldMatrix;
  71839. /**
  71840. * This function can be defined to specify initial direction for every new particle.
  71841. * It by default use the emitterType defined function
  71842. */
  71843. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  71844. /**
  71845. * This function can be defined to specify initial position for every new particle.
  71846. * It by default use the emitterType defined function
  71847. */
  71848. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  71849. /**
  71850. * @hidden
  71851. */
  71852. _inheritedVelocityOffset: Vector3;
  71853. /**
  71854. * An event triggered when the system is disposed
  71855. */
  71856. onDisposeObservable: Observable<ParticleSystem>;
  71857. private _onDisposeObserver;
  71858. /**
  71859. * Sets a callback that will be triggered when the system is disposed
  71860. */
  71861. onDispose: () => void;
  71862. private _particles;
  71863. private _epsilon;
  71864. private _capacity;
  71865. private _stockParticles;
  71866. private _newPartsExcess;
  71867. private _vertexData;
  71868. private _vertexBuffer;
  71869. private _vertexBuffers;
  71870. private _spriteBuffer;
  71871. private _indexBuffer;
  71872. private _effect;
  71873. private _customEffect;
  71874. private _cachedDefines;
  71875. private _scaledColorStep;
  71876. private _colorDiff;
  71877. private _scaledDirection;
  71878. private _scaledGravity;
  71879. private _currentRenderId;
  71880. private _alive;
  71881. private _useInstancing;
  71882. private _started;
  71883. private _stopped;
  71884. private _actualFrame;
  71885. private _scaledUpdateSpeed;
  71886. private _vertexBufferSize;
  71887. /** @hidden */
  71888. _currentEmitRateGradient: Nullable<FactorGradient>;
  71889. /** @hidden */
  71890. _currentEmitRate1: number;
  71891. /** @hidden */
  71892. _currentEmitRate2: number;
  71893. /** @hidden */
  71894. _currentStartSizeGradient: Nullable<FactorGradient>;
  71895. /** @hidden */
  71896. _currentStartSize1: number;
  71897. /** @hidden */
  71898. _currentStartSize2: number;
  71899. private readonly _rawTextureWidth;
  71900. private _rampGradientsTexture;
  71901. private _useRampGradients;
  71902. /** Gets or sets a boolean indicating that ramp gradients must be used
  71903. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  71904. */
  71905. useRampGradients: boolean;
  71906. /**
  71907. * 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.
  71908. * 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: [])
  71909. */
  71910. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  71911. private _subEmitters;
  71912. /**
  71913. * @hidden
  71914. * If the particle systems emitter should be disposed when the particle system is disposed
  71915. */
  71916. _disposeEmitterOnDispose: boolean;
  71917. /**
  71918. * The current active Sub-systems, this property is used by the root particle system only.
  71919. */
  71920. activeSubSystems: Array<ParticleSystem>;
  71921. private _rootParticleSystem;
  71922. /**
  71923. * Gets the current list of active particles
  71924. */
  71925. readonly particles: Particle[];
  71926. /**
  71927. * Returns the string "ParticleSystem"
  71928. * @returns a string containing the class name
  71929. */
  71930. getClassName(): string;
  71931. /**
  71932. * Instantiates a particle system.
  71933. * 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.
  71934. * @param name The name of the particle system
  71935. * @param capacity The max number of particles alive at the same time
  71936. * @param scene The scene the particle system belongs to
  71937. * @param customEffect a custom effect used to change the way particles are rendered by default
  71938. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  71939. * @param epsilon Offset used to render the particles
  71940. */
  71941. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  71942. private _addFactorGradient;
  71943. private _removeFactorGradient;
  71944. /**
  71945. * Adds a new life time gradient
  71946. * @param gradient defines the gradient to use (between 0 and 1)
  71947. * @param factor defines the life time factor to affect to the specified gradient
  71948. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  71949. * @returns the current particle system
  71950. */
  71951. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  71952. /**
  71953. * Remove a specific life time gradient
  71954. * @param gradient defines the gradient to remove
  71955. * @returns the current particle system
  71956. */
  71957. removeLifeTimeGradient(gradient: number): IParticleSystem;
  71958. /**
  71959. * Adds a new size gradient
  71960. * @param gradient defines the gradient to use (between 0 and 1)
  71961. * @param factor defines the size factor to affect to the specified gradient
  71962. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  71963. * @returns the current particle system
  71964. */
  71965. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  71966. /**
  71967. * Remove a specific size gradient
  71968. * @param gradient defines the gradient to remove
  71969. * @returns the current particle system
  71970. */
  71971. removeSizeGradient(gradient: number): IParticleSystem;
  71972. /**
  71973. * Adds a new color remap gradient
  71974. * @param gradient defines the gradient to use (between 0 and 1)
  71975. * @param min defines the color remap minimal range
  71976. * @param max defines the color remap maximal range
  71977. * @returns the current particle system
  71978. */
  71979. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  71980. /**
  71981. * Remove a specific color remap gradient
  71982. * @param gradient defines the gradient to remove
  71983. * @returns the current particle system
  71984. */
  71985. removeColorRemapGradient(gradient: number): IParticleSystem;
  71986. /**
  71987. * Adds a new alpha remap gradient
  71988. * @param gradient defines the gradient to use (between 0 and 1)
  71989. * @param min defines the alpha remap minimal range
  71990. * @param max defines the alpha remap maximal range
  71991. * @returns the current particle system
  71992. */
  71993. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  71994. /**
  71995. * Remove a specific alpha remap gradient
  71996. * @param gradient defines the gradient to remove
  71997. * @returns the current particle system
  71998. */
  71999. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  72000. /**
  72001. * Adds a new angular speed gradient
  72002. * @param gradient defines the gradient to use (between 0 and 1)
  72003. * @param factor defines the angular speed to affect to the specified gradient
  72004. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72005. * @returns the current particle system
  72006. */
  72007. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72008. /**
  72009. * Remove a specific angular speed gradient
  72010. * @param gradient defines the gradient to remove
  72011. * @returns the current particle system
  72012. */
  72013. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  72014. /**
  72015. * Adds a new velocity gradient
  72016. * @param gradient defines the gradient to use (between 0 and 1)
  72017. * @param factor defines the velocity to affect to the specified gradient
  72018. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72019. * @returns the current particle system
  72020. */
  72021. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72022. /**
  72023. * Remove a specific velocity gradient
  72024. * @param gradient defines the gradient to remove
  72025. * @returns the current particle system
  72026. */
  72027. removeVelocityGradient(gradient: number): IParticleSystem;
  72028. /**
  72029. * Adds a new limit velocity gradient
  72030. * @param gradient defines the gradient to use (between 0 and 1)
  72031. * @param factor defines the limit velocity value to affect to the specified gradient
  72032. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72033. * @returns the current particle system
  72034. */
  72035. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72036. /**
  72037. * Remove a specific limit velocity gradient
  72038. * @param gradient defines the gradient to remove
  72039. * @returns the current particle system
  72040. */
  72041. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  72042. /**
  72043. * Adds a new drag gradient
  72044. * @param gradient defines the gradient to use (between 0 and 1)
  72045. * @param factor defines the drag value to affect to the specified gradient
  72046. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72047. * @returns the current particle system
  72048. */
  72049. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72050. /**
  72051. * Remove a specific drag gradient
  72052. * @param gradient defines the gradient to remove
  72053. * @returns the current particle system
  72054. */
  72055. removeDragGradient(gradient: number): IParticleSystem;
  72056. /**
  72057. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  72058. * @param gradient defines the gradient to use (between 0 and 1)
  72059. * @param factor defines the emit rate value to affect to the specified gradient
  72060. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72061. * @returns the current particle system
  72062. */
  72063. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72064. /**
  72065. * Remove a specific emit rate gradient
  72066. * @param gradient defines the gradient to remove
  72067. * @returns the current particle system
  72068. */
  72069. removeEmitRateGradient(gradient: number): IParticleSystem;
  72070. /**
  72071. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  72072. * @param gradient defines the gradient to use (between 0 and 1)
  72073. * @param factor defines the start size value to affect to the specified gradient
  72074. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72075. * @returns the current particle system
  72076. */
  72077. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72078. /**
  72079. * Remove a specific start size gradient
  72080. * @param gradient defines the gradient to remove
  72081. * @returns the current particle system
  72082. */
  72083. removeStartSizeGradient(gradient: number): IParticleSystem;
  72084. private _createRampGradientTexture;
  72085. /**
  72086. * Gets the current list of ramp gradients.
  72087. * You must use addRampGradient and removeRampGradient to udpate this list
  72088. * @returns the list of ramp gradients
  72089. */
  72090. getRampGradients(): Nullable<Array<Color3Gradient>>;
  72091. /**
  72092. * Adds a new ramp gradient used to remap particle colors
  72093. * @param gradient defines the gradient to use (between 0 and 1)
  72094. * @param color defines the color to affect to the specified gradient
  72095. * @returns the current particle system
  72096. */
  72097. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  72098. /**
  72099. * Remove a specific ramp gradient
  72100. * @param gradient defines the gradient to remove
  72101. * @returns the current particle system
  72102. */
  72103. removeRampGradient(gradient: number): ParticleSystem;
  72104. /**
  72105. * Adds a new color gradient
  72106. * @param gradient defines the gradient to use (between 0 and 1)
  72107. * @param color1 defines the color to affect to the specified gradient
  72108. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  72109. * @returns this particle system
  72110. */
  72111. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  72112. /**
  72113. * Remove a specific color gradient
  72114. * @param gradient defines the gradient to remove
  72115. * @returns this particle system
  72116. */
  72117. removeColorGradient(gradient: number): IParticleSystem;
  72118. private _fetchR;
  72119. protected _reset(): void;
  72120. private _resetEffect;
  72121. private _createVertexBuffers;
  72122. private _createIndexBuffer;
  72123. /**
  72124. * Gets the maximum number of particles active at the same time.
  72125. * @returns The max number of active particles.
  72126. */
  72127. getCapacity(): number;
  72128. /**
  72129. * Gets whether there are still active particles in the system.
  72130. * @returns True if it is alive, otherwise false.
  72131. */
  72132. isAlive(): boolean;
  72133. /**
  72134. * Gets if the system has been started. (Note: this will still be true after stop is called)
  72135. * @returns True if it has been started, otherwise false.
  72136. */
  72137. isStarted(): boolean;
  72138. private _prepareSubEmitterInternalArray;
  72139. /**
  72140. * Starts the particle system and begins to emit
  72141. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  72142. */
  72143. start(delay?: number): void;
  72144. /**
  72145. * Stops the particle system.
  72146. * @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.
  72147. */
  72148. stop(stopSubEmitters?: boolean): void;
  72149. /**
  72150. * Remove all active particles
  72151. */
  72152. reset(): void;
  72153. /**
  72154. * @hidden (for internal use only)
  72155. */
  72156. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  72157. /**
  72158. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  72159. * Its lifetime will start back at 0.
  72160. */
  72161. recycleParticle: (particle: Particle) => void;
  72162. private _stopSubEmitters;
  72163. private _createParticle;
  72164. private _removeFromRoot;
  72165. private _emitFromParticle;
  72166. private _update;
  72167. /** @hidden */
  72168. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  72169. /** @hidden */
  72170. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  72171. /** @hidden */
  72172. private _getEffect;
  72173. /**
  72174. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  72175. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  72176. */
  72177. animate(preWarmOnly?: boolean): void;
  72178. private _appendParticleVertices;
  72179. /**
  72180. * Rebuilds the particle system.
  72181. */
  72182. rebuild(): void;
  72183. /**
  72184. * Is this system ready to be used/rendered
  72185. * @return true if the system is ready
  72186. */
  72187. isReady(): boolean;
  72188. private _render;
  72189. /**
  72190. * Renders the particle system in its current state.
  72191. * @returns the current number of particles
  72192. */
  72193. render(): number;
  72194. /**
  72195. * Disposes the particle system and free the associated resources
  72196. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  72197. */
  72198. dispose(disposeTexture?: boolean): void;
  72199. /**
  72200. * Clones the particle system.
  72201. * @param name The name of the cloned object
  72202. * @param newEmitter The new emitter to use
  72203. * @returns the cloned particle system
  72204. */
  72205. clone(name: string, newEmitter: any): ParticleSystem;
  72206. /**
  72207. * Serializes the particle system to a JSON object.
  72208. * @returns the JSON object
  72209. */
  72210. serialize(): any;
  72211. /** @hidden */
  72212. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  72213. /** @hidden */
  72214. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  72215. /**
  72216. * Parses a JSON object to create a particle system.
  72217. * @param parsedParticleSystem The JSON object to parse
  72218. * @param scene The scene to create the particle system in
  72219. * @param rootUrl The root url to use to load external dependencies like texture
  72220. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  72221. * @returns the Parsed particle system
  72222. */
  72223. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  72224. }
  72225. }
  72226. declare module BABYLON {
  72227. /**
  72228. * A particle represents one of the element emitted by a particle system.
  72229. * This is mainly define by its coordinates, direction, velocity and age.
  72230. */
  72231. export class Particle {
  72232. /**
  72233. * The particle system the particle belongs to.
  72234. */
  72235. particleSystem: ParticleSystem;
  72236. private static _Count;
  72237. /**
  72238. * Unique ID of the particle
  72239. */
  72240. id: number;
  72241. /**
  72242. * The world position of the particle in the scene.
  72243. */
  72244. position: Vector3;
  72245. /**
  72246. * The world direction of the particle in the scene.
  72247. */
  72248. direction: Vector3;
  72249. /**
  72250. * The color of the particle.
  72251. */
  72252. color: Color4;
  72253. /**
  72254. * The color change of the particle per step.
  72255. */
  72256. colorStep: Color4;
  72257. /**
  72258. * Defines how long will the life of the particle be.
  72259. */
  72260. lifeTime: number;
  72261. /**
  72262. * The current age of the particle.
  72263. */
  72264. age: number;
  72265. /**
  72266. * The current size of the particle.
  72267. */
  72268. size: number;
  72269. /**
  72270. * The current scale of the particle.
  72271. */
  72272. scale: Vector2;
  72273. /**
  72274. * The current angle of the particle.
  72275. */
  72276. angle: number;
  72277. /**
  72278. * Defines how fast is the angle changing.
  72279. */
  72280. angularSpeed: number;
  72281. /**
  72282. * Defines the cell index used by the particle to be rendered from a sprite.
  72283. */
  72284. cellIndex: number;
  72285. /**
  72286. * The information required to support color remapping
  72287. */
  72288. remapData: Vector4;
  72289. /** @hidden */
  72290. _randomCellOffset?: number;
  72291. /** @hidden */
  72292. _initialDirection: Nullable<Vector3>;
  72293. /** @hidden */
  72294. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  72295. /** @hidden */
  72296. _initialStartSpriteCellID: number;
  72297. /** @hidden */
  72298. _initialEndSpriteCellID: number;
  72299. /** @hidden */
  72300. _currentColorGradient: Nullable<ColorGradient>;
  72301. /** @hidden */
  72302. _currentColor1: Color4;
  72303. /** @hidden */
  72304. _currentColor2: Color4;
  72305. /** @hidden */
  72306. _currentSizeGradient: Nullable<FactorGradient>;
  72307. /** @hidden */
  72308. _currentSize1: number;
  72309. /** @hidden */
  72310. _currentSize2: number;
  72311. /** @hidden */
  72312. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  72313. /** @hidden */
  72314. _currentAngularSpeed1: number;
  72315. /** @hidden */
  72316. _currentAngularSpeed2: number;
  72317. /** @hidden */
  72318. _currentVelocityGradient: Nullable<FactorGradient>;
  72319. /** @hidden */
  72320. _currentVelocity1: number;
  72321. /** @hidden */
  72322. _currentVelocity2: number;
  72323. /** @hidden */
  72324. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  72325. /** @hidden */
  72326. _currentLimitVelocity1: number;
  72327. /** @hidden */
  72328. _currentLimitVelocity2: number;
  72329. /** @hidden */
  72330. _currentDragGradient: Nullable<FactorGradient>;
  72331. /** @hidden */
  72332. _currentDrag1: number;
  72333. /** @hidden */
  72334. _currentDrag2: number;
  72335. /** @hidden */
  72336. _randomNoiseCoordinates1: Vector3;
  72337. /** @hidden */
  72338. _randomNoiseCoordinates2: Vector3;
  72339. /**
  72340. * Creates a new instance Particle
  72341. * @param particleSystem the particle system the particle belongs to
  72342. */
  72343. constructor(
  72344. /**
  72345. * The particle system the particle belongs to.
  72346. */
  72347. particleSystem: ParticleSystem);
  72348. private updateCellInfoFromSystem;
  72349. /**
  72350. * Defines how the sprite cell index is updated for the particle
  72351. */
  72352. updateCellIndex(): void;
  72353. /** @hidden */
  72354. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  72355. /** @hidden */
  72356. _inheritParticleInfoToSubEmitters(): void;
  72357. /** @hidden */
  72358. _reset(): void;
  72359. /**
  72360. * Copy the properties of particle to another one.
  72361. * @param other the particle to copy the information to.
  72362. */
  72363. copyTo(other: Particle): void;
  72364. }
  72365. }
  72366. declare module BABYLON {
  72367. /**
  72368. * Particle emitter represents a volume emitting particles.
  72369. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  72370. */
  72371. export interface IParticleEmitterType {
  72372. /**
  72373. * Called by the particle System when the direction is computed for the created particle.
  72374. * @param worldMatrix is the world matrix of the particle system
  72375. * @param directionToUpdate is the direction vector to update with the result
  72376. * @param particle is the particle we are computed the direction for
  72377. */
  72378. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  72379. /**
  72380. * Called by the particle System when the position is computed for the created particle.
  72381. * @param worldMatrix is the world matrix of the particle system
  72382. * @param positionToUpdate is the position vector to update with the result
  72383. * @param particle is the particle we are computed the position for
  72384. */
  72385. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  72386. /**
  72387. * Clones the current emitter and returns a copy of it
  72388. * @returns the new emitter
  72389. */
  72390. clone(): IParticleEmitterType;
  72391. /**
  72392. * Called by the GPUParticleSystem to setup the update shader
  72393. * @param effect defines the update shader
  72394. */
  72395. applyToShader(effect: Effect): void;
  72396. /**
  72397. * Returns a string to use to update the GPU particles update shader
  72398. * @returns the effect defines string
  72399. */
  72400. getEffectDefines(): string;
  72401. /**
  72402. * Returns a string representing the class name
  72403. * @returns a string containing the class name
  72404. */
  72405. getClassName(): string;
  72406. /**
  72407. * Serializes the particle system to a JSON object.
  72408. * @returns the JSON object
  72409. */
  72410. serialize(): any;
  72411. /**
  72412. * Parse properties from a JSON object
  72413. * @param serializationObject defines the JSON object
  72414. */
  72415. parse(serializationObject: any): void;
  72416. }
  72417. }
  72418. declare module BABYLON {
  72419. /**
  72420. * Particle emitter emitting particles from the inside of a box.
  72421. * It emits the particles randomly between 2 given directions.
  72422. */
  72423. export class BoxParticleEmitter implements IParticleEmitterType {
  72424. /**
  72425. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  72426. */
  72427. direction1: Vector3;
  72428. /**
  72429. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  72430. */
  72431. direction2: Vector3;
  72432. /**
  72433. * 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.
  72434. */
  72435. minEmitBox: Vector3;
  72436. /**
  72437. * 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.
  72438. */
  72439. maxEmitBox: Vector3;
  72440. /**
  72441. * Creates a new instance BoxParticleEmitter
  72442. */
  72443. constructor();
  72444. /**
  72445. * Called by the particle System when the direction is computed for the created particle.
  72446. * @param worldMatrix is the world matrix of the particle system
  72447. * @param directionToUpdate is the direction vector to update with the result
  72448. * @param particle is the particle we are computed the direction for
  72449. */
  72450. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  72451. /**
  72452. * Called by the particle System when the position is computed for the created particle.
  72453. * @param worldMatrix is the world matrix of the particle system
  72454. * @param positionToUpdate is the position vector to update with the result
  72455. * @param particle is the particle we are computed the position for
  72456. */
  72457. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  72458. /**
  72459. * Clones the current emitter and returns a copy of it
  72460. * @returns the new emitter
  72461. */
  72462. clone(): BoxParticleEmitter;
  72463. /**
  72464. * Called by the GPUParticleSystem to setup the update shader
  72465. * @param effect defines the update shader
  72466. */
  72467. applyToShader(effect: Effect): void;
  72468. /**
  72469. * Returns a string to use to update the GPU particles update shader
  72470. * @returns a string containng the defines string
  72471. */
  72472. getEffectDefines(): string;
  72473. /**
  72474. * Returns the string "BoxParticleEmitter"
  72475. * @returns a string containing the class name
  72476. */
  72477. getClassName(): string;
  72478. /**
  72479. * Serializes the particle system to a JSON object.
  72480. * @returns the JSON object
  72481. */
  72482. serialize(): any;
  72483. /**
  72484. * Parse properties from a JSON object
  72485. * @param serializationObject defines the JSON object
  72486. */
  72487. parse(serializationObject: any): void;
  72488. }
  72489. }
  72490. declare module BABYLON {
  72491. /**
  72492. * Particle emitter emitting particles from the inside of a cone.
  72493. * It emits the particles alongside the cone volume from the base to the particle.
  72494. * The emission direction might be randomized.
  72495. */
  72496. export class ConeParticleEmitter implements IParticleEmitterType {
  72497. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  72498. directionRandomizer: number;
  72499. private _radius;
  72500. private _angle;
  72501. private _height;
  72502. /**
  72503. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  72504. */
  72505. radiusRange: number;
  72506. /**
  72507. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  72508. */
  72509. heightRange: number;
  72510. /**
  72511. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  72512. */
  72513. emitFromSpawnPointOnly: boolean;
  72514. /**
  72515. * Gets or sets the radius of the emission cone
  72516. */
  72517. radius: number;
  72518. /**
  72519. * Gets or sets the angle of the emission cone
  72520. */
  72521. angle: number;
  72522. private _buildHeight;
  72523. /**
  72524. * Creates a new instance ConeParticleEmitter
  72525. * @param radius the radius of the emission cone (1 by default)
  72526. * @param angle the cone base angle (PI by default)
  72527. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  72528. */
  72529. constructor(radius?: number, angle?: number,
  72530. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  72531. directionRandomizer?: number);
  72532. /**
  72533. * Called by the particle System when the direction is computed for the created particle.
  72534. * @param worldMatrix is the world matrix of the particle system
  72535. * @param directionToUpdate is the direction vector to update with the result
  72536. * @param particle is the particle we are computed the direction for
  72537. */
  72538. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  72539. /**
  72540. * Called by the particle System when the position is computed for the created particle.
  72541. * @param worldMatrix is the world matrix of the particle system
  72542. * @param positionToUpdate is the position vector to update with the result
  72543. * @param particle is the particle we are computed the position for
  72544. */
  72545. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  72546. /**
  72547. * Clones the current emitter and returns a copy of it
  72548. * @returns the new emitter
  72549. */
  72550. clone(): ConeParticleEmitter;
  72551. /**
  72552. * Called by the GPUParticleSystem to setup the update shader
  72553. * @param effect defines the update shader
  72554. */
  72555. applyToShader(effect: Effect): void;
  72556. /**
  72557. * Returns a string to use to update the GPU particles update shader
  72558. * @returns a string containng the defines string
  72559. */
  72560. getEffectDefines(): string;
  72561. /**
  72562. * Returns the string "ConeParticleEmitter"
  72563. * @returns a string containing the class name
  72564. */
  72565. getClassName(): string;
  72566. /**
  72567. * Serializes the particle system to a JSON object.
  72568. * @returns the JSON object
  72569. */
  72570. serialize(): any;
  72571. /**
  72572. * Parse properties from a JSON object
  72573. * @param serializationObject defines the JSON object
  72574. */
  72575. parse(serializationObject: any): void;
  72576. }
  72577. }
  72578. declare module BABYLON {
  72579. /**
  72580. * Particle emitter emitting particles from the inside of a cylinder.
  72581. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  72582. */
  72583. export class CylinderParticleEmitter implements IParticleEmitterType {
  72584. /**
  72585. * The radius of the emission cylinder.
  72586. */
  72587. radius: number;
  72588. /**
  72589. * The height of the emission cylinder.
  72590. */
  72591. height: number;
  72592. /**
  72593. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  72594. */
  72595. radiusRange: number;
  72596. /**
  72597. * How much to randomize the particle direction [0-1].
  72598. */
  72599. directionRandomizer: number;
  72600. /**
  72601. * Creates a new instance CylinderParticleEmitter
  72602. * @param radius the radius of the emission cylinder (1 by default)
  72603. * @param height the height of the emission cylinder (1 by default)
  72604. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  72605. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  72606. */
  72607. constructor(
  72608. /**
  72609. * The radius of the emission cylinder.
  72610. */
  72611. radius?: number,
  72612. /**
  72613. * The height of the emission cylinder.
  72614. */
  72615. height?: number,
  72616. /**
  72617. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  72618. */
  72619. radiusRange?: number,
  72620. /**
  72621. * How much to randomize the particle direction [0-1].
  72622. */
  72623. directionRandomizer?: number);
  72624. /**
  72625. * Called by the particle System when the direction is computed for the created particle.
  72626. * @param worldMatrix is the world matrix of the particle system
  72627. * @param directionToUpdate is the direction vector to update with the result
  72628. * @param particle is the particle we are computed the direction for
  72629. */
  72630. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  72631. /**
  72632. * Called by the particle System when the position is computed for the created particle.
  72633. * @param worldMatrix is the world matrix of the particle system
  72634. * @param positionToUpdate is the position vector to update with the result
  72635. * @param particle is the particle we are computed the position for
  72636. */
  72637. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  72638. /**
  72639. * Clones the current emitter and returns a copy of it
  72640. * @returns the new emitter
  72641. */
  72642. clone(): CylinderParticleEmitter;
  72643. /**
  72644. * Called by the GPUParticleSystem to setup the update shader
  72645. * @param effect defines the update shader
  72646. */
  72647. applyToShader(effect: Effect): void;
  72648. /**
  72649. * Returns a string to use to update the GPU particles update shader
  72650. * @returns a string containng the defines string
  72651. */
  72652. getEffectDefines(): string;
  72653. /**
  72654. * Returns the string "CylinderParticleEmitter"
  72655. * @returns a string containing the class name
  72656. */
  72657. getClassName(): string;
  72658. /**
  72659. * Serializes the particle system to a JSON object.
  72660. * @returns the JSON object
  72661. */
  72662. serialize(): any;
  72663. /**
  72664. * Parse properties from a JSON object
  72665. * @param serializationObject defines the JSON object
  72666. */
  72667. parse(serializationObject: any): void;
  72668. }
  72669. /**
  72670. * Particle emitter emitting particles from the inside of a cylinder.
  72671. * It emits the particles randomly between two vectors.
  72672. */
  72673. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  72674. /**
  72675. * The min limit of the emission direction.
  72676. */
  72677. direction1: Vector3;
  72678. /**
  72679. * The max limit of the emission direction.
  72680. */
  72681. direction2: Vector3;
  72682. /**
  72683. * Creates a new instance CylinderDirectedParticleEmitter
  72684. * @param radius the radius of the emission cylinder (1 by default)
  72685. * @param height the height of the emission cylinder (1 by default)
  72686. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  72687. * @param direction1 the min limit of the emission direction (up vector by default)
  72688. * @param direction2 the max limit of the emission direction (up vector by default)
  72689. */
  72690. constructor(radius?: number, height?: number, radiusRange?: number,
  72691. /**
  72692. * The min limit of the emission direction.
  72693. */
  72694. direction1?: Vector3,
  72695. /**
  72696. * The max limit of the emission direction.
  72697. */
  72698. direction2?: Vector3);
  72699. /**
  72700. * Called by the particle System when the direction is computed for the created particle.
  72701. * @param worldMatrix is the world matrix of the particle system
  72702. * @param directionToUpdate is the direction vector to update with the result
  72703. * @param particle is the particle we are computed the direction for
  72704. */
  72705. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  72706. /**
  72707. * Clones the current emitter and returns a copy of it
  72708. * @returns the new emitter
  72709. */
  72710. clone(): CylinderDirectedParticleEmitter;
  72711. /**
  72712. * Called by the GPUParticleSystem to setup the update shader
  72713. * @param effect defines the update shader
  72714. */
  72715. applyToShader(effect: Effect): void;
  72716. /**
  72717. * Returns a string to use to update the GPU particles update shader
  72718. * @returns a string containng the defines string
  72719. */
  72720. getEffectDefines(): string;
  72721. /**
  72722. * Returns the string "CylinderDirectedParticleEmitter"
  72723. * @returns a string containing the class name
  72724. */
  72725. getClassName(): string;
  72726. /**
  72727. * Serializes the particle system to a JSON object.
  72728. * @returns the JSON object
  72729. */
  72730. serialize(): any;
  72731. /**
  72732. * Parse properties from a JSON object
  72733. * @param serializationObject defines the JSON object
  72734. */
  72735. parse(serializationObject: any): void;
  72736. }
  72737. }
  72738. declare module BABYLON {
  72739. /**
  72740. * Particle emitter emitting particles from the inside of a hemisphere.
  72741. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  72742. */
  72743. export class HemisphericParticleEmitter implements IParticleEmitterType {
  72744. /**
  72745. * The radius of the emission hemisphere.
  72746. */
  72747. radius: number;
  72748. /**
  72749. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  72750. */
  72751. radiusRange: number;
  72752. /**
  72753. * How much to randomize the particle direction [0-1].
  72754. */
  72755. directionRandomizer: number;
  72756. /**
  72757. * Creates a new instance HemisphericParticleEmitter
  72758. * @param radius the radius of the emission hemisphere (1 by default)
  72759. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  72760. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  72761. */
  72762. constructor(
  72763. /**
  72764. * The radius of the emission hemisphere.
  72765. */
  72766. radius?: number,
  72767. /**
  72768. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  72769. */
  72770. radiusRange?: number,
  72771. /**
  72772. * How much to randomize the particle direction [0-1].
  72773. */
  72774. directionRandomizer?: number);
  72775. /**
  72776. * Called by the particle System when the direction is computed for the created particle.
  72777. * @param worldMatrix is the world matrix of the particle system
  72778. * @param directionToUpdate is the direction vector to update with the result
  72779. * @param particle is the particle we are computed the direction for
  72780. */
  72781. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  72782. /**
  72783. * Called by the particle System when the position is computed for the created particle.
  72784. * @param worldMatrix is the world matrix of the particle system
  72785. * @param positionToUpdate is the position vector to update with the result
  72786. * @param particle is the particle we are computed the position for
  72787. */
  72788. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  72789. /**
  72790. * Clones the current emitter and returns a copy of it
  72791. * @returns the new emitter
  72792. */
  72793. clone(): HemisphericParticleEmitter;
  72794. /**
  72795. * Called by the GPUParticleSystem to setup the update shader
  72796. * @param effect defines the update shader
  72797. */
  72798. applyToShader(effect: Effect): void;
  72799. /**
  72800. * Returns a string to use to update the GPU particles update shader
  72801. * @returns a string containng the defines string
  72802. */
  72803. getEffectDefines(): string;
  72804. /**
  72805. * Returns the string "HemisphericParticleEmitter"
  72806. * @returns a string containing the class name
  72807. */
  72808. getClassName(): string;
  72809. /**
  72810. * Serializes the particle system to a JSON object.
  72811. * @returns the JSON object
  72812. */
  72813. serialize(): any;
  72814. /**
  72815. * Parse properties from a JSON object
  72816. * @param serializationObject defines the JSON object
  72817. */
  72818. parse(serializationObject: any): void;
  72819. }
  72820. }
  72821. declare module BABYLON {
  72822. /**
  72823. * Particle emitter emitting particles from a point.
  72824. * It emits the particles randomly between 2 given directions.
  72825. */
  72826. export class PointParticleEmitter implements IParticleEmitterType {
  72827. /**
  72828. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  72829. */
  72830. direction1: Vector3;
  72831. /**
  72832. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  72833. */
  72834. direction2: Vector3;
  72835. /**
  72836. * Creates a new instance PointParticleEmitter
  72837. */
  72838. constructor();
  72839. /**
  72840. * Called by the particle System when the direction is computed for the created particle.
  72841. * @param worldMatrix is the world matrix of the particle system
  72842. * @param directionToUpdate is the direction vector to update with the result
  72843. * @param particle is the particle we are computed the direction for
  72844. */
  72845. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  72846. /**
  72847. * Called by the particle System when the position is computed for the created particle.
  72848. * @param worldMatrix is the world matrix of the particle system
  72849. * @param positionToUpdate is the position vector to update with the result
  72850. * @param particle is the particle we are computed the position for
  72851. */
  72852. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  72853. /**
  72854. * Clones the current emitter and returns a copy of it
  72855. * @returns the new emitter
  72856. */
  72857. clone(): PointParticleEmitter;
  72858. /**
  72859. * Called by the GPUParticleSystem to setup the update shader
  72860. * @param effect defines the update shader
  72861. */
  72862. applyToShader(effect: Effect): void;
  72863. /**
  72864. * Returns a string to use to update the GPU particles update shader
  72865. * @returns a string containng the defines string
  72866. */
  72867. getEffectDefines(): string;
  72868. /**
  72869. * Returns the string "PointParticleEmitter"
  72870. * @returns a string containing the class name
  72871. */
  72872. getClassName(): string;
  72873. /**
  72874. * Serializes the particle system to a JSON object.
  72875. * @returns the JSON object
  72876. */
  72877. serialize(): any;
  72878. /**
  72879. * Parse properties from a JSON object
  72880. * @param serializationObject defines the JSON object
  72881. */
  72882. parse(serializationObject: any): void;
  72883. }
  72884. }
  72885. declare module BABYLON {
  72886. /**
  72887. * Particle emitter emitting particles from the inside of a sphere.
  72888. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  72889. */
  72890. export class SphereParticleEmitter implements IParticleEmitterType {
  72891. /**
  72892. * The radius of the emission sphere.
  72893. */
  72894. radius: number;
  72895. /**
  72896. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  72897. */
  72898. radiusRange: number;
  72899. /**
  72900. * How much to randomize the particle direction [0-1].
  72901. */
  72902. directionRandomizer: number;
  72903. /**
  72904. * Creates a new instance SphereParticleEmitter
  72905. * @param radius the radius of the emission sphere (1 by default)
  72906. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  72907. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  72908. */
  72909. constructor(
  72910. /**
  72911. * The radius of the emission sphere.
  72912. */
  72913. radius?: number,
  72914. /**
  72915. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  72916. */
  72917. radiusRange?: number,
  72918. /**
  72919. * How much to randomize the particle direction [0-1].
  72920. */
  72921. directionRandomizer?: number);
  72922. /**
  72923. * Called by the particle System when the direction is computed for the created particle.
  72924. * @param worldMatrix is the world matrix of the particle system
  72925. * @param directionToUpdate is the direction vector to update with the result
  72926. * @param particle is the particle we are computed the direction for
  72927. */
  72928. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  72929. /**
  72930. * Called by the particle System when the position is computed for the created particle.
  72931. * @param worldMatrix is the world matrix of the particle system
  72932. * @param positionToUpdate is the position vector to update with the result
  72933. * @param particle is the particle we are computed the position for
  72934. */
  72935. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  72936. /**
  72937. * Clones the current emitter and returns a copy of it
  72938. * @returns the new emitter
  72939. */
  72940. clone(): SphereParticleEmitter;
  72941. /**
  72942. * Called by the GPUParticleSystem to setup the update shader
  72943. * @param effect defines the update shader
  72944. */
  72945. applyToShader(effect: Effect): void;
  72946. /**
  72947. * Returns a string to use to update the GPU particles update shader
  72948. * @returns a string containng the defines string
  72949. */
  72950. getEffectDefines(): string;
  72951. /**
  72952. * Returns the string "SphereParticleEmitter"
  72953. * @returns a string containing the class name
  72954. */
  72955. getClassName(): string;
  72956. /**
  72957. * Serializes the particle system to a JSON object.
  72958. * @returns the JSON object
  72959. */
  72960. serialize(): any;
  72961. /**
  72962. * Parse properties from a JSON object
  72963. * @param serializationObject defines the JSON object
  72964. */
  72965. parse(serializationObject: any): void;
  72966. }
  72967. /**
  72968. * Particle emitter emitting particles from the inside of a sphere.
  72969. * It emits the particles randomly between two vectors.
  72970. */
  72971. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  72972. /**
  72973. * The min limit of the emission direction.
  72974. */
  72975. direction1: Vector3;
  72976. /**
  72977. * The max limit of the emission direction.
  72978. */
  72979. direction2: Vector3;
  72980. /**
  72981. * Creates a new instance SphereDirectedParticleEmitter
  72982. * @param radius the radius of the emission sphere (1 by default)
  72983. * @param direction1 the min limit of the emission direction (up vector by default)
  72984. * @param direction2 the max limit of the emission direction (up vector by default)
  72985. */
  72986. constructor(radius?: number,
  72987. /**
  72988. * The min limit of the emission direction.
  72989. */
  72990. direction1?: Vector3,
  72991. /**
  72992. * The max limit of the emission direction.
  72993. */
  72994. direction2?: Vector3);
  72995. /**
  72996. * Called by the particle System when the direction is computed for the created particle.
  72997. * @param worldMatrix is the world matrix of the particle system
  72998. * @param directionToUpdate is the direction vector to update with the result
  72999. * @param particle is the particle we are computed the direction for
  73000. */
  73001. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  73002. /**
  73003. * Clones the current emitter and returns a copy of it
  73004. * @returns the new emitter
  73005. */
  73006. clone(): SphereDirectedParticleEmitter;
  73007. /**
  73008. * Called by the GPUParticleSystem to setup the update shader
  73009. * @param effect defines the update shader
  73010. */
  73011. applyToShader(effect: Effect): void;
  73012. /**
  73013. * Returns a string to use to update the GPU particles update shader
  73014. * @returns a string containng the defines string
  73015. */
  73016. getEffectDefines(): string;
  73017. /**
  73018. * Returns the string "SphereDirectedParticleEmitter"
  73019. * @returns a string containing the class name
  73020. */
  73021. getClassName(): string;
  73022. /**
  73023. * Serializes the particle system to a JSON object.
  73024. * @returns the JSON object
  73025. */
  73026. serialize(): any;
  73027. /**
  73028. * Parse properties from a JSON object
  73029. * @param serializationObject defines the JSON object
  73030. */
  73031. parse(serializationObject: any): void;
  73032. }
  73033. }
  73034. declare module BABYLON {
  73035. /**
  73036. * Interface representing a particle system in Babylon.js.
  73037. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  73038. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  73039. */
  73040. export interface IParticleSystem {
  73041. /**
  73042. * List of animations used by the particle system.
  73043. */
  73044. animations: Animation[];
  73045. /**
  73046. * The id of the Particle system.
  73047. */
  73048. id: string;
  73049. /**
  73050. * The name of the Particle system.
  73051. */
  73052. name: string;
  73053. /**
  73054. * The emitter represents the Mesh or position we are attaching the particle system to.
  73055. */
  73056. emitter: Nullable<AbstractMesh | Vector3>;
  73057. /**
  73058. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  73059. */
  73060. isBillboardBased: boolean;
  73061. /**
  73062. * The rendering group used by the Particle system to chose when to render.
  73063. */
  73064. renderingGroupId: number;
  73065. /**
  73066. * The layer mask we are rendering the particles through.
  73067. */
  73068. layerMask: number;
  73069. /**
  73070. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  73071. */
  73072. updateSpeed: number;
  73073. /**
  73074. * The amount of time the particle system is running (depends of the overall update speed).
  73075. */
  73076. targetStopDuration: number;
  73077. /**
  73078. * The texture used to render each particle. (this can be a spritesheet)
  73079. */
  73080. particleTexture: Nullable<Texture>;
  73081. /**
  73082. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  73083. */
  73084. blendMode: number;
  73085. /**
  73086. * Minimum life time of emitting particles.
  73087. */
  73088. minLifeTime: number;
  73089. /**
  73090. * Maximum life time of emitting particles.
  73091. */
  73092. maxLifeTime: number;
  73093. /**
  73094. * Minimum Size of emitting particles.
  73095. */
  73096. minSize: number;
  73097. /**
  73098. * Maximum Size of emitting particles.
  73099. */
  73100. maxSize: number;
  73101. /**
  73102. * Minimum scale of emitting particles on X axis.
  73103. */
  73104. minScaleX: number;
  73105. /**
  73106. * Maximum scale of emitting particles on X axis.
  73107. */
  73108. maxScaleX: number;
  73109. /**
  73110. * Minimum scale of emitting particles on Y axis.
  73111. */
  73112. minScaleY: number;
  73113. /**
  73114. * Maximum scale of emitting particles on Y axis.
  73115. */
  73116. maxScaleY: number;
  73117. /**
  73118. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  73119. */
  73120. color1: Color4;
  73121. /**
  73122. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  73123. */
  73124. color2: Color4;
  73125. /**
  73126. * Color the particle will have at the end of its lifetime.
  73127. */
  73128. colorDead: Color4;
  73129. /**
  73130. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  73131. */
  73132. emitRate: number;
  73133. /**
  73134. * You can use gravity if you want to give an orientation to your particles.
  73135. */
  73136. gravity: Vector3;
  73137. /**
  73138. * Minimum power of emitting particles.
  73139. */
  73140. minEmitPower: number;
  73141. /**
  73142. * Maximum power of emitting particles.
  73143. */
  73144. maxEmitPower: number;
  73145. /**
  73146. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  73147. */
  73148. minAngularSpeed: number;
  73149. /**
  73150. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  73151. */
  73152. maxAngularSpeed: number;
  73153. /**
  73154. * Gets or sets the minimal initial rotation in radians.
  73155. */
  73156. minInitialRotation: number;
  73157. /**
  73158. * Gets or sets the maximal initial rotation in radians.
  73159. */
  73160. maxInitialRotation: number;
  73161. /**
  73162. * The particle emitter type defines the emitter used by the particle system.
  73163. * It can be for example box, sphere, or cone...
  73164. */
  73165. particleEmitterType: Nullable<IParticleEmitterType>;
  73166. /**
  73167. * Defines the delay in milliseconds before starting the system (0 by default)
  73168. */
  73169. startDelay: number;
  73170. /**
  73171. * 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
  73172. */
  73173. preWarmCycles: number;
  73174. /**
  73175. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  73176. */
  73177. preWarmStepOffset: number;
  73178. /**
  73179. * 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)
  73180. */
  73181. spriteCellChangeSpeed: number;
  73182. /**
  73183. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  73184. */
  73185. startSpriteCellID: number;
  73186. /**
  73187. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  73188. */
  73189. endSpriteCellID: number;
  73190. /**
  73191. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  73192. */
  73193. spriteCellWidth: number;
  73194. /**
  73195. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  73196. */
  73197. spriteCellHeight: number;
  73198. /**
  73199. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  73200. */
  73201. spriteRandomStartCell: boolean;
  73202. /**
  73203. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  73204. */
  73205. isAnimationSheetEnabled: boolean;
  73206. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  73207. translationPivot: Vector2;
  73208. /**
  73209. * Gets or sets a texture used to add random noise to particle positions
  73210. */
  73211. noiseTexture: Nullable<BaseTexture>;
  73212. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  73213. noiseStrength: Vector3;
  73214. /**
  73215. * Gets or sets the billboard mode to use when isBillboardBased = true.
  73216. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  73217. */
  73218. billboardMode: number;
  73219. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  73220. limitVelocityDamping: number;
  73221. /**
  73222. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  73223. */
  73224. beginAnimationOnStart: boolean;
  73225. /**
  73226. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  73227. */
  73228. beginAnimationFrom: number;
  73229. /**
  73230. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  73231. */
  73232. beginAnimationTo: number;
  73233. /**
  73234. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  73235. */
  73236. beginAnimationLoop: boolean;
  73237. /**
  73238. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  73239. */
  73240. disposeOnStop: boolean;
  73241. /**
  73242. * Gets the maximum number of particles active at the same time.
  73243. * @returns The max number of active particles.
  73244. */
  73245. getCapacity(): number;
  73246. /**
  73247. * Gets if the system has been started. (Note: this will still be true after stop is called)
  73248. * @returns True if it has been started, otherwise false.
  73249. */
  73250. isStarted(): boolean;
  73251. /**
  73252. * Animates the particle system for this frame.
  73253. */
  73254. animate(): void;
  73255. /**
  73256. * Renders the particle system in its current state.
  73257. * @returns the current number of particles
  73258. */
  73259. render(): number;
  73260. /**
  73261. * Dispose the particle system and frees its associated resources.
  73262. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  73263. */
  73264. dispose(disposeTexture?: boolean): void;
  73265. /**
  73266. * Clones the particle system.
  73267. * @param name The name of the cloned object
  73268. * @param newEmitter The new emitter to use
  73269. * @returns the cloned particle system
  73270. */
  73271. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  73272. /**
  73273. * Serializes the particle system to a JSON object.
  73274. * @returns the JSON object
  73275. */
  73276. serialize(): any;
  73277. /**
  73278. * Rebuild the particle system
  73279. */
  73280. rebuild(): void;
  73281. /**
  73282. * Starts the particle system and begins to emit
  73283. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  73284. */
  73285. start(delay?: number): void;
  73286. /**
  73287. * Stops the particle system.
  73288. */
  73289. stop(): void;
  73290. /**
  73291. * Remove all active particles
  73292. */
  73293. reset(): void;
  73294. /**
  73295. * Is this system ready to be used/rendered
  73296. * @return true if the system is ready
  73297. */
  73298. isReady(): boolean;
  73299. /**
  73300. * Adds a new color gradient
  73301. * @param gradient defines the gradient to use (between 0 and 1)
  73302. * @param color1 defines the color to affect to the specified gradient
  73303. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  73304. * @returns the current particle system
  73305. */
  73306. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  73307. /**
  73308. * Remove a specific color gradient
  73309. * @param gradient defines the gradient to remove
  73310. * @returns the current particle system
  73311. */
  73312. removeColorGradient(gradient: number): IParticleSystem;
  73313. /**
  73314. * Adds a new size gradient
  73315. * @param gradient defines the gradient to use (between 0 and 1)
  73316. * @param factor defines the size factor to affect to the specified gradient
  73317. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73318. * @returns the current particle system
  73319. */
  73320. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73321. /**
  73322. * Remove a specific size gradient
  73323. * @param gradient defines the gradient to remove
  73324. * @returns the current particle system
  73325. */
  73326. removeSizeGradient(gradient: number): IParticleSystem;
  73327. /**
  73328. * Gets the current list of color gradients.
  73329. * You must use addColorGradient and removeColorGradient to udpate this list
  73330. * @returns the list of color gradients
  73331. */
  73332. getColorGradients(): Nullable<Array<ColorGradient>>;
  73333. /**
  73334. * Gets the current list of size gradients.
  73335. * You must use addSizeGradient and removeSizeGradient to udpate this list
  73336. * @returns the list of size gradients
  73337. */
  73338. getSizeGradients(): Nullable<Array<FactorGradient>>;
  73339. /**
  73340. * Gets the current list of angular speed gradients.
  73341. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  73342. * @returns the list of angular speed gradients
  73343. */
  73344. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  73345. /**
  73346. * Adds a new angular speed gradient
  73347. * @param gradient defines the gradient to use (between 0 and 1)
  73348. * @param factor defines the angular speed to affect to the specified gradient
  73349. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73350. * @returns the current particle system
  73351. */
  73352. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73353. /**
  73354. * Remove a specific angular speed gradient
  73355. * @param gradient defines the gradient to remove
  73356. * @returns the current particle system
  73357. */
  73358. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  73359. /**
  73360. * Gets the current list of velocity gradients.
  73361. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  73362. * @returns the list of velocity gradients
  73363. */
  73364. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  73365. /**
  73366. * Adds a new velocity gradient
  73367. * @param gradient defines the gradient to use (between 0 and 1)
  73368. * @param factor defines the velocity to affect to the specified gradient
  73369. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73370. * @returns the current particle system
  73371. */
  73372. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73373. /**
  73374. * Remove a specific velocity gradient
  73375. * @param gradient defines the gradient to remove
  73376. * @returns the current particle system
  73377. */
  73378. removeVelocityGradient(gradient: number): IParticleSystem;
  73379. /**
  73380. * Gets the current list of limit velocity gradients.
  73381. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  73382. * @returns the list of limit velocity gradients
  73383. */
  73384. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  73385. /**
  73386. * Adds a new limit velocity gradient
  73387. * @param gradient defines the gradient to use (between 0 and 1)
  73388. * @param factor defines the limit velocity to affect to the specified gradient
  73389. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73390. * @returns the current particle system
  73391. */
  73392. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73393. /**
  73394. * Remove a specific limit velocity gradient
  73395. * @param gradient defines the gradient to remove
  73396. * @returns the current particle system
  73397. */
  73398. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  73399. /**
  73400. * Adds a new drag gradient
  73401. * @param gradient defines the gradient to use (between 0 and 1)
  73402. * @param factor defines the drag to affect to the specified gradient
  73403. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73404. * @returns the current particle system
  73405. */
  73406. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73407. /**
  73408. * Remove a specific drag gradient
  73409. * @param gradient defines the gradient to remove
  73410. * @returns the current particle system
  73411. */
  73412. removeDragGradient(gradient: number): IParticleSystem;
  73413. /**
  73414. * Gets the current list of drag gradients.
  73415. * You must use addDragGradient and removeDragGradient to udpate this list
  73416. * @returns the list of drag gradients
  73417. */
  73418. getDragGradients(): Nullable<Array<FactorGradient>>;
  73419. /**
  73420. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  73421. * @param gradient defines the gradient to use (between 0 and 1)
  73422. * @param factor defines the emit rate to affect to the specified gradient
  73423. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73424. * @returns the current particle system
  73425. */
  73426. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73427. /**
  73428. * Remove a specific emit rate gradient
  73429. * @param gradient defines the gradient to remove
  73430. * @returns the current particle system
  73431. */
  73432. removeEmitRateGradient(gradient: number): IParticleSystem;
  73433. /**
  73434. * Gets the current list of emit rate gradients.
  73435. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  73436. * @returns the list of emit rate gradients
  73437. */
  73438. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  73439. /**
  73440. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  73441. * @param gradient defines the gradient to use (between 0 and 1)
  73442. * @param factor defines the start size to affect to the specified gradient
  73443. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73444. * @returns the current particle system
  73445. */
  73446. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73447. /**
  73448. * Remove a specific start size gradient
  73449. * @param gradient defines the gradient to remove
  73450. * @returns the current particle system
  73451. */
  73452. removeStartSizeGradient(gradient: number): IParticleSystem;
  73453. /**
  73454. * Gets the current list of start size gradients.
  73455. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  73456. * @returns the list of start size gradients
  73457. */
  73458. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  73459. /**
  73460. * Adds a new life time gradient
  73461. * @param gradient defines the gradient to use (between 0 and 1)
  73462. * @param factor defines the life time factor to affect to the specified gradient
  73463. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73464. * @returns the current particle system
  73465. */
  73466. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73467. /**
  73468. * Remove a specific life time gradient
  73469. * @param gradient defines the gradient to remove
  73470. * @returns the current particle system
  73471. */
  73472. removeLifeTimeGradient(gradient: number): IParticleSystem;
  73473. /**
  73474. * Gets the current list of life time gradients.
  73475. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  73476. * @returns the list of life time gradients
  73477. */
  73478. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  73479. /**
  73480. * Gets the current list of color gradients.
  73481. * You must use addColorGradient and removeColorGradient to udpate this list
  73482. * @returns the list of color gradients
  73483. */
  73484. getColorGradients(): Nullable<Array<ColorGradient>>;
  73485. /**
  73486. * Adds a new ramp gradient used to remap particle colors
  73487. * @param gradient defines the gradient to use (between 0 and 1)
  73488. * @param color defines the color to affect to the specified gradient
  73489. * @returns the current particle system
  73490. */
  73491. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  73492. /**
  73493. * Gets the current list of ramp gradients.
  73494. * You must use addRampGradient and removeRampGradient to udpate this list
  73495. * @returns the list of ramp gradients
  73496. */
  73497. getRampGradients(): Nullable<Array<Color3Gradient>>;
  73498. /** Gets or sets a boolean indicating that ramp gradients must be used
  73499. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  73500. */
  73501. useRampGradients: boolean;
  73502. /**
  73503. * Adds a new color remap gradient
  73504. * @param gradient defines the gradient to use (between 0 and 1)
  73505. * @param min defines the color remap minimal range
  73506. * @param max defines the color remap maximal range
  73507. * @returns the current particle system
  73508. */
  73509. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  73510. /**
  73511. * Gets the current list of color remap gradients.
  73512. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  73513. * @returns the list of color remap gradients
  73514. */
  73515. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  73516. /**
  73517. * Adds a new alpha remap gradient
  73518. * @param gradient defines the gradient to use (between 0 and 1)
  73519. * @param min defines the alpha remap minimal range
  73520. * @param max defines the alpha remap maximal range
  73521. * @returns the current particle system
  73522. */
  73523. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  73524. /**
  73525. * Gets the current list of alpha remap gradients.
  73526. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  73527. * @returns the list of alpha remap gradients
  73528. */
  73529. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  73530. /**
  73531. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  73532. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  73533. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  73534. * @returns the emitter
  73535. */
  73536. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  73537. /**
  73538. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  73539. * @param radius The radius of the hemisphere to emit from
  73540. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  73541. * @returns the emitter
  73542. */
  73543. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  73544. /**
  73545. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  73546. * @param radius The radius of the sphere to emit from
  73547. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  73548. * @returns the emitter
  73549. */
  73550. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  73551. /**
  73552. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  73553. * @param radius The radius of the sphere to emit from
  73554. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  73555. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  73556. * @returns the emitter
  73557. */
  73558. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  73559. /**
  73560. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  73561. * @param radius The radius of the emission cylinder
  73562. * @param height The height of the emission cylinder
  73563. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  73564. * @param directionRandomizer How much to randomize the particle direction [0-1]
  73565. * @returns the emitter
  73566. */
  73567. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  73568. /**
  73569. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  73570. * @param radius The radius of the cylinder to emit from
  73571. * @param height The height of the emission cylinder
  73572. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  73573. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  73574. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  73575. * @returns the emitter
  73576. */
  73577. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  73578. /**
  73579. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  73580. * @param radius The radius of the cone to emit from
  73581. * @param angle The base angle of the cone
  73582. * @returns the emitter
  73583. */
  73584. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  73585. /**
  73586. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  73587. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  73588. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  73589. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  73590. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  73591. * @returns the emitter
  73592. */
  73593. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  73594. /**
  73595. * Get hosting scene
  73596. * @returns the scene
  73597. */
  73598. getScene(): Scene;
  73599. }
  73600. }
  73601. declare module BABYLON {
  73602. /**
  73603. * Creates an instance based on a source mesh.
  73604. */
  73605. export class InstancedMesh extends AbstractMesh {
  73606. private _sourceMesh;
  73607. private _currentLOD;
  73608. /** @hidden */
  73609. _indexInSourceMeshInstanceArray: number;
  73610. constructor(name: string, source: Mesh);
  73611. /**
  73612. * Returns the string "InstancedMesh".
  73613. */
  73614. getClassName(): string;
  73615. /**
  73616. * If the source mesh receives shadows
  73617. */
  73618. readonly receiveShadows: boolean;
  73619. /**
  73620. * The material of the source mesh
  73621. */
  73622. readonly material: Nullable<Material>;
  73623. /**
  73624. * Visibility of the source mesh
  73625. */
  73626. readonly visibility: number;
  73627. /**
  73628. * Skeleton of the source mesh
  73629. */
  73630. readonly skeleton: Nullable<Skeleton>;
  73631. /**
  73632. * Rendering ground id of the source mesh
  73633. */
  73634. renderingGroupId: number;
  73635. /**
  73636. * Returns the total number of vertices (integer).
  73637. */
  73638. getTotalVertices(): number;
  73639. /**
  73640. * Returns a positive integer : the total number of indices in this mesh geometry.
  73641. * @returns the numner of indices or zero if the mesh has no geometry.
  73642. */
  73643. getTotalIndices(): number;
  73644. /**
  73645. * The source mesh of the instance
  73646. */
  73647. readonly sourceMesh: Mesh;
  73648. /**
  73649. * Is this node ready to be used/rendered
  73650. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  73651. * @return {boolean} is it ready
  73652. */
  73653. isReady(completeCheck?: boolean): boolean;
  73654. /**
  73655. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  73656. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  73657. * @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.
  73658. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  73659. */
  73660. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  73661. /**
  73662. * Sets the vertex data of the mesh geometry for the requested `kind`.
  73663. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  73664. * The `data` are either a numeric array either a Float32Array.
  73665. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  73666. * 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).
  73667. * Note that a new underlying VertexBuffer object is created each call.
  73668. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  73669. *
  73670. * Possible `kind` values :
  73671. * - VertexBuffer.PositionKind
  73672. * - VertexBuffer.UVKind
  73673. * - VertexBuffer.UV2Kind
  73674. * - VertexBuffer.UV3Kind
  73675. * - VertexBuffer.UV4Kind
  73676. * - VertexBuffer.UV5Kind
  73677. * - VertexBuffer.UV6Kind
  73678. * - VertexBuffer.ColorKind
  73679. * - VertexBuffer.MatricesIndicesKind
  73680. * - VertexBuffer.MatricesIndicesExtraKind
  73681. * - VertexBuffer.MatricesWeightsKind
  73682. * - VertexBuffer.MatricesWeightsExtraKind
  73683. *
  73684. * Returns the Mesh.
  73685. */
  73686. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  73687. /**
  73688. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  73689. * If the mesh has no geometry, it is simply returned as it is.
  73690. * The `data` are either a numeric array either a Float32Array.
  73691. * No new underlying VertexBuffer object is created.
  73692. * 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.
  73693. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  73694. *
  73695. * Possible `kind` values :
  73696. * - VertexBuffer.PositionKind
  73697. * - VertexBuffer.UVKind
  73698. * - VertexBuffer.UV2Kind
  73699. * - VertexBuffer.UV3Kind
  73700. * - VertexBuffer.UV4Kind
  73701. * - VertexBuffer.UV5Kind
  73702. * - VertexBuffer.UV6Kind
  73703. * - VertexBuffer.ColorKind
  73704. * - VertexBuffer.MatricesIndicesKind
  73705. * - VertexBuffer.MatricesIndicesExtraKind
  73706. * - VertexBuffer.MatricesWeightsKind
  73707. * - VertexBuffer.MatricesWeightsExtraKind
  73708. *
  73709. * Returns the Mesh.
  73710. */
  73711. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  73712. /**
  73713. * Sets the mesh indices.
  73714. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  73715. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  73716. * This method creates a new index buffer each call.
  73717. * Returns the Mesh.
  73718. */
  73719. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  73720. /**
  73721. * Boolean : True if the mesh owns the requested kind of data.
  73722. */
  73723. isVerticesDataPresent(kind: string): boolean;
  73724. /**
  73725. * Returns an array of indices (IndicesArray).
  73726. */
  73727. getIndices(): Nullable<IndicesArray>;
  73728. readonly _positions: Nullable<Vector3[]>;
  73729. /**
  73730. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  73731. * This means the mesh underlying bounding box and sphere are recomputed.
  73732. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  73733. * @returns the current mesh
  73734. */
  73735. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  73736. /** @hidden */
  73737. _preActivate(): InstancedMesh;
  73738. /** @hidden */
  73739. _activate(renderId: number): InstancedMesh;
  73740. /**
  73741. * Returns the current associated LOD AbstractMesh.
  73742. */
  73743. getLOD(camera: Camera): AbstractMesh;
  73744. /** @hidden */
  73745. _syncSubMeshes(): InstancedMesh;
  73746. /** @hidden */
  73747. _generatePointsArray(): boolean;
  73748. /**
  73749. * Creates a new InstancedMesh from the current mesh.
  73750. * - name (string) : the cloned mesh name
  73751. * - newParent (optional Node) : the optional Node to parent the clone to.
  73752. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  73753. *
  73754. * Returns the clone.
  73755. */
  73756. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  73757. /**
  73758. * Disposes the InstancedMesh.
  73759. * Returns nothing.
  73760. */
  73761. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  73762. }
  73763. }
  73764. declare module BABYLON {
  73765. /**
  73766. * Defines the options associated with the creation of a shader material.
  73767. */
  73768. export interface IShaderMaterialOptions {
  73769. /**
  73770. * Does the material work in alpha blend mode
  73771. */
  73772. needAlphaBlending: boolean;
  73773. /**
  73774. * Does the material work in alpha test mode
  73775. */
  73776. needAlphaTesting: boolean;
  73777. /**
  73778. * The list of attribute names used in the shader
  73779. */
  73780. attributes: string[];
  73781. /**
  73782. * The list of unifrom names used in the shader
  73783. */
  73784. uniforms: string[];
  73785. /**
  73786. * The list of UBO names used in the shader
  73787. */
  73788. uniformBuffers: string[];
  73789. /**
  73790. * The list of sampler names used in the shader
  73791. */
  73792. samplers: string[];
  73793. /**
  73794. * The list of defines used in the shader
  73795. */
  73796. defines: string[];
  73797. }
  73798. /**
  73799. * 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.
  73800. *
  73801. * This returned material effects how the mesh will look based on the code in the shaders.
  73802. *
  73803. * @see http://doc.babylonjs.com/how_to/shader_material
  73804. */
  73805. export class ShaderMaterial extends Material {
  73806. private _shaderPath;
  73807. private _options;
  73808. private _textures;
  73809. private _textureArrays;
  73810. private _floats;
  73811. private _ints;
  73812. private _floatsArrays;
  73813. private _colors3;
  73814. private _colors3Arrays;
  73815. private _colors4;
  73816. private _vectors2;
  73817. private _vectors3;
  73818. private _vectors4;
  73819. private _matrices;
  73820. private _matrices3x3;
  73821. private _matrices2x2;
  73822. private _vectors2Arrays;
  73823. private _vectors3Arrays;
  73824. private _cachedWorldViewMatrix;
  73825. private _renderId;
  73826. /**
  73827. * Instantiate a new shader material.
  73828. * 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.
  73829. * This returned material effects how the mesh will look based on the code in the shaders.
  73830. * @see http://doc.babylonjs.com/how_to/shader_material
  73831. * @param name Define the name of the material in the scene
  73832. * @param scene Define the scene the material belongs to
  73833. * @param shaderPath Defines the route to the shader code in one of three ways:
  73834. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  73835. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  73836. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  73837. * @param options Define the options used to create the shader
  73838. */
  73839. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  73840. /**
  73841. * Gets the current class name of the material e.g. "ShaderMaterial"
  73842. * Mainly use in serialization.
  73843. * @returns the class name
  73844. */
  73845. getClassName(): string;
  73846. /**
  73847. * Specifies if the material will require alpha blending
  73848. * @returns a boolean specifying if alpha blending is needed
  73849. */
  73850. needAlphaBlending(): boolean;
  73851. /**
  73852. * Specifies if this material should be rendered in alpha test mode
  73853. * @returns a boolean specifying if an alpha test is needed.
  73854. */
  73855. needAlphaTesting(): boolean;
  73856. private _checkUniform;
  73857. /**
  73858. * Set a texture in the shader.
  73859. * @param name Define the name of the uniform samplers as defined in the shader
  73860. * @param texture Define the texture to bind to this sampler
  73861. * @return the material itself allowing "fluent" like uniform updates
  73862. */
  73863. setTexture(name: string, texture: Texture): ShaderMaterial;
  73864. /**
  73865. * Set a texture array in the shader.
  73866. * @param name Define the name of the uniform sampler array as defined in the shader
  73867. * @param textures Define the list of textures to bind to this sampler
  73868. * @return the material itself allowing "fluent" like uniform updates
  73869. */
  73870. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  73871. /**
  73872. * Set a float in the shader.
  73873. * @param name Define the name of the uniform as defined in the shader
  73874. * @param value Define the value to give to the uniform
  73875. * @return the material itself allowing "fluent" like uniform updates
  73876. */
  73877. setFloat(name: string, value: number): ShaderMaterial;
  73878. /**
  73879. * Set a int in the shader.
  73880. * @param name Define the name of the uniform as defined in the shader
  73881. * @param value Define the value to give to the uniform
  73882. * @return the material itself allowing "fluent" like uniform updates
  73883. */
  73884. setInt(name: string, value: number): ShaderMaterial;
  73885. /**
  73886. * Set an array of floats in the shader.
  73887. * @param name Define the name of the uniform as defined in the shader
  73888. * @param value Define the value to give to the uniform
  73889. * @return the material itself allowing "fluent" like uniform updates
  73890. */
  73891. setFloats(name: string, value: number[]): ShaderMaterial;
  73892. /**
  73893. * Set a vec3 in the shader from a Color3.
  73894. * @param name Define the name of the uniform as defined in the shader
  73895. * @param value Define the value to give to the uniform
  73896. * @return the material itself allowing "fluent" like uniform updates
  73897. */
  73898. setColor3(name: string, value: Color3): ShaderMaterial;
  73899. /**
  73900. * Set a vec3 array in the shader from a Color3 array.
  73901. * @param name Define the name of the uniform as defined in the shader
  73902. * @param value Define the value to give to the uniform
  73903. * @return the material itself allowing "fluent" like uniform updates
  73904. */
  73905. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  73906. /**
  73907. * Set a vec4 in the shader from a Color4.
  73908. * @param name Define the name of the uniform as defined in the shader
  73909. * @param value Define the value to give to the uniform
  73910. * @return the material itself allowing "fluent" like uniform updates
  73911. */
  73912. setColor4(name: string, value: Color4): ShaderMaterial;
  73913. /**
  73914. * Set a vec2 in the shader from a Vector2.
  73915. * @param name Define the name of the uniform as defined in the shader
  73916. * @param value Define the value to give to the uniform
  73917. * @return the material itself allowing "fluent" like uniform updates
  73918. */
  73919. setVector2(name: string, value: Vector2): ShaderMaterial;
  73920. /**
  73921. * Set a vec3 in the shader from a Vector3.
  73922. * @param name Define the name of the uniform as defined in the shader
  73923. * @param value Define the value to give to the uniform
  73924. * @return the material itself allowing "fluent" like uniform updates
  73925. */
  73926. setVector3(name: string, value: Vector3): ShaderMaterial;
  73927. /**
  73928. * Set a vec4 in the shader from a Vector4.
  73929. * @param name Define the name of the uniform as defined in the shader
  73930. * @param value Define the value to give to the uniform
  73931. * @return the material itself allowing "fluent" like uniform updates
  73932. */
  73933. setVector4(name: string, value: Vector4): ShaderMaterial;
  73934. /**
  73935. * Set a mat4 in the shader from a Matrix.
  73936. * @param name Define the name of the uniform as defined in the shader
  73937. * @param value Define the value to give to the uniform
  73938. * @return the material itself allowing "fluent" like uniform updates
  73939. */
  73940. setMatrix(name: string, value: Matrix): ShaderMaterial;
  73941. /**
  73942. * Set a mat3 in the shader from a Float32Array.
  73943. * @param name Define the name of the uniform as defined in the shader
  73944. * @param value Define the value to give to the uniform
  73945. * @return the material itself allowing "fluent" like uniform updates
  73946. */
  73947. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  73948. /**
  73949. * Set a mat2 in the shader from a Float32Array.
  73950. * @param name Define the name of the uniform as defined in the shader
  73951. * @param value Define the value to give to the uniform
  73952. * @return the material itself allowing "fluent" like uniform updates
  73953. */
  73954. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  73955. /**
  73956. * Set a vec2 array in the shader from a number array.
  73957. * @param name Define the name of the uniform as defined in the shader
  73958. * @param value Define the value to give to the uniform
  73959. * @return the material itself allowing "fluent" like uniform updates
  73960. */
  73961. setArray2(name: string, value: number[]): ShaderMaterial;
  73962. /**
  73963. * Set a vec3 array in the shader from a number array.
  73964. * @param name Define the name of the uniform as defined in the shader
  73965. * @param value Define the value to give to the uniform
  73966. * @return the material itself allowing "fluent" like uniform updates
  73967. */
  73968. setArray3(name: string, value: number[]): ShaderMaterial;
  73969. private _checkCache;
  73970. /**
  73971. * Checks if the material is ready to render the requested mesh
  73972. * @param mesh Define the mesh to render
  73973. * @param useInstances Define whether or not the material is used with instances
  73974. * @returns true if ready, otherwise false
  73975. */
  73976. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  73977. /**
  73978. * Binds the world matrix to the material
  73979. * @param world defines the world transformation matrix
  73980. */
  73981. bindOnlyWorldMatrix(world: Matrix): void;
  73982. /**
  73983. * Binds the material to the mesh
  73984. * @param world defines the world transformation matrix
  73985. * @param mesh defines the mesh to bind the material to
  73986. */
  73987. bind(world: Matrix, mesh?: Mesh): void;
  73988. /**
  73989. * Gets the active textures from the material
  73990. * @returns an array of textures
  73991. */
  73992. getActiveTextures(): BaseTexture[];
  73993. /**
  73994. * Specifies if the material uses a texture
  73995. * @param texture defines the texture to check against the material
  73996. * @returns a boolean specifying if the material uses the texture
  73997. */
  73998. hasTexture(texture: BaseTexture): boolean;
  73999. /**
  74000. * Makes a duplicate of the material, and gives it a new name
  74001. * @param name defines the new name for the duplicated material
  74002. * @returns the cloned material
  74003. */
  74004. clone(name: string): ShaderMaterial;
  74005. /**
  74006. * Disposes the material
  74007. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  74008. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  74009. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  74010. */
  74011. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  74012. /**
  74013. * Serializes this material in a JSON representation
  74014. * @returns the serialized material object
  74015. */
  74016. serialize(): any;
  74017. /**
  74018. * Creates a shader material from parsed shader material data
  74019. * @param source defines the JSON represnetation of the material
  74020. * @param scene defines the hosting scene
  74021. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  74022. * @returns a new material
  74023. */
  74024. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  74025. }
  74026. }
  74027. declare module BABYLON {
  74028. /** @hidden */
  74029. export var colorPixelShader: {
  74030. name: string;
  74031. shader: string;
  74032. };
  74033. }
  74034. declare module BABYLON {
  74035. /** @hidden */
  74036. export var colorVertexShader: {
  74037. name: string;
  74038. shader: string;
  74039. };
  74040. }
  74041. declare module BABYLON {
  74042. /**
  74043. * Line mesh
  74044. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  74045. */
  74046. export class LinesMesh extends Mesh {
  74047. /**
  74048. * If vertex color should be applied to the mesh
  74049. */
  74050. useVertexColor?: boolean | undefined;
  74051. /**
  74052. * If vertex alpha should be applied to the mesh
  74053. */
  74054. useVertexAlpha?: boolean | undefined;
  74055. /**
  74056. * Color of the line (Default: White)
  74057. */
  74058. color: Color3;
  74059. /**
  74060. * Alpha of the line (Default: 1)
  74061. */
  74062. alpha: number;
  74063. /**
  74064. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  74065. * This margin is expressed in world space coordinates, so its value may vary.
  74066. * Default value is 0.1
  74067. */
  74068. intersectionThreshold: number;
  74069. private _colorShader;
  74070. /**
  74071. * Creates a new LinesMesh
  74072. * @param name defines the name
  74073. * @param scene defines the hosting scene
  74074. * @param parent defines the parent mesh if any
  74075. * @param source defines the optional source LinesMesh used to clone data from
  74076. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  74077. * When false, achieved by calling a clone(), also passing False.
  74078. * This will make creation of children, recursive.
  74079. * @param useVertexColor defines if this LinesMesh supports vertex color
  74080. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  74081. */
  74082. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  74083. /**
  74084. * If vertex color should be applied to the mesh
  74085. */
  74086. useVertexColor?: boolean | undefined,
  74087. /**
  74088. * If vertex alpha should be applied to the mesh
  74089. */
  74090. useVertexAlpha?: boolean | undefined);
  74091. /**
  74092. * Returns the string "LineMesh"
  74093. */
  74094. getClassName(): string;
  74095. /**
  74096. * @hidden
  74097. */
  74098. /**
  74099. * @hidden
  74100. */
  74101. material: Material;
  74102. /**
  74103. * @hidden
  74104. */
  74105. readonly checkCollisions: boolean;
  74106. /** @hidden */
  74107. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  74108. /** @hidden */
  74109. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  74110. /**
  74111. * Disposes of the line mesh
  74112. * @param doNotRecurse If children should be disposed
  74113. */
  74114. dispose(doNotRecurse?: boolean): void;
  74115. /**
  74116. * Returns a new LineMesh object cloned from the current one.
  74117. */
  74118. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  74119. /**
  74120. * Creates a new InstancedLinesMesh object from the mesh model.
  74121. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  74122. * @param name defines the name of the new instance
  74123. * @returns a new InstancedLinesMesh
  74124. */
  74125. createInstance(name: string): InstancedLinesMesh;
  74126. }
  74127. /**
  74128. * Creates an instance based on a source LinesMesh
  74129. */
  74130. export class InstancedLinesMesh extends InstancedMesh {
  74131. /**
  74132. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  74133. * This margin is expressed in world space coordinates, so its value may vary.
  74134. * Initilized with the intersectionThreshold value of the source LinesMesh
  74135. */
  74136. intersectionThreshold: number;
  74137. constructor(name: string, source: LinesMesh);
  74138. /**
  74139. * Returns the string "InstancedLinesMesh".
  74140. */
  74141. getClassName(): string;
  74142. }
  74143. }
  74144. declare module BABYLON {
  74145. /** @hidden */
  74146. export var linePixelShader: {
  74147. name: string;
  74148. shader: string;
  74149. };
  74150. }
  74151. declare module BABYLON {
  74152. /** @hidden */
  74153. export var lineVertexShader: {
  74154. name: string;
  74155. shader: string;
  74156. };
  74157. }
  74158. declare module BABYLON {
  74159. interface AbstractMesh {
  74160. /**
  74161. * Disables the mesh edge rendering mode
  74162. * @returns the currentAbstractMesh
  74163. */
  74164. disableEdgesRendering(): AbstractMesh;
  74165. /**
  74166. * Enables the edge rendering mode on the mesh.
  74167. * This mode makes the mesh edges visible
  74168. * @param epsilon defines the maximal distance between two angles to detect a face
  74169. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  74170. * @returns the currentAbstractMesh
  74171. * @see https://www.babylonjs-playground.com/#19O9TU#0
  74172. */
  74173. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  74174. /**
  74175. * Gets the edgesRenderer associated with the mesh
  74176. */
  74177. edgesRenderer: Nullable<EdgesRenderer>;
  74178. }
  74179. interface LinesMesh {
  74180. /**
  74181. * Enables the edge rendering mode on the mesh.
  74182. * This mode makes the mesh edges visible
  74183. * @param epsilon defines the maximal distance between two angles to detect a face
  74184. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  74185. * @returns the currentAbstractMesh
  74186. * @see https://www.babylonjs-playground.com/#19O9TU#0
  74187. */
  74188. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  74189. }
  74190. interface InstancedLinesMesh {
  74191. /**
  74192. * Enables the edge rendering mode on the mesh.
  74193. * This mode makes the mesh edges visible
  74194. * @param epsilon defines the maximal distance between two angles to detect a face
  74195. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  74196. * @returns the current InstancedLinesMesh
  74197. * @see https://www.babylonjs-playground.com/#19O9TU#0
  74198. */
  74199. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  74200. }
  74201. /**
  74202. * Defines the minimum contract an Edges renderer should follow.
  74203. */
  74204. export interface IEdgesRenderer extends IDisposable {
  74205. /**
  74206. * Gets or sets a boolean indicating if the edgesRenderer is active
  74207. */
  74208. isEnabled: boolean;
  74209. /**
  74210. * Renders the edges of the attached mesh,
  74211. */
  74212. render(): void;
  74213. /**
  74214. * Checks wether or not the edges renderer is ready to render.
  74215. * @return true if ready, otherwise false.
  74216. */
  74217. isReady(): boolean;
  74218. }
  74219. /**
  74220. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  74221. */
  74222. export class EdgesRenderer implements IEdgesRenderer {
  74223. /**
  74224. * Define the size of the edges with an orthographic camera
  74225. */
  74226. edgesWidthScalerForOrthographic: number;
  74227. /**
  74228. * Define the size of the edges with a perspective camera
  74229. */
  74230. edgesWidthScalerForPerspective: number;
  74231. protected _source: AbstractMesh;
  74232. protected _linesPositions: number[];
  74233. protected _linesNormals: number[];
  74234. protected _linesIndices: number[];
  74235. protected _epsilon: number;
  74236. protected _indicesCount: number;
  74237. protected _lineShader: ShaderMaterial;
  74238. protected _ib: WebGLBuffer;
  74239. protected _buffers: {
  74240. [key: string]: Nullable<VertexBuffer>;
  74241. };
  74242. protected _checkVerticesInsteadOfIndices: boolean;
  74243. private _meshRebuildObserver;
  74244. private _meshDisposeObserver;
  74245. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  74246. isEnabled: boolean;
  74247. /**
  74248. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  74249. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  74250. * @param source Mesh used to create edges
  74251. * @param epsilon sum of angles in adjacency to check for edge
  74252. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  74253. * @param generateEdgesLines - should generate Lines or only prepare resources.
  74254. */
  74255. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  74256. protected _prepareRessources(): void;
  74257. /** @hidden */
  74258. _rebuild(): void;
  74259. /**
  74260. * Releases the required resources for the edges renderer
  74261. */
  74262. dispose(): void;
  74263. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  74264. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  74265. /**
  74266. * Checks if the pair of p0 and p1 is en edge
  74267. * @param faceIndex
  74268. * @param edge
  74269. * @param faceNormals
  74270. * @param p0
  74271. * @param p1
  74272. * @private
  74273. */
  74274. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  74275. /**
  74276. * push line into the position, normal and index buffer
  74277. * @protected
  74278. */
  74279. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  74280. /**
  74281. * Generates lines edges from adjacencjes
  74282. * @private
  74283. */
  74284. _generateEdgesLines(): void;
  74285. /**
  74286. * Checks wether or not the edges renderer is ready to render.
  74287. * @return true if ready, otherwise false.
  74288. */
  74289. isReady(): boolean;
  74290. /**
  74291. * Renders the edges of the attached mesh,
  74292. */
  74293. render(): void;
  74294. }
  74295. /**
  74296. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  74297. */
  74298. export class LineEdgesRenderer extends EdgesRenderer {
  74299. /**
  74300. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  74301. * @param source LineMesh used to generate edges
  74302. * @param epsilon not important (specified angle for edge detection)
  74303. * @param checkVerticesInsteadOfIndices not important for LineMesh
  74304. */
  74305. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  74306. /**
  74307. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  74308. */
  74309. _generateEdgesLines(): void;
  74310. }
  74311. }
  74312. declare module BABYLON {
  74313. /**
  74314. * This represents the object necessary to create a rendering group.
  74315. * This is exclusively used and created by the rendering manager.
  74316. * To modify the behavior, you use the available helpers in your scene or meshes.
  74317. * @hidden
  74318. */
  74319. export class RenderingGroup {
  74320. index: number;
  74321. private _scene;
  74322. private _opaqueSubMeshes;
  74323. private _transparentSubMeshes;
  74324. private _alphaTestSubMeshes;
  74325. private _depthOnlySubMeshes;
  74326. private _particleSystems;
  74327. private _spriteManagers;
  74328. private _opaqueSortCompareFn;
  74329. private _alphaTestSortCompareFn;
  74330. private _transparentSortCompareFn;
  74331. private _renderOpaque;
  74332. private _renderAlphaTest;
  74333. private _renderTransparent;
  74334. private _edgesRenderers;
  74335. onBeforeTransparentRendering: () => void;
  74336. /**
  74337. * Set the opaque sort comparison function.
  74338. * If null the sub meshes will be render in the order they were created
  74339. */
  74340. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  74341. /**
  74342. * Set the alpha test sort comparison function.
  74343. * If null the sub meshes will be render in the order they were created
  74344. */
  74345. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  74346. /**
  74347. * Set the transparent sort comparison function.
  74348. * If null the sub meshes will be render in the order they were created
  74349. */
  74350. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  74351. /**
  74352. * Creates a new rendering group.
  74353. * @param index The rendering group index
  74354. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  74355. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  74356. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  74357. */
  74358. 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>);
  74359. /**
  74360. * Render all the sub meshes contained in the group.
  74361. * @param customRenderFunction Used to override the default render behaviour of the group.
  74362. * @returns true if rendered some submeshes.
  74363. */
  74364. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  74365. /**
  74366. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  74367. * @param subMeshes The submeshes to render
  74368. */
  74369. private renderOpaqueSorted;
  74370. /**
  74371. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  74372. * @param subMeshes The submeshes to render
  74373. */
  74374. private renderAlphaTestSorted;
  74375. /**
  74376. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  74377. * @param subMeshes The submeshes to render
  74378. */
  74379. private renderTransparentSorted;
  74380. /**
  74381. * Renders the submeshes in a specified order.
  74382. * @param subMeshes The submeshes to sort before render
  74383. * @param sortCompareFn The comparison function use to sort
  74384. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  74385. * @param transparent Specifies to activate blending if true
  74386. */
  74387. private static renderSorted;
  74388. /**
  74389. * Renders the submeshes in the order they were dispatched (no sort applied).
  74390. * @param subMeshes The submeshes to render
  74391. */
  74392. private static renderUnsorted;
  74393. /**
  74394. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  74395. * are rendered back to front if in the same alpha index.
  74396. *
  74397. * @param a The first submesh
  74398. * @param b The second submesh
  74399. * @returns The result of the comparison
  74400. */
  74401. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  74402. /**
  74403. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  74404. * are rendered back to front.
  74405. *
  74406. * @param a The first submesh
  74407. * @param b The second submesh
  74408. * @returns The result of the comparison
  74409. */
  74410. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  74411. /**
  74412. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  74413. * are rendered front to back (prevent overdraw).
  74414. *
  74415. * @param a The first submesh
  74416. * @param b The second submesh
  74417. * @returns The result of the comparison
  74418. */
  74419. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  74420. /**
  74421. * Resets the different lists of submeshes to prepare a new frame.
  74422. */
  74423. prepare(): void;
  74424. dispose(): void;
  74425. /**
  74426. * Inserts the submesh in its correct queue depending on its material.
  74427. * @param subMesh The submesh to dispatch
  74428. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  74429. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  74430. */
  74431. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  74432. dispatchSprites(spriteManager: ISpriteManager): void;
  74433. dispatchParticles(particleSystem: IParticleSystem): void;
  74434. private _renderParticles;
  74435. private _renderSprites;
  74436. }
  74437. }
  74438. declare module BABYLON {
  74439. /**
  74440. * Interface describing the different options available in the rendering manager
  74441. * regarding Auto Clear between groups.
  74442. */
  74443. export interface IRenderingManagerAutoClearSetup {
  74444. /**
  74445. * Defines whether or not autoclear is enable.
  74446. */
  74447. autoClear: boolean;
  74448. /**
  74449. * Defines whether or not to autoclear the depth buffer.
  74450. */
  74451. depth: boolean;
  74452. /**
  74453. * Defines whether or not to autoclear the stencil buffer.
  74454. */
  74455. stencil: boolean;
  74456. }
  74457. /**
  74458. * This class is used by the onRenderingGroupObservable
  74459. */
  74460. export class RenderingGroupInfo {
  74461. /**
  74462. * The Scene that being rendered
  74463. */
  74464. scene: Scene;
  74465. /**
  74466. * The camera currently used for the rendering pass
  74467. */
  74468. camera: Nullable<Camera>;
  74469. /**
  74470. * The ID of the renderingGroup being processed
  74471. */
  74472. renderingGroupId: number;
  74473. }
  74474. /**
  74475. * This is the manager responsible of all the rendering for meshes sprites and particles.
  74476. * It is enable to manage the different groups as well as the different necessary sort functions.
  74477. * This should not be used directly aside of the few static configurations
  74478. */
  74479. export class RenderingManager {
  74480. /**
  74481. * The max id used for rendering groups (not included)
  74482. */
  74483. static MAX_RENDERINGGROUPS: number;
  74484. /**
  74485. * The min id used for rendering groups (included)
  74486. */
  74487. static MIN_RENDERINGGROUPS: number;
  74488. /**
  74489. * Used to globally prevent autoclearing scenes.
  74490. */
  74491. static AUTOCLEAR: boolean;
  74492. /**
  74493. * @hidden
  74494. */
  74495. _useSceneAutoClearSetup: boolean;
  74496. private _scene;
  74497. private _renderingGroups;
  74498. private _depthStencilBufferAlreadyCleaned;
  74499. private _autoClearDepthStencil;
  74500. private _customOpaqueSortCompareFn;
  74501. private _customAlphaTestSortCompareFn;
  74502. private _customTransparentSortCompareFn;
  74503. private _renderingGroupInfo;
  74504. /**
  74505. * Instantiates a new rendering group for a particular scene
  74506. * @param scene Defines the scene the groups belongs to
  74507. */
  74508. constructor(scene: Scene);
  74509. private _clearDepthStencilBuffer;
  74510. /**
  74511. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  74512. * @hidden
  74513. */
  74514. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  74515. /**
  74516. * Resets the different information of the group to prepare a new frame
  74517. * @hidden
  74518. */
  74519. reset(): void;
  74520. /**
  74521. * Dispose and release the group and its associated resources.
  74522. * @hidden
  74523. */
  74524. dispose(): void;
  74525. /**
  74526. * Clear the info related to rendering groups preventing retention points during dispose.
  74527. */
  74528. freeRenderingGroups(): void;
  74529. private _prepareRenderingGroup;
  74530. /**
  74531. * Add a sprite manager to the rendering manager in order to render it this frame.
  74532. * @param spriteManager Define the sprite manager to render
  74533. */
  74534. dispatchSprites(spriteManager: ISpriteManager): void;
  74535. /**
  74536. * Add a particle system to the rendering manager in order to render it this frame.
  74537. * @param particleSystem Define the particle system to render
  74538. */
  74539. dispatchParticles(particleSystem: IParticleSystem): void;
  74540. /**
  74541. * Add a submesh to the manager in order to render it this frame
  74542. * @param subMesh The submesh to dispatch
  74543. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  74544. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  74545. */
  74546. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  74547. /**
  74548. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  74549. * This allowed control for front to back rendering or reversly depending of the special needs.
  74550. *
  74551. * @param renderingGroupId The rendering group id corresponding to its index
  74552. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  74553. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  74554. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  74555. */
  74556. 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;
  74557. /**
  74558. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  74559. *
  74560. * @param renderingGroupId The rendering group id corresponding to its index
  74561. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  74562. * @param depth Automatically clears depth between groups if true and autoClear is true.
  74563. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  74564. */
  74565. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  74566. /**
  74567. * Gets the current auto clear configuration for one rendering group of the rendering
  74568. * manager.
  74569. * @param index the rendering group index to get the information for
  74570. * @returns The auto clear setup for the requested rendering group
  74571. */
  74572. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  74573. }
  74574. }
  74575. declare module BABYLON {
  74576. /**
  74577. * This Helps creating a texture that will be created from a camera in your scene.
  74578. * It is basically a dynamic texture that could be used to create special effects for instance.
  74579. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  74580. */
  74581. export class RenderTargetTexture extends Texture {
  74582. isCube: boolean;
  74583. /**
  74584. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  74585. */
  74586. static readonly REFRESHRATE_RENDER_ONCE: number;
  74587. /**
  74588. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  74589. */
  74590. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  74591. /**
  74592. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  74593. * the central point of your effect and can save a lot of performances.
  74594. */
  74595. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  74596. /**
  74597. * Use this predicate to dynamically define the list of mesh you want to render.
  74598. * If set, the renderList property will be overwritten.
  74599. */
  74600. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  74601. private _renderList;
  74602. /**
  74603. * Use this list to define the list of mesh you want to render.
  74604. */
  74605. renderList: Nullable<Array<AbstractMesh>>;
  74606. private _hookArray;
  74607. /**
  74608. * Define if particles should be rendered in your texture.
  74609. */
  74610. renderParticles: boolean;
  74611. /**
  74612. * Define if sprites should be rendered in your texture.
  74613. */
  74614. renderSprites: boolean;
  74615. /**
  74616. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  74617. */
  74618. coordinatesMode: number;
  74619. /**
  74620. * Define the camera used to render the texture.
  74621. */
  74622. activeCamera: Nullable<Camera>;
  74623. /**
  74624. * Override the render function of the texture with your own one.
  74625. */
  74626. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  74627. /**
  74628. * Define if camera post processes should be use while rendering the texture.
  74629. */
  74630. useCameraPostProcesses: boolean;
  74631. /**
  74632. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  74633. */
  74634. ignoreCameraViewport: boolean;
  74635. private _postProcessManager;
  74636. private _postProcesses;
  74637. private _resizeObserver;
  74638. /**
  74639. * An event triggered when the texture is unbind.
  74640. */
  74641. onBeforeBindObservable: Observable<RenderTargetTexture>;
  74642. /**
  74643. * An event triggered when the texture is unbind.
  74644. */
  74645. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  74646. private _onAfterUnbindObserver;
  74647. /**
  74648. * Set a after unbind callback in the texture.
  74649. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  74650. */
  74651. onAfterUnbind: () => void;
  74652. /**
  74653. * An event triggered before rendering the texture
  74654. */
  74655. onBeforeRenderObservable: Observable<number>;
  74656. private _onBeforeRenderObserver;
  74657. /**
  74658. * Set a before render callback in the texture.
  74659. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  74660. */
  74661. onBeforeRender: (faceIndex: number) => void;
  74662. /**
  74663. * An event triggered after rendering the texture
  74664. */
  74665. onAfterRenderObservable: Observable<number>;
  74666. private _onAfterRenderObserver;
  74667. /**
  74668. * Set a after render callback in the texture.
  74669. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  74670. */
  74671. onAfterRender: (faceIndex: number) => void;
  74672. /**
  74673. * An event triggered after the texture clear
  74674. */
  74675. onClearObservable: Observable<Engine>;
  74676. private _onClearObserver;
  74677. /**
  74678. * Set a clear callback in the texture.
  74679. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  74680. */
  74681. onClear: (Engine: Engine) => void;
  74682. /**
  74683. * Define the clear color of the Render Target if it should be different from the scene.
  74684. */
  74685. clearColor: Color4;
  74686. protected _size: number | {
  74687. width: number;
  74688. height: number;
  74689. };
  74690. protected _initialSizeParameter: number | {
  74691. width: number;
  74692. height: number;
  74693. } | {
  74694. ratio: number;
  74695. };
  74696. protected _sizeRatio: Nullable<number>;
  74697. /** @hidden */
  74698. _generateMipMaps: boolean;
  74699. protected _renderingManager: RenderingManager;
  74700. /** @hidden */
  74701. _waitingRenderList: string[];
  74702. protected _doNotChangeAspectRatio: boolean;
  74703. protected _currentRefreshId: number;
  74704. protected _refreshRate: number;
  74705. protected _textureMatrix: Matrix;
  74706. protected _samples: number;
  74707. protected _renderTargetOptions: RenderTargetCreationOptions;
  74708. /**
  74709. * Gets render target creation options that were used.
  74710. */
  74711. readonly renderTargetOptions: RenderTargetCreationOptions;
  74712. protected _engine: Engine;
  74713. protected _onRatioRescale(): void;
  74714. /**
  74715. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  74716. * It must define where the camera used to render the texture is set
  74717. */
  74718. boundingBoxPosition: Vector3;
  74719. private _boundingBoxSize;
  74720. /**
  74721. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  74722. * When defined, the cubemap will switch to local mode
  74723. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  74724. * @example https://www.babylonjs-playground.com/#RNASML
  74725. */
  74726. boundingBoxSize: Vector3;
  74727. /**
  74728. * In case the RTT has been created with a depth texture, get the associated
  74729. * depth texture.
  74730. * Otherwise, return null.
  74731. */
  74732. depthStencilTexture: Nullable<InternalTexture>;
  74733. /**
  74734. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  74735. * or used a shadow, depth texture...
  74736. * @param name The friendly name of the texture
  74737. * @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)
  74738. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  74739. * @param generateMipMaps True if mip maps need to be generated after render.
  74740. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  74741. * @param type The type of the buffer in the RTT (int, half float, float...)
  74742. * @param isCube True if a cube texture needs to be created
  74743. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  74744. * @param generateDepthBuffer True to generate a depth buffer
  74745. * @param generateStencilBuffer True to generate a stencil buffer
  74746. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  74747. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  74748. * @param delayAllocation if the texture allocation should be delayed (default: false)
  74749. */
  74750. constructor(name: string, size: number | {
  74751. width: number;
  74752. height: number;
  74753. } | {
  74754. ratio: number;
  74755. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  74756. /**
  74757. * Creates a depth stencil texture.
  74758. * This is only available in WebGL 2 or with the depth texture extension available.
  74759. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  74760. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  74761. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  74762. */
  74763. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  74764. private _processSizeParameter;
  74765. /**
  74766. * Define the number of samples to use in case of MSAA.
  74767. * It defaults to one meaning no MSAA has been enabled.
  74768. */
  74769. samples: number;
  74770. /**
  74771. * Resets the refresh counter of the texture and start bak from scratch.
  74772. * Could be useful to regenerate the texture if it is setup to render only once.
  74773. */
  74774. resetRefreshCounter(): void;
  74775. /**
  74776. * Define the refresh rate of the texture or the rendering frequency.
  74777. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  74778. */
  74779. refreshRate: number;
  74780. /**
  74781. * Adds a post process to the render target rendering passes.
  74782. * @param postProcess define the post process to add
  74783. */
  74784. addPostProcess(postProcess: PostProcess): void;
  74785. /**
  74786. * Clear all the post processes attached to the render target
  74787. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  74788. */
  74789. clearPostProcesses(dispose?: boolean): void;
  74790. /**
  74791. * Remove one of the post process from the list of attached post processes to the texture
  74792. * @param postProcess define the post process to remove from the list
  74793. */
  74794. removePostProcess(postProcess: PostProcess): void;
  74795. /** @hidden */
  74796. _shouldRender(): boolean;
  74797. /**
  74798. * Gets the actual render size of the texture.
  74799. * @returns the width of the render size
  74800. */
  74801. getRenderSize(): number;
  74802. /**
  74803. * Gets the actual render width of the texture.
  74804. * @returns the width of the render size
  74805. */
  74806. getRenderWidth(): number;
  74807. /**
  74808. * Gets the actual render height of the texture.
  74809. * @returns the height of the render size
  74810. */
  74811. getRenderHeight(): number;
  74812. /**
  74813. * Get if the texture can be rescaled or not.
  74814. */
  74815. readonly canRescale: boolean;
  74816. /**
  74817. * Resize the texture using a ratio.
  74818. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  74819. */
  74820. scale(ratio: number): void;
  74821. /**
  74822. * Get the texture reflection matrix used to rotate/transform the reflection.
  74823. * @returns the reflection matrix
  74824. */
  74825. getReflectionTextureMatrix(): Matrix;
  74826. /**
  74827. * Resize the texture to a new desired size.
  74828. * Be carrefull as it will recreate all the data in the new texture.
  74829. * @param size Define the new size. It can be:
  74830. * - a number for squared texture,
  74831. * - an object containing { width: number, height: number }
  74832. * - or an object containing a ratio { ratio: number }
  74833. */
  74834. resize(size: number | {
  74835. width: number;
  74836. height: number;
  74837. } | {
  74838. ratio: number;
  74839. }): void;
  74840. /**
  74841. * Renders all the objects from the render list into the texture.
  74842. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  74843. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  74844. */
  74845. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  74846. private _bestReflectionRenderTargetDimension;
  74847. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  74848. private renderToTarget;
  74849. /**
  74850. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  74851. * This allowed control for front to back rendering or reversly depending of the special needs.
  74852. *
  74853. * @param renderingGroupId The rendering group id corresponding to its index
  74854. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  74855. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  74856. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  74857. */
  74858. 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;
  74859. /**
  74860. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  74861. *
  74862. * @param renderingGroupId The rendering group id corresponding to its index
  74863. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  74864. */
  74865. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  74866. /**
  74867. * Clones the texture.
  74868. * @returns the cloned texture
  74869. */
  74870. clone(): RenderTargetTexture;
  74871. /**
  74872. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  74873. * @returns The JSON representation of the texture
  74874. */
  74875. serialize(): any;
  74876. /**
  74877. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  74878. */
  74879. disposeFramebufferObjects(): void;
  74880. /**
  74881. * Dispose the texture and release its associated resources.
  74882. */
  74883. dispose(): void;
  74884. /** @hidden */
  74885. _rebuild(): void;
  74886. /**
  74887. * Clear the info related to rendering groups preventing retention point in material dispose.
  74888. */
  74889. freeRenderingGroups(): void;
  74890. }
  74891. }
  74892. declare module BABYLON {
  74893. /**
  74894. * Mirror texture can be used to simulate the view from a mirror in a scene.
  74895. * It will dynamically be rendered every frame to adapt to the camera point of view.
  74896. * You can then easily use it as a reflectionTexture on a flat surface.
  74897. * In case the surface is not a plane, please consider relying on reflection probes.
  74898. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  74899. */
  74900. export class MirrorTexture extends RenderTargetTexture {
  74901. private scene;
  74902. /**
  74903. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  74904. * 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.
  74905. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  74906. */
  74907. mirrorPlane: Plane;
  74908. /**
  74909. * Define the blur ratio used to blur the reflection if needed.
  74910. */
  74911. blurRatio: number;
  74912. /**
  74913. * Define the adaptive blur kernel used to blur the reflection if needed.
  74914. * This will autocompute the closest best match for the `blurKernel`
  74915. */
  74916. adaptiveBlurKernel: number;
  74917. /**
  74918. * Define the blur kernel used to blur the reflection if needed.
  74919. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  74920. */
  74921. blurKernel: number;
  74922. /**
  74923. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  74924. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  74925. */
  74926. blurKernelX: number;
  74927. /**
  74928. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  74929. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  74930. */
  74931. blurKernelY: number;
  74932. private _autoComputeBlurKernel;
  74933. protected _onRatioRescale(): void;
  74934. private _updateGammaSpace;
  74935. private _imageProcessingConfigChangeObserver;
  74936. private _transformMatrix;
  74937. private _mirrorMatrix;
  74938. private _savedViewMatrix;
  74939. private _blurX;
  74940. private _blurY;
  74941. private _adaptiveBlurKernel;
  74942. private _blurKernelX;
  74943. private _blurKernelY;
  74944. private _blurRatio;
  74945. /**
  74946. * Instantiates a Mirror Texture.
  74947. * Mirror texture can be used to simulate the view from a mirror in a scene.
  74948. * It will dynamically be rendered every frame to adapt to the camera point of view.
  74949. * You can then easily use it as a reflectionTexture on a flat surface.
  74950. * In case the surface is not a plane, please consider relying on reflection probes.
  74951. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  74952. * @param name
  74953. * @param size
  74954. * @param scene
  74955. * @param generateMipMaps
  74956. * @param type
  74957. * @param samplingMode
  74958. * @param generateDepthBuffer
  74959. */
  74960. constructor(name: string, size: number | {
  74961. width: number;
  74962. height: number;
  74963. } | {
  74964. ratio: number;
  74965. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  74966. private _preparePostProcesses;
  74967. /**
  74968. * Clone the mirror texture.
  74969. * @returns the cloned texture
  74970. */
  74971. clone(): MirrorTexture;
  74972. /**
  74973. * Serialize the texture to a JSON representation you could use in Parse later on
  74974. * @returns the serialized JSON representation
  74975. */
  74976. serialize(): any;
  74977. /**
  74978. * Dispose the texture and release its associated resources.
  74979. */
  74980. dispose(): void;
  74981. }
  74982. }
  74983. declare module BABYLON {
  74984. /**
  74985. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  74986. * @see http://doc.babylonjs.com/babylon101/materials#texture
  74987. */
  74988. export class Texture extends BaseTexture {
  74989. /** @hidden */
  74990. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  74991. /** @hidden */
  74992. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  74993. /** @hidden */
  74994. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  74995. /** nearest is mag = nearest and min = nearest and mip = linear */
  74996. static readonly NEAREST_SAMPLINGMODE: number;
  74997. /** nearest is mag = nearest and min = nearest and mip = linear */
  74998. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  74999. /** Bilinear is mag = linear and min = linear and mip = nearest */
  75000. static readonly BILINEAR_SAMPLINGMODE: number;
  75001. /** Bilinear is mag = linear and min = linear and mip = nearest */
  75002. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  75003. /** Trilinear is mag = linear and min = linear and mip = linear */
  75004. static readonly TRILINEAR_SAMPLINGMODE: number;
  75005. /** Trilinear is mag = linear and min = linear and mip = linear */
  75006. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  75007. /** mag = nearest and min = nearest and mip = nearest */
  75008. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  75009. /** mag = nearest and min = linear and mip = nearest */
  75010. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  75011. /** mag = nearest and min = linear and mip = linear */
  75012. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  75013. /** mag = nearest and min = linear and mip = none */
  75014. static readonly NEAREST_LINEAR: number;
  75015. /** mag = nearest and min = nearest and mip = none */
  75016. static readonly NEAREST_NEAREST: number;
  75017. /** mag = linear and min = nearest and mip = nearest */
  75018. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  75019. /** mag = linear and min = nearest and mip = linear */
  75020. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  75021. /** mag = linear and min = linear and mip = none */
  75022. static readonly LINEAR_LINEAR: number;
  75023. /** mag = linear and min = nearest and mip = none */
  75024. static readonly LINEAR_NEAREST: number;
  75025. /** Explicit coordinates mode */
  75026. static readonly EXPLICIT_MODE: number;
  75027. /** Spherical coordinates mode */
  75028. static readonly SPHERICAL_MODE: number;
  75029. /** Planar coordinates mode */
  75030. static readonly PLANAR_MODE: number;
  75031. /** Cubic coordinates mode */
  75032. static readonly CUBIC_MODE: number;
  75033. /** Projection coordinates mode */
  75034. static readonly PROJECTION_MODE: number;
  75035. /** Inverse Cubic coordinates mode */
  75036. static readonly SKYBOX_MODE: number;
  75037. /** Inverse Cubic coordinates mode */
  75038. static readonly INVCUBIC_MODE: number;
  75039. /** Equirectangular coordinates mode */
  75040. static readonly EQUIRECTANGULAR_MODE: number;
  75041. /** Equirectangular Fixed coordinates mode */
  75042. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  75043. /** Equirectangular Fixed Mirrored coordinates mode */
  75044. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  75045. /** Texture is not repeating outside of 0..1 UVs */
  75046. static readonly CLAMP_ADDRESSMODE: number;
  75047. /** Texture is repeating outside of 0..1 UVs */
  75048. static readonly WRAP_ADDRESSMODE: number;
  75049. /** Texture is repeating and mirrored */
  75050. static readonly MIRROR_ADDRESSMODE: number;
  75051. /**
  75052. * 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
  75053. */
  75054. static UseSerializedUrlIfAny: boolean;
  75055. /**
  75056. * Define the url of the texture.
  75057. */
  75058. url: Nullable<string>;
  75059. /**
  75060. * Define an offset on the texture to offset the u coordinates of the UVs
  75061. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  75062. */
  75063. uOffset: number;
  75064. /**
  75065. * Define an offset on the texture to offset the v coordinates of the UVs
  75066. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  75067. */
  75068. vOffset: number;
  75069. /**
  75070. * Define an offset on the texture to scale the u coordinates of the UVs
  75071. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  75072. */
  75073. uScale: number;
  75074. /**
  75075. * Define an offset on the texture to scale the v coordinates of the UVs
  75076. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  75077. */
  75078. vScale: number;
  75079. /**
  75080. * Define an offset on the texture to rotate around the u coordinates of the UVs
  75081. * @see http://doc.babylonjs.com/how_to/more_materials
  75082. */
  75083. uAng: number;
  75084. /**
  75085. * Define an offset on the texture to rotate around the v coordinates of the UVs
  75086. * @see http://doc.babylonjs.com/how_to/more_materials
  75087. */
  75088. vAng: number;
  75089. /**
  75090. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  75091. * @see http://doc.babylonjs.com/how_to/more_materials
  75092. */
  75093. wAng: number;
  75094. /**
  75095. * Defines the center of rotation (U)
  75096. */
  75097. uRotationCenter: number;
  75098. /**
  75099. * Defines the center of rotation (V)
  75100. */
  75101. vRotationCenter: number;
  75102. /**
  75103. * Defines the center of rotation (W)
  75104. */
  75105. wRotationCenter: number;
  75106. /**
  75107. * Are mip maps generated for this texture or not.
  75108. */
  75109. readonly noMipmap: boolean;
  75110. private _noMipmap;
  75111. /** @hidden */
  75112. _invertY: boolean;
  75113. private _rowGenerationMatrix;
  75114. private _cachedTextureMatrix;
  75115. private _projectionModeMatrix;
  75116. private _t0;
  75117. private _t1;
  75118. private _t2;
  75119. private _cachedUOffset;
  75120. private _cachedVOffset;
  75121. private _cachedUScale;
  75122. private _cachedVScale;
  75123. private _cachedUAng;
  75124. private _cachedVAng;
  75125. private _cachedWAng;
  75126. private _cachedProjectionMatrixId;
  75127. private _cachedCoordinatesMode;
  75128. /** @hidden */
  75129. protected _initialSamplingMode: number;
  75130. /** @hidden */
  75131. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  75132. private _deleteBuffer;
  75133. protected _format: Nullable<number>;
  75134. private _delayedOnLoad;
  75135. private _delayedOnError;
  75136. /**
  75137. * Observable triggered once the texture has been loaded.
  75138. */
  75139. onLoadObservable: Observable<Texture>;
  75140. protected _isBlocking: boolean;
  75141. /**
  75142. * Is the texture preventing material to render while loading.
  75143. * If false, a default texture will be used instead of the loading one during the preparation step.
  75144. */
  75145. isBlocking: boolean;
  75146. /**
  75147. * Get the current sampling mode associated with the texture.
  75148. */
  75149. readonly samplingMode: number;
  75150. /**
  75151. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  75152. */
  75153. readonly invertY: boolean;
  75154. /**
  75155. * Instantiates a new texture.
  75156. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  75157. * @see http://doc.babylonjs.com/babylon101/materials#texture
  75158. * @param url define the url of the picture to load as a texture
  75159. * @param scene define the scene the texture will belong to
  75160. * @param noMipmap define if the texture will require mip maps or not
  75161. * @param invertY define if the texture needs to be inverted on the y axis during loading
  75162. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  75163. * @param onLoad define a callback triggered when the texture has been loaded
  75164. * @param onError define a callback triggered when an error occurred during the loading session
  75165. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  75166. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  75167. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  75168. */
  75169. 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);
  75170. /**
  75171. * Update the url (and optional buffer) of this texture if url was null during construction.
  75172. * @param url the url of the texture
  75173. * @param buffer the buffer of the texture (defaults to null)
  75174. * @param onLoad callback called when the texture is loaded (defaults to null)
  75175. */
  75176. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  75177. /**
  75178. * Finish the loading sequence of a texture flagged as delayed load.
  75179. * @hidden
  75180. */
  75181. delayLoad(): void;
  75182. private _prepareRowForTextureGeneration;
  75183. /**
  75184. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  75185. * @returns the transform matrix of the texture.
  75186. */
  75187. getTextureMatrix(): Matrix;
  75188. /**
  75189. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  75190. * @returns The reflection texture transform
  75191. */
  75192. getReflectionTextureMatrix(): Matrix;
  75193. /**
  75194. * Clones the texture.
  75195. * @returns the cloned texture
  75196. */
  75197. clone(): Texture;
  75198. /**
  75199. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  75200. * @returns The JSON representation of the texture
  75201. */
  75202. serialize(): any;
  75203. /**
  75204. * Get the current class name of the texture useful for serialization or dynamic coding.
  75205. * @returns "Texture"
  75206. */
  75207. getClassName(): string;
  75208. /**
  75209. * Dispose the texture and release its associated resources.
  75210. */
  75211. dispose(): void;
  75212. /**
  75213. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  75214. * @param parsedTexture Define the JSON representation of the texture
  75215. * @param scene Define the scene the parsed texture should be instantiated in
  75216. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  75217. * @returns The parsed texture if successful
  75218. */
  75219. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  75220. /**
  75221. * Creates a texture from its base 64 representation.
  75222. * @param data Define the base64 payload without the data: prefix
  75223. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  75224. * @param scene Define the scene the texture should belong to
  75225. * @param noMipmap Forces the texture to not create mip map information if true
  75226. * @param invertY define if the texture needs to be inverted on the y axis during loading
  75227. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  75228. * @param onLoad define a callback triggered when the texture has been loaded
  75229. * @param onError define a callback triggered when an error occurred during the loading session
  75230. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  75231. * @returns the created texture
  75232. */
  75233. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  75234. /**
  75235. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  75236. * @param data Define the base64 payload without the data: prefix
  75237. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  75238. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  75239. * @param scene Define the scene the texture should belong to
  75240. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  75241. * @param noMipmap Forces the texture to not create mip map information if true
  75242. * @param invertY define if the texture needs to be inverted on the y axis during loading
  75243. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  75244. * @param onLoad define a callback triggered when the texture has been loaded
  75245. * @param onError define a callback triggered when an error occurred during the loading session
  75246. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  75247. * @returns the created texture
  75248. */
  75249. 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;
  75250. }
  75251. }
  75252. declare module BABYLON {
  75253. /**
  75254. * Raw texture can help creating a texture directly from an array of data.
  75255. * This can be super useful if you either get the data from an uncompressed source or
  75256. * if you wish to create your texture pixel by pixel.
  75257. */
  75258. export class RawTexture extends Texture {
  75259. /**
  75260. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  75261. */
  75262. format: number;
  75263. private _engine;
  75264. /**
  75265. * Instantiates a new RawTexture.
  75266. * Raw texture can help creating a texture directly from an array of data.
  75267. * This can be super useful if you either get the data from an uncompressed source or
  75268. * if you wish to create your texture pixel by pixel.
  75269. * @param data define the array of data to use to create the texture
  75270. * @param width define the width of the texture
  75271. * @param height define the height of the texture
  75272. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  75273. * @param scene define the scene the texture belongs to
  75274. * @param generateMipMaps define whether mip maps should be generated or not
  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. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  75278. */
  75279. constructor(data: ArrayBufferView, width: number, height: number,
  75280. /**
  75281. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  75282. */
  75283. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  75284. /**
  75285. * Updates the texture underlying data.
  75286. * @param data Define the new data of the texture
  75287. */
  75288. update(data: ArrayBufferView): void;
  75289. /**
  75290. * Creates a luminance texture from some data.
  75291. * @param data Define the texture data
  75292. * @param width Define the width of the texture
  75293. * @param height Define the height of the texture
  75294. * @param scene Define the scene the texture belongs to
  75295. * @param generateMipMaps Define whether or not to create mip maps for the texture
  75296. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  75297. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  75298. * @returns the luminance texture
  75299. */
  75300. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  75301. /**
  75302. * Creates a luminance alpha texture from some data.
  75303. * @param data Define the texture data
  75304. * @param width Define the width of the texture
  75305. * @param height Define the height of the texture
  75306. * @param scene Define the scene the texture belongs to
  75307. * @param generateMipMaps Define whether or not to create mip maps for the texture
  75308. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  75309. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  75310. * @returns the luminance alpha texture
  75311. */
  75312. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  75313. /**
  75314. * Creates an alpha texture from some data.
  75315. * @param data Define the texture data
  75316. * @param width Define the width of the texture
  75317. * @param height Define the height of the texture
  75318. * @param scene Define the scene the texture belongs to
  75319. * @param generateMipMaps Define whether or not to create mip maps for the texture
  75320. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  75321. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  75322. * @returns the alpha texture
  75323. */
  75324. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  75325. /**
  75326. * Creates a RGB texture from some data.
  75327. * @param data Define the texture data
  75328. * @param width Define the width of the texture
  75329. * @param height Define the height of the texture
  75330. * @param scene Define the scene the texture belongs to
  75331. * @param generateMipMaps Define whether or not to create mip maps for the texture
  75332. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  75333. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  75334. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  75335. * @returns the RGB alpha texture
  75336. */
  75337. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  75338. /**
  75339. * Creates a RGBA texture from some data.
  75340. * @param data Define the texture data
  75341. * @param width Define the width of the texture
  75342. * @param height Define the height of the texture
  75343. * @param scene Define the scene the texture belongs to
  75344. * @param generateMipMaps Define whether or not to create mip maps for the texture
  75345. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  75346. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  75347. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  75348. * @returns the RGBA texture
  75349. */
  75350. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  75351. /**
  75352. * Creates a R texture from some data.
  75353. * @param data Define the texture data
  75354. * @param width Define the width of the texture
  75355. * @param height Define the height of the texture
  75356. * @param scene Define the scene the texture belongs to
  75357. * @param generateMipMaps Define whether or not to create mip maps for the texture
  75358. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  75359. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  75360. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  75361. * @returns the R texture
  75362. */
  75363. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  75364. }
  75365. }
  75366. declare module BABYLON {
  75367. /**
  75368. * Defines a runtime animation
  75369. */
  75370. export class RuntimeAnimation {
  75371. private _events;
  75372. /**
  75373. * The current frame of the runtime animation
  75374. */
  75375. private _currentFrame;
  75376. /**
  75377. * The animation used by the runtime animation
  75378. */
  75379. private _animation;
  75380. /**
  75381. * The target of the runtime animation
  75382. */
  75383. private _target;
  75384. /**
  75385. * The initiating animatable
  75386. */
  75387. private _host;
  75388. /**
  75389. * The original value of the runtime animation
  75390. */
  75391. private _originalValue;
  75392. /**
  75393. * The original blend value of the runtime animation
  75394. */
  75395. private _originalBlendValue;
  75396. /**
  75397. * The offsets cache of the runtime animation
  75398. */
  75399. private _offsetsCache;
  75400. /**
  75401. * The high limits cache of the runtime animation
  75402. */
  75403. private _highLimitsCache;
  75404. /**
  75405. * Specifies if the runtime animation has been stopped
  75406. */
  75407. private _stopped;
  75408. /**
  75409. * The blending factor of the runtime animation
  75410. */
  75411. private _blendingFactor;
  75412. /**
  75413. * The BabylonJS scene
  75414. */
  75415. private _scene;
  75416. /**
  75417. * The current value of the runtime animation
  75418. */
  75419. private _currentValue;
  75420. /** @hidden */
  75421. _workValue: any;
  75422. /**
  75423. * The active target of the runtime animation
  75424. */
  75425. private _activeTarget;
  75426. /**
  75427. * The target path of the runtime animation
  75428. */
  75429. private _targetPath;
  75430. /**
  75431. * The weight of the runtime animation
  75432. */
  75433. private _weight;
  75434. /**
  75435. * The ratio offset of the runtime animation
  75436. */
  75437. private _ratioOffset;
  75438. /**
  75439. * The previous delay of the runtime animation
  75440. */
  75441. private _previousDelay;
  75442. /**
  75443. * The previous ratio of the runtime animation
  75444. */
  75445. private _previousRatio;
  75446. /**
  75447. * Gets the current frame of the runtime animation
  75448. */
  75449. readonly currentFrame: number;
  75450. /**
  75451. * Gets the weight of the runtime animation
  75452. */
  75453. readonly weight: number;
  75454. /**
  75455. * Gets the current value of the runtime animation
  75456. */
  75457. readonly currentValue: any;
  75458. /**
  75459. * Gets the target path of the runtime animation
  75460. */
  75461. readonly targetPath: string;
  75462. /**
  75463. * Gets the actual target of the runtime animation
  75464. */
  75465. readonly target: any;
  75466. /**
  75467. * Create a new RuntimeAnimation object
  75468. * @param target defines the target of the animation
  75469. * @param animation defines the source animation object
  75470. * @param scene defines the hosting scene
  75471. * @param host defines the initiating Animatable
  75472. */
  75473. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  75474. /**
  75475. * Gets the animation from the runtime animation
  75476. */
  75477. readonly animation: Animation;
  75478. /**
  75479. * Resets the runtime animation to the beginning
  75480. * @param restoreOriginal defines whether to restore the target property to the original value
  75481. */
  75482. reset(restoreOriginal?: boolean): void;
  75483. /**
  75484. * Specifies if the runtime animation is stopped
  75485. * @returns Boolean specifying if the runtime animation is stopped
  75486. */
  75487. isStopped(): boolean;
  75488. /**
  75489. * Disposes of the runtime animation
  75490. */
  75491. dispose(): void;
  75492. /**
  75493. * Interpolates the animation from the current frame
  75494. * @param currentFrame The frame to interpolate the animation to
  75495. * @param repeatCount The number of times that the animation should loop
  75496. * @param loopMode The type of looping mode to use
  75497. * @param offsetValue Animation offset value
  75498. * @param highLimitValue The high limit value
  75499. * @returns The interpolated value
  75500. */
  75501. private _interpolate;
  75502. /**
  75503. * Apply the interpolated value to the target
  75504. * @param currentValue defines the value computed by the animation
  75505. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  75506. */
  75507. setValue(currentValue: any, weight?: number): void;
  75508. private _setValue;
  75509. /**
  75510. * Gets the loop pmode of the runtime animation
  75511. * @returns Loop Mode
  75512. */
  75513. private _getCorrectLoopMode;
  75514. /**
  75515. * Move the current animation to a given frame
  75516. * @param frame defines the frame to move to
  75517. */
  75518. goToFrame(frame: number): void;
  75519. /**
  75520. * @hidden Internal use only
  75521. */
  75522. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  75523. /**
  75524. * Execute the current animation
  75525. * @param delay defines the delay to add to the current frame
  75526. * @param from defines the lower bound of the animation range
  75527. * @param to defines the upper bound of the animation range
  75528. * @param loop defines if the current animation must loop
  75529. * @param speedRatio defines the current speed ratio
  75530. * @param weight defines the weight of the animation (default is -1 so no weight)
  75531. * @param onLoop optional callback called when animation loops
  75532. * @returns a boolean indicating if the animation is running
  75533. */
  75534. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number, onLoop?: () => void): boolean;
  75535. }
  75536. }
  75537. declare module BABYLON {
  75538. /**
  75539. * Class used to store an actual running animation
  75540. */
  75541. export class Animatable {
  75542. /** defines the target object */
  75543. target: any;
  75544. /** defines the starting frame number (default is 0) */
  75545. fromFrame: number;
  75546. /** defines the ending frame number (default is 100) */
  75547. toFrame: number;
  75548. /** defines if the animation must loop (default is false) */
  75549. loopAnimation: boolean;
  75550. /** defines a callback to call when animation ends if it is not looping */
  75551. onAnimationEnd?: (() => void) | null | undefined;
  75552. /** defines a callback to call when animation loops */
  75553. onAnimationLoop?: (() => void) | null | undefined;
  75554. private _localDelayOffset;
  75555. private _pausedDelay;
  75556. private _runtimeAnimations;
  75557. private _paused;
  75558. private _scene;
  75559. private _speedRatio;
  75560. private _weight;
  75561. private _syncRoot;
  75562. /**
  75563. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  75564. * This will only apply for non looping animation (default is true)
  75565. */
  75566. disposeOnEnd: boolean;
  75567. /**
  75568. * Gets a boolean indicating if the animation has started
  75569. */
  75570. animationStarted: boolean;
  75571. /**
  75572. * Observer raised when the animation ends
  75573. */
  75574. onAnimationEndObservable: Observable<Animatable>;
  75575. /**
  75576. * Observer raised when the animation loops
  75577. */
  75578. onAnimationLoopObservable: Observable<Animatable>;
  75579. /**
  75580. * Gets the root Animatable used to synchronize and normalize animations
  75581. */
  75582. readonly syncRoot: Animatable;
  75583. /**
  75584. * Gets the current frame of the first RuntimeAnimation
  75585. * Used to synchronize Animatables
  75586. */
  75587. readonly masterFrame: number;
  75588. /**
  75589. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  75590. */
  75591. weight: number;
  75592. /**
  75593. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  75594. */
  75595. speedRatio: number;
  75596. /**
  75597. * Creates a new Animatable
  75598. * @param scene defines the hosting scene
  75599. * @param target defines the target object
  75600. * @param fromFrame defines the starting frame number (default is 0)
  75601. * @param toFrame defines the ending frame number (default is 100)
  75602. * @param loopAnimation defines if the animation must loop (default is false)
  75603. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  75604. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  75605. * @param animations defines a group of animation to add to the new Animatable
  75606. * @param onAnimationLoop defines a callback to call when animation loops
  75607. */
  75608. constructor(scene: Scene,
  75609. /** defines the target object */
  75610. target: any,
  75611. /** defines the starting frame number (default is 0) */
  75612. fromFrame?: number,
  75613. /** defines the ending frame number (default is 100) */
  75614. toFrame?: number,
  75615. /** defines if the animation must loop (default is false) */
  75616. loopAnimation?: boolean, speedRatio?: number,
  75617. /** defines a callback to call when animation ends if it is not looping */
  75618. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  75619. /** defines a callback to call when animation loops */
  75620. onAnimationLoop?: (() => void) | null | undefined);
  75621. /**
  75622. * Synchronize and normalize current Animatable with a source Animatable
  75623. * This is useful when using animation weights and when animations are not of the same length
  75624. * @param root defines the root Animatable to synchronize with
  75625. * @returns the current Animatable
  75626. */
  75627. syncWith(root: Animatable): Animatable;
  75628. /**
  75629. * Gets the list of runtime animations
  75630. * @returns an array of RuntimeAnimation
  75631. */
  75632. getAnimations(): RuntimeAnimation[];
  75633. /**
  75634. * Adds more animations to the current animatable
  75635. * @param target defines the target of the animations
  75636. * @param animations defines the new animations to add
  75637. */
  75638. appendAnimations(target: any, animations: Animation[]): void;
  75639. /**
  75640. * Gets the source animation for a specific property
  75641. * @param property defines the propertyu to look for
  75642. * @returns null or the source animation for the given property
  75643. */
  75644. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  75645. /**
  75646. * Gets the runtime animation for a specific property
  75647. * @param property defines the propertyu to look for
  75648. * @returns null or the runtime animation for the given property
  75649. */
  75650. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  75651. /**
  75652. * Resets the animatable to its original state
  75653. */
  75654. reset(): void;
  75655. /**
  75656. * Allows the animatable to blend with current running animations
  75657. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  75658. * @param blendingSpeed defines the blending speed to use
  75659. */
  75660. enableBlending(blendingSpeed: number): void;
  75661. /**
  75662. * Disable animation blending
  75663. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  75664. */
  75665. disableBlending(): void;
  75666. /**
  75667. * Jump directly to a given frame
  75668. * @param frame defines the frame to jump to
  75669. */
  75670. goToFrame(frame: number): void;
  75671. /**
  75672. * Pause the animation
  75673. */
  75674. pause(): void;
  75675. /**
  75676. * Restart the animation
  75677. */
  75678. restart(): void;
  75679. private _raiseOnAnimationEnd;
  75680. /**
  75681. * Stop and delete the current animation
  75682. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  75683. * @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)
  75684. */
  75685. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  75686. /**
  75687. * Wait asynchronously for the animation to end
  75688. * @returns a promise which will be fullfilled when the animation ends
  75689. */
  75690. waitAsync(): Promise<Animatable>;
  75691. /** @hidden */
  75692. _animate(delay: number): boolean;
  75693. }
  75694. interface Scene {
  75695. /** @hidden */
  75696. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  75697. /** @hidden */
  75698. _processLateAnimationBindingsForMatrices(holder: {
  75699. totalWeight: number;
  75700. animations: RuntimeAnimation[];
  75701. originalValue: Matrix;
  75702. }): any;
  75703. /** @hidden */
  75704. _processLateAnimationBindingsForQuaternions(holder: {
  75705. totalWeight: number;
  75706. animations: RuntimeAnimation[];
  75707. originalValue: Quaternion;
  75708. }, refQuaternion: Quaternion): Quaternion;
  75709. /** @hidden */
  75710. _processLateAnimationBindings(): void;
  75711. /**
  75712. * Will start the animation sequence of a given target
  75713. * @param target defines the target
  75714. * @param from defines from which frame should animation start
  75715. * @param to defines until which frame should animation run.
  75716. * @param weight defines the weight to apply to the animation (1.0 by default)
  75717. * @param loop defines if the animation loops
  75718. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  75719. * @param onAnimationEnd defines the function to be executed when the animation ends
  75720. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  75721. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  75722. * @param onAnimationLoop defines the callback to call when an animation loops
  75723. * @returns the animatable object created for this animation
  75724. */
  75725. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  75726. /**
  75727. * Will start the animation sequence of a given target
  75728. * @param target defines the target
  75729. * @param from defines from which frame should animation start
  75730. * @param to defines until which frame should animation run.
  75731. * @param loop defines if the animation loops
  75732. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  75733. * @param onAnimationEnd defines the function to be executed when the animation ends
  75734. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  75735. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  75736. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  75737. * @param onAnimationLoop defines the callback to call when an animation loops
  75738. * @returns the animatable object created for this animation
  75739. */
  75740. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  75741. /**
  75742. * Will start the animation sequence of a given target and its hierarchy
  75743. * @param target defines the target
  75744. * @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.
  75745. * @param from defines from which frame should animation start
  75746. * @param to defines until which frame should animation run.
  75747. * @param loop defines if the animation loops
  75748. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  75749. * @param onAnimationEnd defines the function to be executed when the animation ends
  75750. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  75751. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  75752. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  75753. * @param onAnimationLoop defines the callback to call when an animation loops
  75754. * @returns the list of created animatables
  75755. */
  75756. 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[];
  75757. /**
  75758. * Begin a new animation on a given node
  75759. * @param target defines the target where the animation will take place
  75760. * @param animations defines the list of animations to start
  75761. * @param from defines the initial value
  75762. * @param to defines the final value
  75763. * @param loop defines if you want animation to loop (off by default)
  75764. * @param speedRatio defines the speed ratio to apply to all animations
  75765. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  75766. * @param onAnimationLoop defines the callback to call when an animation loops
  75767. * @returns the list of created animatables
  75768. */
  75769. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  75770. /**
  75771. * Begin a new animation on a given node and its hierarchy
  75772. * @param target defines the root node where the animation will take place
  75773. * @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.
  75774. * @param animations defines the list of animations to start
  75775. * @param from defines the initial value
  75776. * @param to defines the final value
  75777. * @param loop defines if you want animation to loop (off by default)
  75778. * @param speedRatio defines the speed ratio to apply to all animations
  75779. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  75780. * @param onAnimationLoop defines the callback to call when an animation loops
  75781. * @returns the list of animatables created for all nodes
  75782. */
  75783. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  75784. /**
  75785. * Gets the animatable associated with a specific target
  75786. * @param target defines the target of the animatable
  75787. * @returns the required animatable if found
  75788. */
  75789. getAnimatableByTarget(target: any): Nullable<Animatable>;
  75790. /**
  75791. * Gets all animatables associated with a given target
  75792. * @param target defines the target to look animatables for
  75793. * @returns an array of Animatables
  75794. */
  75795. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  75796. /**
  75797. * Will stop the animation of the given target
  75798. * @param target - the target
  75799. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  75800. * @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)
  75801. */
  75802. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  75803. /**
  75804. * Stops and removes all animations that have been applied to the scene
  75805. */
  75806. stopAllAnimations(): void;
  75807. }
  75808. interface Bone {
  75809. /**
  75810. * Copy an animation range from another bone
  75811. * @param source defines the source bone
  75812. * @param rangeName defines the range name to copy
  75813. * @param frameOffset defines the frame offset
  75814. * @param rescaleAsRequired defines if rescaling must be applied if required
  75815. * @param skelDimensionsRatio defines the scaling ratio
  75816. * @returns true if operation was successful
  75817. */
  75818. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  75819. }
  75820. }
  75821. declare module BABYLON {
  75822. /**
  75823. * Class used to handle skinning animations
  75824. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  75825. */
  75826. export class Skeleton implements IAnimatable {
  75827. /** defines the skeleton name */
  75828. name: string;
  75829. /** defines the skeleton Id */
  75830. id: string;
  75831. /**
  75832. * Defines the list of child bones
  75833. */
  75834. bones: Bone[];
  75835. /**
  75836. * Defines an estimate of the dimension of the skeleton at rest
  75837. */
  75838. dimensionsAtRest: Vector3;
  75839. /**
  75840. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  75841. */
  75842. needInitialSkinMatrix: boolean;
  75843. /**
  75844. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  75845. */
  75846. overrideMesh: Nullable<AbstractMesh>;
  75847. /**
  75848. * Gets the list of animations attached to this skeleton
  75849. */
  75850. animations: Array<Animation>;
  75851. private _scene;
  75852. private _isDirty;
  75853. private _transformMatrices;
  75854. private _transformMatrixTexture;
  75855. private _meshesWithPoseMatrix;
  75856. private _animatables;
  75857. private _identity;
  75858. private _synchronizedWithMesh;
  75859. private _ranges;
  75860. private _lastAbsoluteTransformsUpdateId;
  75861. private _canUseTextureForBones;
  75862. /** @hidden */
  75863. _numBonesWithLinkedTransformNode: number;
  75864. /**
  75865. * Specifies if the skeleton should be serialized
  75866. */
  75867. doNotSerialize: boolean;
  75868. /**
  75869. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  75870. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  75871. */
  75872. useTextureToStoreBoneMatrices: boolean;
  75873. private _animationPropertiesOverride;
  75874. /**
  75875. * Gets or sets the animation properties override
  75876. */
  75877. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  75878. /**
  75879. * An observable triggered before computing the skeleton's matrices
  75880. */
  75881. onBeforeComputeObservable: Observable<Skeleton>;
  75882. /**
  75883. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  75884. */
  75885. readonly isUsingTextureForMatrices: boolean;
  75886. /**
  75887. * Creates a new skeleton
  75888. * @param name defines the skeleton name
  75889. * @param id defines the skeleton Id
  75890. * @param scene defines the hosting scene
  75891. */
  75892. constructor(
  75893. /** defines the skeleton name */
  75894. name: string,
  75895. /** defines the skeleton Id */
  75896. id: string, scene: Scene);
  75897. /**
  75898. * Gets the current object class name.
  75899. * @return the class name
  75900. */
  75901. getClassName(): string;
  75902. /**
  75903. * Returns an array containing the root bones
  75904. * @returns an array containing the root bones
  75905. */
  75906. getChildren(): Array<Bone>;
  75907. /**
  75908. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  75909. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  75910. * @returns a Float32Array containing matrices data
  75911. */
  75912. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  75913. /**
  75914. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  75915. * @returns a raw texture containing the data
  75916. */
  75917. getTransformMatrixTexture(): Nullable<RawTexture>;
  75918. /**
  75919. * Gets the current hosting scene
  75920. * @returns a scene object
  75921. */
  75922. getScene(): Scene;
  75923. /**
  75924. * Gets a string representing the current skeleton data
  75925. * @param fullDetails defines a boolean indicating if we want a verbose version
  75926. * @returns a string representing the current skeleton data
  75927. */
  75928. toString(fullDetails?: boolean): string;
  75929. /**
  75930. * Get bone's index searching by name
  75931. * @param name defines bone's name to search for
  75932. * @return the indice of the bone. Returns -1 if not found
  75933. */
  75934. getBoneIndexByName(name: string): number;
  75935. /**
  75936. * Creater a new animation range
  75937. * @param name defines the name of the range
  75938. * @param from defines the start key
  75939. * @param to defines the end key
  75940. */
  75941. createAnimationRange(name: string, from: number, to: number): void;
  75942. /**
  75943. * Delete a specific animation range
  75944. * @param name defines the name of the range
  75945. * @param deleteFrames defines if frames must be removed as well
  75946. */
  75947. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  75948. /**
  75949. * Gets a specific animation range
  75950. * @param name defines the name of the range to look for
  75951. * @returns the requested animation range or null if not found
  75952. */
  75953. getAnimationRange(name: string): Nullable<AnimationRange>;
  75954. /**
  75955. * Gets the list of all animation ranges defined on this skeleton
  75956. * @returns an array
  75957. */
  75958. getAnimationRanges(): Nullable<AnimationRange>[];
  75959. /**
  75960. * Copy animation range from a source skeleton.
  75961. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  75962. * @param source defines the source skeleton
  75963. * @param name defines the name of the range to copy
  75964. * @param rescaleAsRequired defines if rescaling must be applied if required
  75965. * @returns true if operation was successful
  75966. */
  75967. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  75968. /**
  75969. * Forces the skeleton to go to rest pose
  75970. */
  75971. returnToRest(): void;
  75972. private _getHighestAnimationFrame;
  75973. /**
  75974. * Begin a specific animation range
  75975. * @param name defines the name of the range to start
  75976. * @param loop defines if looping must be turned on (false by default)
  75977. * @param speedRatio defines the speed ratio to apply (1 by default)
  75978. * @param onAnimationEnd defines a callback which will be called when animation will end
  75979. * @returns a new animatable
  75980. */
  75981. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  75982. /** @hidden */
  75983. _markAsDirty(): void;
  75984. /** @hidden */
  75985. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  75986. /** @hidden */
  75987. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  75988. private _computeTransformMatrices;
  75989. /**
  75990. * Build all resources required to render a skeleton
  75991. */
  75992. prepare(): void;
  75993. /**
  75994. * Gets the list of animatables currently running for this skeleton
  75995. * @returns an array of animatables
  75996. */
  75997. getAnimatables(): IAnimatable[];
  75998. /**
  75999. * Clone the current skeleton
  76000. * @param name defines the name of the new skeleton
  76001. * @param id defines the id of the enw skeleton
  76002. * @returns the new skeleton
  76003. */
  76004. clone(name: string, id: string): Skeleton;
  76005. /**
  76006. * Enable animation blending for this skeleton
  76007. * @param blendingSpeed defines the blending speed to apply
  76008. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  76009. */
  76010. enableBlending(blendingSpeed?: number): void;
  76011. /**
  76012. * Releases all resources associated with the current skeleton
  76013. */
  76014. dispose(): void;
  76015. /**
  76016. * Serialize the skeleton in a JSON object
  76017. * @returns a JSON object
  76018. */
  76019. serialize(): any;
  76020. /**
  76021. * Creates a new skeleton from serialized data
  76022. * @param parsedSkeleton defines the serialized data
  76023. * @param scene defines the hosting scene
  76024. * @returns a new skeleton
  76025. */
  76026. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  76027. /**
  76028. * Compute all node absolute transforms
  76029. * @param forceUpdate defines if computation must be done even if cache is up to date
  76030. */
  76031. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  76032. /**
  76033. * Gets the root pose matrix
  76034. * @returns a matrix
  76035. */
  76036. getPoseMatrix(): Nullable<Matrix>;
  76037. /**
  76038. * Sorts bones per internal index
  76039. */
  76040. sortBones(): void;
  76041. private _sortBones;
  76042. }
  76043. }
  76044. declare module BABYLON {
  76045. /**
  76046. * Defines a target to use with MorphTargetManager
  76047. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  76048. */
  76049. export class MorphTarget implements IAnimatable {
  76050. /** defines the name of the target */
  76051. name: string;
  76052. /**
  76053. * Gets or sets the list of animations
  76054. */
  76055. animations: Animation[];
  76056. private _scene;
  76057. private _positions;
  76058. private _normals;
  76059. private _tangents;
  76060. private _influence;
  76061. /**
  76062. * Observable raised when the influence changes
  76063. */
  76064. onInfluenceChanged: Observable<boolean>;
  76065. /** @hidden */
  76066. _onDataLayoutChanged: Observable<void>;
  76067. /**
  76068. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  76069. */
  76070. influence: number;
  76071. /**
  76072. * Gets or sets the id of the morph Target
  76073. */
  76074. id: string;
  76075. private _animationPropertiesOverride;
  76076. /**
  76077. * Gets or sets the animation properties override
  76078. */
  76079. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  76080. /**
  76081. * Creates a new MorphTarget
  76082. * @param name defines the name of the target
  76083. * @param influence defines the influence to use
  76084. * @param scene defines the scene the morphtarget belongs to
  76085. */
  76086. constructor(
  76087. /** defines the name of the target */
  76088. name: string, influence?: number, scene?: Nullable<Scene>);
  76089. /**
  76090. * Gets a boolean defining if the target contains position data
  76091. */
  76092. readonly hasPositions: boolean;
  76093. /**
  76094. * Gets a boolean defining if the target contains normal data
  76095. */
  76096. readonly hasNormals: boolean;
  76097. /**
  76098. * Gets a boolean defining if the target contains tangent data
  76099. */
  76100. readonly hasTangents: boolean;
  76101. /**
  76102. * Affects position data to this target
  76103. * @param data defines the position data to use
  76104. */
  76105. setPositions(data: Nullable<FloatArray>): void;
  76106. /**
  76107. * Gets the position data stored in this target
  76108. * @returns a FloatArray containing the position data (or null if not present)
  76109. */
  76110. getPositions(): Nullable<FloatArray>;
  76111. /**
  76112. * Affects normal data to this target
  76113. * @param data defines the normal data to use
  76114. */
  76115. setNormals(data: Nullable<FloatArray>): void;
  76116. /**
  76117. * Gets the normal data stored in this target
  76118. * @returns a FloatArray containing the normal data (or null if not present)
  76119. */
  76120. getNormals(): Nullable<FloatArray>;
  76121. /**
  76122. * Affects tangent data to this target
  76123. * @param data defines the tangent data to use
  76124. */
  76125. setTangents(data: Nullable<FloatArray>): void;
  76126. /**
  76127. * Gets the tangent data stored in this target
  76128. * @returns a FloatArray containing the tangent data (or null if not present)
  76129. */
  76130. getTangents(): Nullable<FloatArray>;
  76131. /**
  76132. * Serializes the current target into a Serialization object
  76133. * @returns the serialized object
  76134. */
  76135. serialize(): any;
  76136. /**
  76137. * Returns the string "MorphTarget"
  76138. * @returns "MorphTarget"
  76139. */
  76140. getClassName(): string;
  76141. /**
  76142. * Creates a new target from serialized data
  76143. * @param serializationObject defines the serialized data to use
  76144. * @returns a new MorphTarget
  76145. */
  76146. static Parse(serializationObject: any): MorphTarget;
  76147. /**
  76148. * Creates a MorphTarget from mesh data
  76149. * @param mesh defines the source mesh
  76150. * @param name defines the name to use for the new target
  76151. * @param influence defines the influence to attach to the target
  76152. * @returns a new MorphTarget
  76153. */
  76154. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  76155. }
  76156. }
  76157. declare module BABYLON {
  76158. /**
  76159. * This class is used to deform meshes using morphing between different targets
  76160. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  76161. */
  76162. export class MorphTargetManager {
  76163. private _targets;
  76164. private _targetInfluenceChangedObservers;
  76165. private _targetDataLayoutChangedObservers;
  76166. private _activeTargets;
  76167. private _scene;
  76168. private _influences;
  76169. private _supportsNormals;
  76170. private _supportsTangents;
  76171. private _vertexCount;
  76172. private _uniqueId;
  76173. private _tempInfluences;
  76174. /**
  76175. * Creates a new MorphTargetManager
  76176. * @param scene defines the current scene
  76177. */
  76178. constructor(scene?: Nullable<Scene>);
  76179. /**
  76180. * Gets the unique ID of this manager
  76181. */
  76182. readonly uniqueId: number;
  76183. /**
  76184. * Gets the number of vertices handled by this manager
  76185. */
  76186. readonly vertexCount: number;
  76187. /**
  76188. * Gets a boolean indicating if this manager supports morphing of normals
  76189. */
  76190. readonly supportsNormals: boolean;
  76191. /**
  76192. * Gets a boolean indicating if this manager supports morphing of tangents
  76193. */
  76194. readonly supportsTangents: boolean;
  76195. /**
  76196. * Gets the number of targets stored in this manager
  76197. */
  76198. readonly numTargets: number;
  76199. /**
  76200. * Gets the number of influencers (ie. the number of targets with influences > 0)
  76201. */
  76202. readonly numInfluencers: number;
  76203. /**
  76204. * Gets the list of influences (one per target)
  76205. */
  76206. readonly influences: Float32Array;
  76207. /**
  76208. * Gets the active target at specified index. An active target is a target with an influence > 0
  76209. * @param index defines the index to check
  76210. * @returns the requested target
  76211. */
  76212. getActiveTarget(index: number): MorphTarget;
  76213. /**
  76214. * Gets the target at specified index
  76215. * @param index defines the index to check
  76216. * @returns the requested target
  76217. */
  76218. getTarget(index: number): MorphTarget;
  76219. /**
  76220. * Add a new target to this manager
  76221. * @param target defines the target to add
  76222. */
  76223. addTarget(target: MorphTarget): void;
  76224. /**
  76225. * Removes a target from the manager
  76226. * @param target defines the target to remove
  76227. */
  76228. removeTarget(target: MorphTarget): void;
  76229. /**
  76230. * Serializes the current manager into a Serialization object
  76231. * @returns the serialized object
  76232. */
  76233. serialize(): any;
  76234. private _syncActiveTargets;
  76235. /**
  76236. * Syncrhonize the targets with all the meshes using this morph target manager
  76237. */
  76238. synchronize(): void;
  76239. /**
  76240. * Creates a new MorphTargetManager from serialized data
  76241. * @param serializationObject defines the serialized data
  76242. * @param scene defines the hosting scene
  76243. * @returns the new MorphTargetManager
  76244. */
  76245. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  76246. }
  76247. }
  76248. declare module BABYLON {
  76249. /**
  76250. * Mesh representing the gorund
  76251. */
  76252. export class GroundMesh extends Mesh {
  76253. /** If octree should be generated */
  76254. generateOctree: boolean;
  76255. private _heightQuads;
  76256. /** @hidden */
  76257. _subdivisionsX: number;
  76258. /** @hidden */
  76259. _subdivisionsY: number;
  76260. /** @hidden */
  76261. _width: number;
  76262. /** @hidden */
  76263. _height: number;
  76264. /** @hidden */
  76265. _minX: number;
  76266. /** @hidden */
  76267. _maxX: number;
  76268. /** @hidden */
  76269. _minZ: number;
  76270. /** @hidden */
  76271. _maxZ: number;
  76272. constructor(name: string, scene: Scene);
  76273. /**
  76274. * "GroundMesh"
  76275. * @returns "GroundMesh"
  76276. */
  76277. getClassName(): string;
  76278. /**
  76279. * The minimum of x and y subdivisions
  76280. */
  76281. readonly subdivisions: number;
  76282. /**
  76283. * X subdivisions
  76284. */
  76285. readonly subdivisionsX: number;
  76286. /**
  76287. * Y subdivisions
  76288. */
  76289. readonly subdivisionsY: number;
  76290. /**
  76291. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  76292. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  76293. * @param chunksCount the number of subdivisions for x and y
  76294. * @param octreeBlocksSize (Default: 32)
  76295. */
  76296. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  76297. /**
  76298. * Returns a height (y) value in the Worl system :
  76299. * the ground altitude at the coordinates (x, z) expressed in the World system.
  76300. * @param x x coordinate
  76301. * @param z z coordinate
  76302. * @returns the ground y position if (x, z) are outside the ground surface.
  76303. */
  76304. getHeightAtCoordinates(x: number, z: number): number;
  76305. /**
  76306. * Returns a normalized vector (Vector3) orthogonal to the ground
  76307. * at the ground coordinates (x, z) expressed in the World system.
  76308. * @param x x coordinate
  76309. * @param z z coordinate
  76310. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  76311. */
  76312. getNormalAtCoordinates(x: number, z: number): Vector3;
  76313. /**
  76314. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  76315. * at the ground coordinates (x, z) expressed in the World system.
  76316. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  76317. * @param x x coordinate
  76318. * @param z z coordinate
  76319. * @param ref vector to store the result
  76320. * @returns the GroundMesh.
  76321. */
  76322. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  76323. /**
  76324. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  76325. * if the ground has been updated.
  76326. * This can be used in the render loop.
  76327. * @returns the GroundMesh.
  76328. */
  76329. updateCoordinateHeights(): GroundMesh;
  76330. private _getFacetAt;
  76331. private _initHeightQuads;
  76332. private _computeHeightQuads;
  76333. /**
  76334. * Serializes this ground mesh
  76335. * @param serializationObject object to write serialization to
  76336. */
  76337. serialize(serializationObject: any): void;
  76338. /**
  76339. * Parses a serialized ground mesh
  76340. * @param parsedMesh the serialized mesh
  76341. * @param scene the scene to create the ground mesh in
  76342. * @returns the created ground mesh
  76343. */
  76344. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  76345. }
  76346. }
  76347. declare module BABYLON {
  76348. /**
  76349. * Interface for Physics-Joint data
  76350. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  76351. */
  76352. export interface PhysicsJointData {
  76353. /**
  76354. * The main pivot of the joint
  76355. */
  76356. mainPivot?: Vector3;
  76357. /**
  76358. * The connected pivot of the joint
  76359. */
  76360. connectedPivot?: Vector3;
  76361. /**
  76362. * The main axis of the joint
  76363. */
  76364. mainAxis?: Vector3;
  76365. /**
  76366. * The connected axis of the joint
  76367. */
  76368. connectedAxis?: Vector3;
  76369. /**
  76370. * The collision of the joint
  76371. */
  76372. collision?: boolean;
  76373. /**
  76374. * Native Oimo/Cannon/Energy data
  76375. */
  76376. nativeParams?: any;
  76377. }
  76378. /**
  76379. * This is a holder class for the physics joint created by the physics plugin
  76380. * It holds a set of functions to control the underlying joint
  76381. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  76382. */
  76383. export class PhysicsJoint {
  76384. /**
  76385. * The type of the physics joint
  76386. */
  76387. type: number;
  76388. /**
  76389. * The data for the physics joint
  76390. */
  76391. jointData: PhysicsJointData;
  76392. private _physicsJoint;
  76393. protected _physicsPlugin: IPhysicsEnginePlugin;
  76394. /**
  76395. * Initializes the physics joint
  76396. * @param type The type of the physics joint
  76397. * @param jointData The data for the physics joint
  76398. */
  76399. constructor(
  76400. /**
  76401. * The type of the physics joint
  76402. */
  76403. type: number,
  76404. /**
  76405. * The data for the physics joint
  76406. */
  76407. jointData: PhysicsJointData);
  76408. /**
  76409. * Gets the physics joint
  76410. */
  76411. /**
  76412. * Sets the physics joint
  76413. */
  76414. physicsJoint: any;
  76415. /**
  76416. * Sets the physics plugin
  76417. */
  76418. physicsPlugin: IPhysicsEnginePlugin;
  76419. /**
  76420. * Execute a function that is physics-plugin specific.
  76421. * @param {Function} func the function that will be executed.
  76422. * It accepts two parameters: the physics world and the physics joint
  76423. */
  76424. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  76425. /**
  76426. * Distance-Joint type
  76427. */
  76428. static DistanceJoint: number;
  76429. /**
  76430. * Hinge-Joint type
  76431. */
  76432. static HingeJoint: number;
  76433. /**
  76434. * Ball-and-Socket joint type
  76435. */
  76436. static BallAndSocketJoint: number;
  76437. /**
  76438. * Wheel-Joint type
  76439. */
  76440. static WheelJoint: number;
  76441. /**
  76442. * Slider-Joint type
  76443. */
  76444. static SliderJoint: number;
  76445. /**
  76446. * Prismatic-Joint type
  76447. */
  76448. static PrismaticJoint: number;
  76449. /**
  76450. * Universal-Joint type
  76451. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  76452. */
  76453. static UniversalJoint: number;
  76454. /**
  76455. * Hinge-Joint 2 type
  76456. */
  76457. static Hinge2Joint: number;
  76458. /**
  76459. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  76460. */
  76461. static PointToPointJoint: number;
  76462. /**
  76463. * Spring-Joint type
  76464. */
  76465. static SpringJoint: number;
  76466. /**
  76467. * Lock-Joint type
  76468. */
  76469. static LockJoint: number;
  76470. }
  76471. /**
  76472. * A class representing a physics distance joint
  76473. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  76474. */
  76475. export class DistanceJoint extends PhysicsJoint {
  76476. /**
  76477. *
  76478. * @param jointData The data for the Distance-Joint
  76479. */
  76480. constructor(jointData: DistanceJointData);
  76481. /**
  76482. * Update the predefined distance.
  76483. * @param maxDistance The maximum preferred distance
  76484. * @param minDistance The minimum preferred distance
  76485. */
  76486. updateDistance(maxDistance: number, minDistance?: number): void;
  76487. }
  76488. /**
  76489. * Represents a Motor-Enabled Joint
  76490. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  76491. */
  76492. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  76493. /**
  76494. * Initializes the Motor-Enabled Joint
  76495. * @param type The type of the joint
  76496. * @param jointData The physica joint data for the joint
  76497. */
  76498. constructor(type: number, jointData: PhysicsJointData);
  76499. /**
  76500. * Set the motor values.
  76501. * Attention, this function is plugin specific. Engines won't react 100% the same.
  76502. * @param force the force to apply
  76503. * @param maxForce max force for this motor.
  76504. */
  76505. setMotor(force?: number, maxForce?: number): void;
  76506. /**
  76507. * Set the motor's limits.
  76508. * Attention, this function is plugin specific. Engines won't react 100% the same.
  76509. * @param upperLimit The upper limit of the motor
  76510. * @param lowerLimit The lower limit of the motor
  76511. */
  76512. setLimit(upperLimit: number, lowerLimit?: number): void;
  76513. }
  76514. /**
  76515. * This class represents a single physics Hinge-Joint
  76516. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  76517. */
  76518. export class HingeJoint extends MotorEnabledJoint {
  76519. /**
  76520. * Initializes the Hinge-Joint
  76521. * @param jointData The joint data for the Hinge-Joint
  76522. */
  76523. constructor(jointData: PhysicsJointData);
  76524. /**
  76525. * Set the motor values.
  76526. * Attention, this function is plugin specific. Engines won't react 100% the same.
  76527. * @param {number} force the force to apply
  76528. * @param {number} maxForce max force for this motor.
  76529. */
  76530. setMotor(force?: number, maxForce?: number): void;
  76531. /**
  76532. * Set the motor's limits.
  76533. * Attention, this function is plugin specific. Engines won't react 100% the same.
  76534. * @param upperLimit The upper limit of the motor
  76535. * @param lowerLimit The lower limit of the motor
  76536. */
  76537. setLimit(upperLimit: number, lowerLimit?: number): void;
  76538. }
  76539. /**
  76540. * This class represents a dual hinge physics joint (same as wheel joint)
  76541. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  76542. */
  76543. export class Hinge2Joint extends MotorEnabledJoint {
  76544. /**
  76545. * Initializes the Hinge2-Joint
  76546. * @param jointData The joint data for the Hinge2-Joint
  76547. */
  76548. constructor(jointData: PhysicsJointData);
  76549. /**
  76550. * Set the motor values.
  76551. * Attention, this function is plugin specific. Engines won't react 100% the same.
  76552. * @param {number} targetSpeed the speed the motor is to reach
  76553. * @param {number} maxForce max force for this motor.
  76554. * @param {motorIndex} the motor's index, 0 or 1.
  76555. */
  76556. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  76557. /**
  76558. * Set the motor limits.
  76559. * Attention, this function is plugin specific. Engines won't react 100% the same.
  76560. * @param {number} upperLimit the upper limit
  76561. * @param {number} lowerLimit lower limit
  76562. * @param {motorIndex} the motor's index, 0 or 1.
  76563. */
  76564. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  76565. }
  76566. /**
  76567. * Interface for a motor enabled joint
  76568. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  76569. */
  76570. export interface IMotorEnabledJoint {
  76571. /**
  76572. * Physics joint
  76573. */
  76574. physicsJoint: any;
  76575. /**
  76576. * Sets the motor of the motor-enabled joint
  76577. * @param force The force of the motor
  76578. * @param maxForce The maximum force of the motor
  76579. * @param motorIndex The index of the motor
  76580. */
  76581. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  76582. /**
  76583. * Sets the limit of the motor
  76584. * @param upperLimit The upper limit of the motor
  76585. * @param lowerLimit The lower limit of the motor
  76586. * @param motorIndex The index of the motor
  76587. */
  76588. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  76589. }
  76590. /**
  76591. * Joint data for a Distance-Joint
  76592. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  76593. */
  76594. export interface DistanceJointData extends PhysicsJointData {
  76595. /**
  76596. * Max distance the 2 joint objects can be apart
  76597. */
  76598. maxDistance: number;
  76599. }
  76600. /**
  76601. * Joint data from a spring joint
  76602. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  76603. */
  76604. export interface SpringJointData extends PhysicsJointData {
  76605. /**
  76606. * Length of the spring
  76607. */
  76608. length: number;
  76609. /**
  76610. * Stiffness of the spring
  76611. */
  76612. stiffness: number;
  76613. /**
  76614. * Damping of the spring
  76615. */
  76616. damping: number;
  76617. /** this callback will be called when applying the force to the impostors. */
  76618. forceApplicationCallback: () => void;
  76619. }
  76620. }
  76621. declare module BABYLON {
  76622. /**
  76623. * Interface used to describe a physics joint
  76624. */
  76625. export interface PhysicsImpostorJoint {
  76626. /** Defines the main impostor to which the joint is linked */
  76627. mainImpostor: PhysicsImpostor;
  76628. /** Defines the impostor that is connected to the main impostor using this joint */
  76629. connectedImpostor: PhysicsImpostor;
  76630. /** Defines the joint itself */
  76631. joint: PhysicsJoint;
  76632. }
  76633. /** @hidden */
  76634. export interface IPhysicsEnginePlugin {
  76635. world: any;
  76636. name: string;
  76637. setGravity(gravity: Vector3): void;
  76638. setTimeStep(timeStep: number): void;
  76639. getTimeStep(): number;
  76640. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  76641. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  76642. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  76643. generatePhysicsBody(impostor: PhysicsImpostor): void;
  76644. removePhysicsBody(impostor: PhysicsImpostor): void;
  76645. generateJoint(joint: PhysicsImpostorJoint): void;
  76646. removeJoint(joint: PhysicsImpostorJoint): void;
  76647. isSupported(): boolean;
  76648. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  76649. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  76650. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  76651. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  76652. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  76653. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  76654. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  76655. getBodyMass(impostor: PhysicsImpostor): number;
  76656. getBodyFriction(impostor: PhysicsImpostor): number;
  76657. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  76658. getBodyRestitution(impostor: PhysicsImpostor): number;
  76659. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  76660. sleepBody(impostor: PhysicsImpostor): void;
  76661. wakeUpBody(impostor: PhysicsImpostor): void;
  76662. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  76663. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  76664. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  76665. getRadius(impostor: PhysicsImpostor): number;
  76666. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  76667. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  76668. dispose(): void;
  76669. }
  76670. /**
  76671. * Interface used to define a physics engine
  76672. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  76673. */
  76674. export interface IPhysicsEngine {
  76675. /**
  76676. * Gets the gravity vector used by the simulation
  76677. */
  76678. gravity: Vector3;
  76679. /**
  76680. * Sets the gravity vector used by the simulation
  76681. * @param gravity defines the gravity vector to use
  76682. */
  76683. setGravity(gravity: Vector3): void;
  76684. /**
  76685. * Set the time step of the physics engine.
  76686. * Default is 1/60.
  76687. * To slow it down, enter 1/600 for example.
  76688. * To speed it up, 1/30
  76689. * @param newTimeStep the new timestep to apply to this world.
  76690. */
  76691. setTimeStep(newTimeStep: number): void;
  76692. /**
  76693. * Get the time step of the physics engine.
  76694. * @returns the current time step
  76695. */
  76696. getTimeStep(): number;
  76697. /**
  76698. * Release all resources
  76699. */
  76700. dispose(): void;
  76701. /**
  76702. * Gets the name of the current physics plugin
  76703. * @returns the name of the plugin
  76704. */
  76705. getPhysicsPluginName(): string;
  76706. /**
  76707. * Adding a new impostor for the impostor tracking.
  76708. * This will be done by the impostor itself.
  76709. * @param impostor the impostor to add
  76710. */
  76711. addImpostor(impostor: PhysicsImpostor): void;
  76712. /**
  76713. * Remove an impostor from the engine.
  76714. * This impostor and its mesh will not longer be updated by the physics engine.
  76715. * @param impostor the impostor to remove
  76716. */
  76717. removeImpostor(impostor: PhysicsImpostor): void;
  76718. /**
  76719. * Add a joint to the physics engine
  76720. * @param mainImpostor defines the main impostor to which the joint is added.
  76721. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  76722. * @param joint defines the joint that will connect both impostors.
  76723. */
  76724. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  76725. /**
  76726. * Removes a joint from the simulation
  76727. * @param mainImpostor defines the impostor used with the joint
  76728. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  76729. * @param joint defines the joint to remove
  76730. */
  76731. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  76732. /**
  76733. * Gets the current plugin used to run the simulation
  76734. * @returns current plugin
  76735. */
  76736. getPhysicsPlugin(): IPhysicsEnginePlugin;
  76737. /**
  76738. * Gets the list of physic impostors
  76739. * @returns an array of PhysicsImpostor
  76740. */
  76741. getImpostors(): Array<PhysicsImpostor>;
  76742. /**
  76743. * Gets the impostor for a physics enabled object
  76744. * @param object defines the object impersonated by the impostor
  76745. * @returns the PhysicsImpostor or null if not found
  76746. */
  76747. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  76748. /**
  76749. * Gets the impostor for a physics body object
  76750. * @param body defines physics body used by the impostor
  76751. * @returns the PhysicsImpostor or null if not found
  76752. */
  76753. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  76754. /**
  76755. * Called by the scene. No need to call it.
  76756. * @param delta defines the timespam between frames
  76757. */
  76758. _step(delta: number): void;
  76759. }
  76760. }
  76761. declare module BABYLON {
  76762. /**
  76763. * The interface for the physics imposter parameters
  76764. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  76765. */
  76766. export interface PhysicsImpostorParameters {
  76767. /**
  76768. * The mass of the physics imposter
  76769. */
  76770. mass: number;
  76771. /**
  76772. * The friction of the physics imposter
  76773. */
  76774. friction?: number;
  76775. /**
  76776. * The coefficient of restitution of the physics imposter
  76777. */
  76778. restitution?: number;
  76779. /**
  76780. * The native options of the physics imposter
  76781. */
  76782. nativeOptions?: any;
  76783. /**
  76784. * Specifies if the parent should be ignored
  76785. */
  76786. ignoreParent?: boolean;
  76787. /**
  76788. * Specifies if bi-directional transformations should be disabled
  76789. */
  76790. disableBidirectionalTransformation?: boolean;
  76791. }
  76792. /**
  76793. * Interface for a physics-enabled object
  76794. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  76795. */
  76796. export interface IPhysicsEnabledObject {
  76797. /**
  76798. * The position of the physics-enabled object
  76799. */
  76800. position: Vector3;
  76801. /**
  76802. * The rotation of the physics-enabled object
  76803. */
  76804. rotationQuaternion: Nullable<Quaternion>;
  76805. /**
  76806. * The scale of the physics-enabled object
  76807. */
  76808. scaling: Vector3;
  76809. /**
  76810. * The rotation of the physics-enabled object
  76811. */
  76812. rotation?: Vector3;
  76813. /**
  76814. * The parent of the physics-enabled object
  76815. */
  76816. parent?: any;
  76817. /**
  76818. * The bounding info of the physics-enabled object
  76819. * @returns The bounding info of the physics-enabled object
  76820. */
  76821. getBoundingInfo(): BoundingInfo;
  76822. /**
  76823. * Computes the world matrix
  76824. * @param force Specifies if the world matrix should be computed by force
  76825. * @returns A world matrix
  76826. */
  76827. computeWorldMatrix(force: boolean): Matrix;
  76828. /**
  76829. * Gets the world matrix
  76830. * @returns A world matrix
  76831. */
  76832. getWorldMatrix?(): Matrix;
  76833. /**
  76834. * Gets the child meshes
  76835. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  76836. * @returns An array of abstract meshes
  76837. */
  76838. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  76839. /**
  76840. * Gets the vertex data
  76841. * @param kind The type of vertex data
  76842. * @returns A nullable array of numbers, or a float32 array
  76843. */
  76844. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  76845. /**
  76846. * Gets the indices from the mesh
  76847. * @returns A nullable array of index arrays
  76848. */
  76849. getIndices?(): Nullable<IndicesArray>;
  76850. /**
  76851. * Gets the scene from the mesh
  76852. * @returns the indices array or null
  76853. */
  76854. getScene?(): Scene;
  76855. /**
  76856. * Gets the absolute position from the mesh
  76857. * @returns the absolute position
  76858. */
  76859. getAbsolutePosition(): Vector3;
  76860. /**
  76861. * Gets the absolute pivot point from the mesh
  76862. * @returns the absolute pivot point
  76863. */
  76864. getAbsolutePivotPoint(): Vector3;
  76865. /**
  76866. * Rotates the mesh
  76867. * @param axis The axis of rotation
  76868. * @param amount The amount of rotation
  76869. * @param space The space of the rotation
  76870. * @returns The rotation transform node
  76871. */
  76872. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  76873. /**
  76874. * Translates the mesh
  76875. * @param axis The axis of translation
  76876. * @param distance The distance of translation
  76877. * @param space The space of the translation
  76878. * @returns The transform node
  76879. */
  76880. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  76881. /**
  76882. * Sets the absolute position of the mesh
  76883. * @param absolutePosition The absolute position of the mesh
  76884. * @returns The transform node
  76885. */
  76886. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  76887. /**
  76888. * Gets the class name of the mesh
  76889. * @returns The class name
  76890. */
  76891. getClassName(): string;
  76892. }
  76893. /**
  76894. * Represents a physics imposter
  76895. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  76896. */
  76897. export class PhysicsImpostor {
  76898. /**
  76899. * The physics-enabled object used as the physics imposter
  76900. */
  76901. object: IPhysicsEnabledObject;
  76902. /**
  76903. * The type of the physics imposter
  76904. */
  76905. type: number;
  76906. private _options;
  76907. private _scene?;
  76908. /**
  76909. * The default object size of the imposter
  76910. */
  76911. static DEFAULT_OBJECT_SIZE: Vector3;
  76912. /**
  76913. * The identity quaternion of the imposter
  76914. */
  76915. static IDENTITY_QUATERNION: Quaternion;
  76916. /** @hidden */
  76917. _pluginData: any;
  76918. private _physicsEngine;
  76919. private _physicsBody;
  76920. private _bodyUpdateRequired;
  76921. private _onBeforePhysicsStepCallbacks;
  76922. private _onAfterPhysicsStepCallbacks;
  76923. /** @hidden */
  76924. _onPhysicsCollideCallbacks: Array<{
  76925. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  76926. otherImpostors: Array<PhysicsImpostor>;
  76927. }>;
  76928. private _deltaPosition;
  76929. private _deltaRotation;
  76930. private _deltaRotationConjugated;
  76931. private _parent;
  76932. private _isDisposed;
  76933. private static _tmpVecs;
  76934. private static _tmpQuat;
  76935. /**
  76936. * Specifies if the physics imposter is disposed
  76937. */
  76938. readonly isDisposed: boolean;
  76939. /**
  76940. * Gets the mass of the physics imposter
  76941. */
  76942. mass: number;
  76943. /**
  76944. * Gets the coefficient of friction
  76945. */
  76946. /**
  76947. * Sets the coefficient of friction
  76948. */
  76949. friction: number;
  76950. /**
  76951. * Gets the coefficient of restitution
  76952. */
  76953. /**
  76954. * Sets the coefficient of restitution
  76955. */
  76956. restitution: number;
  76957. /**
  76958. * The unique id of the physics imposter
  76959. * set by the physics engine when adding this impostor to the array
  76960. */
  76961. uniqueId: number;
  76962. private _joints;
  76963. /**
  76964. * Initializes the physics imposter
  76965. * @param object The physics-enabled object used as the physics imposter
  76966. * @param type The type of the physics imposter
  76967. * @param _options The options for the physics imposter
  76968. * @param _scene The Babylon scene
  76969. */
  76970. constructor(
  76971. /**
  76972. * The physics-enabled object used as the physics imposter
  76973. */
  76974. object: IPhysicsEnabledObject,
  76975. /**
  76976. * The type of the physics imposter
  76977. */
  76978. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  76979. /**
  76980. * This function will completly initialize this impostor.
  76981. * It will create a new body - but only if this mesh has no parent.
  76982. * If it has, this impostor will not be used other than to define the impostor
  76983. * of the child mesh.
  76984. * @hidden
  76985. */
  76986. _init(): void;
  76987. private _getPhysicsParent;
  76988. /**
  76989. * Should a new body be generated.
  76990. * @returns boolean specifying if body initialization is required
  76991. */
  76992. isBodyInitRequired(): boolean;
  76993. /**
  76994. * Sets the updated scaling
  76995. * @param updated Specifies if the scaling is updated
  76996. */
  76997. setScalingUpdated(): void;
  76998. /**
  76999. * Force a regeneration of this or the parent's impostor's body.
  77000. * Use under cautious - This will remove all joints already implemented.
  77001. */
  77002. forceUpdate(): void;
  77003. /**
  77004. * Gets the body that holds this impostor. Either its own, or its parent.
  77005. */
  77006. /**
  77007. * Set the physics body. Used mainly by the physics engine/plugin
  77008. */
  77009. physicsBody: any;
  77010. /**
  77011. * Get the parent of the physics imposter
  77012. * @returns Physics imposter or null
  77013. */
  77014. /**
  77015. * Sets the parent of the physics imposter
  77016. */
  77017. parent: Nullable<PhysicsImpostor>;
  77018. /**
  77019. * Resets the update flags
  77020. */
  77021. resetUpdateFlags(): void;
  77022. /**
  77023. * Gets the object extend size
  77024. * @returns the object extend size
  77025. */
  77026. getObjectExtendSize(): Vector3;
  77027. /**
  77028. * Gets the object center
  77029. * @returns The object center
  77030. */
  77031. getObjectCenter(): Vector3;
  77032. /**
  77033. * Get a specific parametes from the options parameter
  77034. * @param paramName The object parameter name
  77035. * @returns The object parameter
  77036. */
  77037. getParam(paramName: string): any;
  77038. /**
  77039. * Sets a specific parameter in the options given to the physics plugin
  77040. * @param paramName The parameter name
  77041. * @param value The value of the parameter
  77042. */
  77043. setParam(paramName: string, value: number): void;
  77044. /**
  77045. * Specifically change the body's mass option. Won't recreate the physics body object
  77046. * @param mass The mass of the physics imposter
  77047. */
  77048. setMass(mass: number): void;
  77049. /**
  77050. * Gets the linear velocity
  77051. * @returns linear velocity or null
  77052. */
  77053. getLinearVelocity(): Nullable<Vector3>;
  77054. /**
  77055. * Sets the linear velocity
  77056. * @param velocity linear velocity or null
  77057. */
  77058. setLinearVelocity(velocity: Nullable<Vector3>): void;
  77059. /**
  77060. * Gets the angular velocity
  77061. * @returns angular velocity or null
  77062. */
  77063. getAngularVelocity(): Nullable<Vector3>;
  77064. /**
  77065. * Sets the angular velocity
  77066. * @param velocity The velocity or null
  77067. */
  77068. setAngularVelocity(velocity: Nullable<Vector3>): void;
  77069. /**
  77070. * Execute a function with the physics plugin native code
  77071. * Provide a function the will have two variables - the world object and the physics body object
  77072. * @param func The function to execute with the physics plugin native code
  77073. */
  77074. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  77075. /**
  77076. * Register a function that will be executed before the physics world is stepping forward
  77077. * @param func The function to execute before the physics world is stepped forward
  77078. */
  77079. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  77080. /**
  77081. * Unregister a function that will be executed before the physics world is stepping forward
  77082. * @param func The function to execute before the physics world is stepped forward
  77083. */
  77084. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  77085. /**
  77086. * Register a function that will be executed after the physics step
  77087. * @param func The function to execute after physics step
  77088. */
  77089. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  77090. /**
  77091. * Unregisters a function that will be executed after the physics step
  77092. * @param func The function to execute after physics step
  77093. */
  77094. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  77095. /**
  77096. * register a function that will be executed when this impostor collides against a different body
  77097. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  77098. * @param func Callback that is executed on collision
  77099. */
  77100. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  77101. /**
  77102. * Unregisters the physics imposter on contact
  77103. * @param collideAgainst The physics object to collide against
  77104. * @param func Callback to execute on collision
  77105. */
  77106. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  77107. private _tmpQuat;
  77108. private _tmpQuat2;
  77109. /**
  77110. * Get the parent rotation
  77111. * @returns The parent rotation
  77112. */
  77113. getParentsRotation(): Quaternion;
  77114. /**
  77115. * this function is executed by the physics engine.
  77116. */
  77117. beforeStep: () => void;
  77118. /**
  77119. * this function is executed by the physics engine
  77120. */
  77121. afterStep: () => void;
  77122. /**
  77123. * Legacy collision detection event support
  77124. */
  77125. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  77126. /**
  77127. * event and body object due to cannon's event-based architecture.
  77128. */
  77129. onCollide: (e: {
  77130. body: any;
  77131. }) => void;
  77132. /**
  77133. * Apply a force
  77134. * @param force The force to apply
  77135. * @param contactPoint The contact point for the force
  77136. * @returns The physics imposter
  77137. */
  77138. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  77139. /**
  77140. * Apply an impulse
  77141. * @param force The impulse force
  77142. * @param contactPoint The contact point for the impulse force
  77143. * @returns The physics imposter
  77144. */
  77145. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  77146. /**
  77147. * A help function to create a joint
  77148. * @param otherImpostor A physics imposter used to create a joint
  77149. * @param jointType The type of joint
  77150. * @param jointData The data for the joint
  77151. * @returns The physics imposter
  77152. */
  77153. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  77154. /**
  77155. * Add a joint to this impostor with a different impostor
  77156. * @param otherImpostor A physics imposter used to add a joint
  77157. * @param joint The joint to add
  77158. * @returns The physics imposter
  77159. */
  77160. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  77161. /**
  77162. * Will keep this body still, in a sleep mode.
  77163. * @returns the physics imposter
  77164. */
  77165. sleep(): PhysicsImpostor;
  77166. /**
  77167. * Wake the body up.
  77168. * @returns The physics imposter
  77169. */
  77170. wakeUp(): PhysicsImpostor;
  77171. /**
  77172. * Clones the physics imposter
  77173. * @param newObject The physics imposter clones to this physics-enabled object
  77174. * @returns A nullable physics imposter
  77175. */
  77176. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  77177. /**
  77178. * Disposes the physics imposter
  77179. */
  77180. dispose(): void;
  77181. /**
  77182. * Sets the delta position
  77183. * @param position The delta position amount
  77184. */
  77185. setDeltaPosition(position: Vector3): void;
  77186. /**
  77187. * Sets the delta rotation
  77188. * @param rotation The delta rotation amount
  77189. */
  77190. setDeltaRotation(rotation: Quaternion): void;
  77191. /**
  77192. * Gets the box size of the physics imposter and stores the result in the input parameter
  77193. * @param result Stores the box size
  77194. * @returns The physics imposter
  77195. */
  77196. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  77197. /**
  77198. * Gets the radius of the physics imposter
  77199. * @returns Radius of the physics imposter
  77200. */
  77201. getRadius(): number;
  77202. /**
  77203. * Sync a bone with this impostor
  77204. * @param bone The bone to sync to the impostor.
  77205. * @param boneMesh The mesh that the bone is influencing.
  77206. * @param jointPivot The pivot of the joint / bone in local space.
  77207. * @param distToJoint Optional distance from the impostor to the joint.
  77208. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  77209. */
  77210. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  77211. /**
  77212. * Sync impostor to a bone
  77213. * @param bone The bone that the impostor will be synced to.
  77214. * @param boneMesh The mesh that the bone is influencing.
  77215. * @param jointPivot The pivot of the joint / bone in local space.
  77216. * @param distToJoint Optional distance from the impostor to the joint.
  77217. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  77218. * @param boneAxis Optional vector3 axis the bone is aligned with
  77219. */
  77220. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  77221. /**
  77222. * No-Imposter type
  77223. */
  77224. static NoImpostor: number;
  77225. /**
  77226. * Sphere-Imposter type
  77227. */
  77228. static SphereImpostor: number;
  77229. /**
  77230. * Box-Imposter type
  77231. */
  77232. static BoxImpostor: number;
  77233. /**
  77234. * Plane-Imposter type
  77235. */
  77236. static PlaneImpostor: number;
  77237. /**
  77238. * Mesh-imposter type
  77239. */
  77240. static MeshImpostor: number;
  77241. /**
  77242. * Cylinder-Imposter type
  77243. */
  77244. static CylinderImpostor: number;
  77245. /**
  77246. * Particle-Imposter type
  77247. */
  77248. static ParticleImpostor: number;
  77249. /**
  77250. * Heightmap-Imposter type
  77251. */
  77252. static HeightmapImpostor: number;
  77253. }
  77254. }
  77255. declare module BABYLON {
  77256. /**
  77257. * Class used to represent a specific level of detail of a mesh
  77258. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  77259. */
  77260. export class MeshLODLevel {
  77261. /** Defines the distance where this level should star being displayed */
  77262. distance: number;
  77263. /** Defines the mesh to use to render this level */
  77264. mesh: Nullable<Mesh>;
  77265. /**
  77266. * Creates a new LOD level
  77267. * @param distance defines the distance where this level should star being displayed
  77268. * @param mesh defines the mesh to use to render this level
  77269. */
  77270. constructor(
  77271. /** Defines the distance where this level should star being displayed */
  77272. distance: number,
  77273. /** Defines the mesh to use to render this level */
  77274. mesh: Nullable<Mesh>);
  77275. }
  77276. /**
  77277. * @hidden
  77278. **/
  77279. export class _CreationDataStorage {
  77280. closePath?: boolean;
  77281. closeArray?: boolean;
  77282. idx: number[];
  77283. dashSize: number;
  77284. gapSize: number;
  77285. path3D: Path3D;
  77286. pathArray: Vector3[][];
  77287. arc: number;
  77288. radius: number;
  77289. cap: number;
  77290. tessellation: number;
  77291. }
  77292. /**
  77293. * @hidden
  77294. **/
  77295. class _InstanceDataStorage {
  77296. visibleInstances: any;
  77297. renderIdForInstances: number[];
  77298. batchCache: _InstancesBatch;
  77299. instancesBufferSize: number;
  77300. instancesBuffer: Nullable<Buffer>;
  77301. instancesData: Float32Array;
  77302. overridenInstanceCount: number;
  77303. }
  77304. /**
  77305. * @hidden
  77306. **/
  77307. export class _InstancesBatch {
  77308. mustReturn: boolean;
  77309. visibleInstances: Nullable<InstancedMesh[]>[];
  77310. renderSelf: boolean[];
  77311. }
  77312. /**
  77313. * Class used to represent renderable models
  77314. */
  77315. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  77316. /**
  77317. * Mesh side orientation : usually the external or front surface
  77318. */
  77319. static readonly FRONTSIDE: number;
  77320. /**
  77321. * Mesh side orientation : usually the internal or back surface
  77322. */
  77323. static readonly BACKSIDE: number;
  77324. /**
  77325. * Mesh side orientation : both internal and external or front and back surfaces
  77326. */
  77327. static readonly DOUBLESIDE: number;
  77328. /**
  77329. * Mesh side orientation : by default, `FRONTSIDE`
  77330. */
  77331. static readonly DEFAULTSIDE: number;
  77332. /**
  77333. * Mesh cap setting : no cap
  77334. */
  77335. static readonly NO_CAP: number;
  77336. /**
  77337. * Mesh cap setting : one cap at the beginning of the mesh
  77338. */
  77339. static readonly CAP_START: number;
  77340. /**
  77341. * Mesh cap setting : one cap at the end of the mesh
  77342. */
  77343. static readonly CAP_END: number;
  77344. /**
  77345. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  77346. */
  77347. static readonly CAP_ALL: number;
  77348. /**
  77349. * Gets the default side orientation.
  77350. * @param orientation the orientation to value to attempt to get
  77351. * @returns the default orientation
  77352. * @hidden
  77353. */
  77354. static _GetDefaultSideOrientation(orientation?: number): number;
  77355. private _onBeforeRenderObservable;
  77356. private _onBeforeBindObservable;
  77357. private _onAfterRenderObservable;
  77358. private _onBeforeDrawObservable;
  77359. /**
  77360. * An event triggered before rendering the mesh
  77361. */
  77362. readonly onBeforeRenderObservable: Observable<Mesh>;
  77363. /**
  77364. * An event triggered before binding the mesh
  77365. */
  77366. readonly onBeforeBindObservable: Observable<Mesh>;
  77367. /**
  77368. * An event triggered after rendering the mesh
  77369. */
  77370. readonly onAfterRenderObservable: Observable<Mesh>;
  77371. /**
  77372. * An event triggered before drawing the mesh
  77373. */
  77374. readonly onBeforeDrawObservable: Observable<Mesh>;
  77375. private _onBeforeDrawObserver;
  77376. /**
  77377. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  77378. */
  77379. onBeforeDraw: () => void;
  77380. /**
  77381. * Gets the delay loading state of the mesh (when delay loading is turned on)
  77382. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  77383. */
  77384. delayLoadState: number;
  77385. /**
  77386. * Gets the list of instances created from this mesh
  77387. * it is not supposed to be modified manually.
  77388. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  77389. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  77390. */
  77391. instances: InstancedMesh[];
  77392. /**
  77393. * Gets the file containing delay loading data for this mesh
  77394. */
  77395. delayLoadingFile: string;
  77396. /** @hidden */
  77397. _binaryInfo: any;
  77398. private _LODLevels;
  77399. /**
  77400. * User defined function used to change how LOD level selection is done
  77401. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  77402. */
  77403. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  77404. private _morphTargetManager;
  77405. /**
  77406. * Gets or sets the morph target manager
  77407. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  77408. */
  77409. morphTargetManager: Nullable<MorphTargetManager>;
  77410. /** @hidden */
  77411. _creationDataStorage: Nullable<_CreationDataStorage>;
  77412. /** @hidden */
  77413. _geometry: Nullable<Geometry>;
  77414. /** @hidden */
  77415. _delayInfo: Array<string>;
  77416. /** @hidden */
  77417. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  77418. /** @hidden */
  77419. _instanceDataStorage: _InstanceDataStorage;
  77420. private _effectiveMaterial;
  77421. /** @hidden */
  77422. _shouldGenerateFlatShading: boolean;
  77423. private _preActivateId;
  77424. /** @hidden */
  77425. _originalBuilderSideOrientation: number;
  77426. /**
  77427. * Use this property to change the original side orientation defined at construction time
  77428. */
  77429. overrideMaterialSideOrientation: Nullable<number>;
  77430. private _areNormalsFrozen;
  77431. private _sourcePositions;
  77432. private _sourceNormals;
  77433. private _source;
  77434. private meshMap;
  77435. /**
  77436. * Gets the source mesh (the one used to clone this one from)
  77437. */
  77438. readonly source: Nullable<Mesh>;
  77439. /**
  77440. * Gets or sets a boolean indicating that this mesh does not use index buffer
  77441. */
  77442. isUnIndexed: boolean;
  77443. /**
  77444. * @constructor
  77445. * @param name The value used by scene.getMeshByName() to do a lookup.
  77446. * @param scene The scene to add this mesh to.
  77447. * @param parent The parent of this mesh, if it has one
  77448. * @param source An optional Mesh from which geometry is shared, cloned.
  77449. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  77450. * When false, achieved by calling a clone(), also passing False.
  77451. * This will make creation of children, recursive.
  77452. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  77453. */
  77454. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  77455. /**
  77456. * Gets the class name
  77457. * @returns the string "Mesh".
  77458. */
  77459. getClassName(): string;
  77460. /** @hidden */
  77461. readonly _isMesh: boolean;
  77462. /**
  77463. * Returns a description of this mesh
  77464. * @param fullDetails define if full details about this mesh must be used
  77465. * @returns a descriptive string representing this mesh
  77466. */
  77467. toString(fullDetails?: boolean): string;
  77468. /** @hidden */
  77469. _unBindEffect(): void;
  77470. /**
  77471. * Gets a boolean indicating if this mesh has LOD
  77472. */
  77473. readonly hasLODLevels: boolean;
  77474. /**
  77475. * Gets the list of MeshLODLevel associated with the current mesh
  77476. * @returns an array of MeshLODLevel
  77477. */
  77478. getLODLevels(): MeshLODLevel[];
  77479. private _sortLODLevels;
  77480. /**
  77481. * Add a mesh as LOD level triggered at the given distance.
  77482. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  77483. * @param distance The distance from the center of the object to show this level
  77484. * @param mesh The mesh to be added as LOD level (can be null)
  77485. * @return This mesh (for chaining)
  77486. */
  77487. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  77488. /**
  77489. * Returns the LOD level mesh at the passed distance or null if not found.
  77490. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  77491. * @param distance The distance from the center of the object to show this level
  77492. * @returns a Mesh or `null`
  77493. */
  77494. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  77495. /**
  77496. * Remove a mesh from the LOD array
  77497. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  77498. * @param mesh defines the mesh to be removed
  77499. * @return This mesh (for chaining)
  77500. */
  77501. removeLODLevel(mesh: Mesh): Mesh;
  77502. /**
  77503. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  77504. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  77505. * @param camera defines the camera to use to compute distance
  77506. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  77507. * @return This mesh (for chaining)
  77508. */
  77509. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  77510. /**
  77511. * Gets the mesh internal Geometry object
  77512. */
  77513. readonly geometry: Nullable<Geometry>;
  77514. /**
  77515. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  77516. * @returns the total number of vertices
  77517. */
  77518. getTotalVertices(): number;
  77519. /**
  77520. * Returns the content of an associated vertex buffer
  77521. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  77522. * - VertexBuffer.PositionKind
  77523. * - VertexBuffer.UVKind
  77524. * - VertexBuffer.UV2Kind
  77525. * - VertexBuffer.UV3Kind
  77526. * - VertexBuffer.UV4Kind
  77527. * - VertexBuffer.UV5Kind
  77528. * - VertexBuffer.UV6Kind
  77529. * - VertexBuffer.ColorKind
  77530. * - VertexBuffer.MatricesIndicesKind
  77531. * - VertexBuffer.MatricesIndicesExtraKind
  77532. * - VertexBuffer.MatricesWeightsKind
  77533. * - VertexBuffer.MatricesWeightsExtraKind
  77534. * @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
  77535. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  77536. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  77537. */
  77538. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  77539. /**
  77540. * Returns the mesh VertexBuffer object from the requested `kind`
  77541. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  77542. * - VertexBuffer.PositionKind
  77543. * - VertexBuffer.UVKind
  77544. * - VertexBuffer.UV2Kind
  77545. * - VertexBuffer.UV3Kind
  77546. * - VertexBuffer.UV4Kind
  77547. * - VertexBuffer.UV5Kind
  77548. * - VertexBuffer.UV6Kind
  77549. * - VertexBuffer.ColorKind
  77550. * - VertexBuffer.MatricesIndicesKind
  77551. * - VertexBuffer.MatricesIndicesExtraKind
  77552. * - VertexBuffer.MatricesWeightsKind
  77553. * - VertexBuffer.MatricesWeightsExtraKind
  77554. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  77555. */
  77556. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  77557. /**
  77558. * Tests if a specific vertex buffer is associated with this mesh
  77559. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  77560. * - VertexBuffer.PositionKind
  77561. * - VertexBuffer.UVKind
  77562. * - VertexBuffer.UV2Kind
  77563. * - VertexBuffer.UV3Kind
  77564. * - VertexBuffer.UV4Kind
  77565. * - VertexBuffer.UV5Kind
  77566. * - VertexBuffer.UV6Kind
  77567. * - VertexBuffer.ColorKind
  77568. * - VertexBuffer.MatricesIndicesKind
  77569. * - VertexBuffer.MatricesIndicesExtraKind
  77570. * - VertexBuffer.MatricesWeightsKind
  77571. * - VertexBuffer.MatricesWeightsExtraKind
  77572. * @returns a boolean
  77573. */
  77574. isVerticesDataPresent(kind: string): boolean;
  77575. /**
  77576. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  77577. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  77578. * - VertexBuffer.PositionKind
  77579. * - VertexBuffer.UVKind
  77580. * - VertexBuffer.UV2Kind
  77581. * - VertexBuffer.UV3Kind
  77582. * - VertexBuffer.UV4Kind
  77583. * - VertexBuffer.UV5Kind
  77584. * - VertexBuffer.UV6Kind
  77585. * - VertexBuffer.ColorKind
  77586. * - VertexBuffer.MatricesIndicesKind
  77587. * - VertexBuffer.MatricesIndicesExtraKind
  77588. * - VertexBuffer.MatricesWeightsKind
  77589. * - VertexBuffer.MatricesWeightsExtraKind
  77590. * @returns a boolean
  77591. */
  77592. isVertexBufferUpdatable(kind: string): boolean;
  77593. /**
  77594. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  77595. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  77596. * - VertexBuffer.PositionKind
  77597. * - VertexBuffer.UVKind
  77598. * - VertexBuffer.UV2Kind
  77599. * - VertexBuffer.UV3Kind
  77600. * - VertexBuffer.UV4Kind
  77601. * - VertexBuffer.UV5Kind
  77602. * - VertexBuffer.UV6Kind
  77603. * - VertexBuffer.ColorKind
  77604. * - VertexBuffer.MatricesIndicesKind
  77605. * - VertexBuffer.MatricesIndicesExtraKind
  77606. * - VertexBuffer.MatricesWeightsKind
  77607. * - VertexBuffer.MatricesWeightsExtraKind
  77608. * @returns an array of strings
  77609. */
  77610. getVerticesDataKinds(): string[];
  77611. /**
  77612. * Returns a positive integer : the total number of indices in this mesh geometry.
  77613. * @returns the numner of indices or zero if the mesh has no geometry.
  77614. */
  77615. getTotalIndices(): number;
  77616. /**
  77617. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  77618. * @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.
  77619. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  77620. * @returns the indices array or an empty array if the mesh has no geometry
  77621. */
  77622. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  77623. readonly isBlocked: boolean;
  77624. /**
  77625. * Determine if the current mesh is ready to be rendered
  77626. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  77627. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  77628. * @returns true if all associated assets are ready (material, textures, shaders)
  77629. */
  77630. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  77631. /**
  77632. * 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.
  77633. */
  77634. readonly areNormalsFrozen: boolean;
  77635. /**
  77636. * 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.
  77637. * @returns the current mesh
  77638. */
  77639. freezeNormals(): Mesh;
  77640. /**
  77641. * 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
  77642. * @returns the current mesh
  77643. */
  77644. unfreezeNormals(): Mesh;
  77645. /**
  77646. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  77647. */
  77648. overridenInstanceCount: number;
  77649. /** @hidden */
  77650. _preActivate(): Mesh;
  77651. /** @hidden */
  77652. _preActivateForIntermediateRendering(renderId: number): Mesh;
  77653. /** @hidden */
  77654. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  77655. /**
  77656. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  77657. * This means the mesh underlying bounding box and sphere are recomputed.
  77658. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  77659. * @returns the current mesh
  77660. */
  77661. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  77662. /** @hidden */
  77663. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  77664. /**
  77665. * This function will subdivide the mesh into multiple submeshes
  77666. * @param count defines the expected number of submeshes
  77667. */
  77668. subdivide(count: number): void;
  77669. /**
  77670. * Copy a FloatArray into 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 updatable defines if the updated vertex buffer must be flagged as updatable
  77686. * @param stride defines the data stride size (can be null)
  77687. * @returns the current mesh
  77688. */
  77689. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  77690. /**
  77691. * Flags an associated vertex buffer as updatable
  77692. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  77693. * - VertexBuffer.PositionKind
  77694. * - VertexBuffer.UVKind
  77695. * - VertexBuffer.UV2Kind
  77696. * - VertexBuffer.UV3Kind
  77697. * - VertexBuffer.UV4Kind
  77698. * - VertexBuffer.UV5Kind
  77699. * - VertexBuffer.UV6Kind
  77700. * - VertexBuffer.ColorKind
  77701. * - VertexBuffer.MatricesIndicesKind
  77702. * - VertexBuffer.MatricesIndicesExtraKind
  77703. * - VertexBuffer.MatricesWeightsKind
  77704. * - VertexBuffer.MatricesWeightsExtraKind
  77705. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  77706. */
  77707. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  77708. /**
  77709. * Sets the mesh global Vertex Buffer
  77710. * @param buffer defines the buffer to use
  77711. * @returns the current mesh
  77712. */
  77713. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  77714. /**
  77715. * Update a specific associated vertex buffer
  77716. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  77717. * - VertexBuffer.PositionKind
  77718. * - VertexBuffer.UVKind
  77719. * - VertexBuffer.UV2Kind
  77720. * - VertexBuffer.UV3Kind
  77721. * - VertexBuffer.UV4Kind
  77722. * - VertexBuffer.UV5Kind
  77723. * - VertexBuffer.UV6Kind
  77724. * - VertexBuffer.ColorKind
  77725. * - VertexBuffer.MatricesIndicesKind
  77726. * - VertexBuffer.MatricesIndicesExtraKind
  77727. * - VertexBuffer.MatricesWeightsKind
  77728. * - VertexBuffer.MatricesWeightsExtraKind
  77729. * @param data defines the data source
  77730. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  77731. * @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)
  77732. * @returns the current mesh
  77733. */
  77734. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  77735. /**
  77736. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  77737. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  77738. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  77739. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  77740. * @returns the current mesh
  77741. */
  77742. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  77743. /**
  77744. * Creates a un-shared specific occurence of the geometry for the mesh.
  77745. * @returns the current mesh
  77746. */
  77747. makeGeometryUnique(): Mesh;
  77748. /**
  77749. * Set the index buffer of this mesh
  77750. * @param indices defines the source data
  77751. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  77752. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  77753. * @returns the current mesh
  77754. */
  77755. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  77756. /**
  77757. * Update the current index buffer
  77758. * @param indices defines the source data
  77759. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  77760. * @returns the current mesh
  77761. */
  77762. updateIndices(indices: IndicesArray, offset?: number): Mesh;
  77763. /**
  77764. * Invert the geometry to move from a right handed system to a left handed one.
  77765. * @returns the current mesh
  77766. */
  77767. toLeftHanded(): Mesh;
  77768. /** @hidden */
  77769. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  77770. /** @hidden */
  77771. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number, alternate?: boolean): Mesh;
  77772. /**
  77773. * Registers for this mesh a javascript function called just before the rendering process
  77774. * @param func defines the function to call before rendering this mesh
  77775. * @returns the current mesh
  77776. */
  77777. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  77778. /**
  77779. * Disposes a previously registered javascript function called before the rendering
  77780. * @param func defines the function to remove
  77781. * @returns the current mesh
  77782. */
  77783. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  77784. /**
  77785. * Registers for this mesh a javascript function called just after the rendering is complete
  77786. * @param func defines the function to call after rendering this mesh
  77787. * @returns the current mesh
  77788. */
  77789. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  77790. /**
  77791. * Disposes a previously registered javascript function called after the rendering.
  77792. * @param func defines the function to remove
  77793. * @returns the current mesh
  77794. */
  77795. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  77796. /** @hidden */
  77797. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  77798. /** @hidden */
  77799. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  77800. /** @hidden */
  77801. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  77802. /**
  77803. * 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
  77804. * @param subMesh defines the subMesh to render
  77805. * @param enableAlphaMode defines if alpha mode can be changed
  77806. * @returns the current mesh
  77807. */
  77808. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  77809. private _onBeforeDraw;
  77810. /**
  77811. * Renormalize the mesh and patch it up if there are no weights
  77812. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  77813. * However in the case of zero weights then we set just a single influence to 1.
  77814. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  77815. */
  77816. cleanMatrixWeights(): void;
  77817. private normalizeSkinFourWeights;
  77818. private normalizeSkinWeightsAndExtra;
  77819. /**
  77820. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  77821. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  77822. * the user know there was an issue with importing the mesh
  77823. * @returns a validation object with skinned, valid and report string
  77824. */
  77825. validateSkinning(): {
  77826. skinned: boolean;
  77827. valid: boolean;
  77828. report: string;
  77829. };
  77830. /** @hidden */
  77831. _checkDelayState(): Mesh;
  77832. private _queueLoad;
  77833. /**
  77834. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  77835. * A mesh is in the frustum if its bounding box intersects the frustum
  77836. * @param frustumPlanes defines the frustum to test
  77837. * @returns true if the mesh is in the frustum planes
  77838. */
  77839. isInFrustum(frustumPlanes: Plane[]): boolean;
  77840. /**
  77841. * Sets the mesh material by the material or multiMaterial `id` property
  77842. * @param id is a string identifying the material or the multiMaterial
  77843. * @returns the current mesh
  77844. */
  77845. setMaterialByID(id: string): Mesh;
  77846. /**
  77847. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  77848. * @returns an array of IAnimatable
  77849. */
  77850. getAnimatables(): IAnimatable[];
  77851. /**
  77852. * Modifies the mesh geometry according to the passed transformation matrix.
  77853. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  77854. * The mesh normals are modified using the same transformation.
  77855. * Note that, under the hood, this method sets a new VertexBuffer each call.
  77856. * @param transform defines the transform matrix to use
  77857. * @see http://doc.babylonjs.com/resources/baking_transformations
  77858. * @returns the current mesh
  77859. */
  77860. bakeTransformIntoVertices(transform: Matrix): Mesh;
  77861. /**
  77862. * Modifies the mesh geometry according to its own current World Matrix.
  77863. * The mesh World Matrix is then reset.
  77864. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  77865. * Note that, under the hood, this method sets a new VertexBuffer each call.
  77866. * @see http://doc.babylonjs.com/resources/baking_transformations
  77867. * @returns the current mesh
  77868. */
  77869. bakeCurrentTransformIntoVertices(): Mesh;
  77870. /** @hidden */
  77871. readonly _positions: Nullable<Vector3[]>;
  77872. /** @hidden */
  77873. _resetPointsArrayCache(): Mesh;
  77874. /** @hidden */
  77875. _generatePointsArray(): boolean;
  77876. /**
  77877. * Returns a new Mesh object generated from the current mesh properties.
  77878. * This method must not get confused with createInstance()
  77879. * @param name is a string, the name given to the new mesh
  77880. * @param newParent can be any Node object (default `null`)
  77881. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  77882. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  77883. * @returns a new mesh
  77884. */
  77885. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  77886. /**
  77887. * Releases resources associated with this mesh.
  77888. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  77889. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  77890. */
  77891. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  77892. /**
  77893. * Modifies the mesh geometry according to a displacement map.
  77894. * 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.
  77895. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  77896. * @param url is a string, the URL from the image file is to be downloaded.
  77897. * @param minHeight is the lower limit of the displacement.
  77898. * @param maxHeight is the upper limit of the displacement.
  77899. * @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.
  77900. * @param uvOffset is an optional vector2 used to offset UV.
  77901. * @param uvScale is an optional vector2 used to scale UV.
  77902. * @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.
  77903. * @returns the Mesh.
  77904. */
  77905. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  77906. /**
  77907. * Modifies the mesh geometry according to a displacementMap buffer.
  77908. * 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.
  77909. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  77910. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  77911. * @param heightMapWidth is the width of the buffer image.
  77912. * @param heightMapHeight is the height of the buffer image.
  77913. * @param minHeight is the lower limit of the displacement.
  77914. * @param maxHeight is the upper limit of the displacement.
  77915. * @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.
  77916. * @param uvOffset is an optional vector2 used to offset UV.
  77917. * @param uvScale is an optional vector2 used to scale UV.
  77918. * @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.
  77919. * @returns the Mesh.
  77920. */
  77921. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  77922. /**
  77923. * Modify the mesh to get a flat shading rendering.
  77924. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  77925. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  77926. * @returns current mesh
  77927. */
  77928. convertToFlatShadedMesh(): Mesh;
  77929. /**
  77930. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  77931. * In other words, more vertices, no more indices and a single bigger VBO.
  77932. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  77933. * @returns current mesh
  77934. */
  77935. convertToUnIndexedMesh(): Mesh;
  77936. /**
  77937. * Inverses facet orientations.
  77938. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  77939. * @param flipNormals will also inverts the normals
  77940. * @returns current mesh
  77941. */
  77942. flipFaces(flipNormals?: boolean): Mesh;
  77943. /** @hidden */
  77944. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  77945. /** @hidden */
  77946. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  77947. /**
  77948. * Creates a new InstancedMesh object from the mesh model.
  77949. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  77950. * @param name defines the name of the new instance
  77951. * @returns a new InstancedMesh
  77952. */
  77953. createInstance(name: string): InstancedMesh;
  77954. /**
  77955. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  77956. * After this call, all the mesh instances have the same submeshes than the current mesh.
  77957. * @returns the current mesh
  77958. */
  77959. synchronizeInstances(): Mesh;
  77960. /**
  77961. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  77962. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  77963. * This should be used together with the simplification to avoid disappearing triangles.
  77964. * @param successCallback an optional success callback to be called after the optimization finished.
  77965. * @returns the current mesh
  77966. */
  77967. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  77968. /**
  77969. * Serialize current mesh
  77970. * @param serializationObject defines the object which will receive the serialization data
  77971. */
  77972. serialize(serializationObject: any): void;
  77973. /** @hidden */
  77974. _syncGeometryWithMorphTargetManager(): void;
  77975. /** @hidden */
  77976. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  77977. /**
  77978. * Returns a new Mesh object parsed from the source provided.
  77979. * @param parsedMesh is the source
  77980. * @param scene defines the hosting scene
  77981. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  77982. * @returns a new Mesh
  77983. */
  77984. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  77985. /**
  77986. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  77987. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  77988. * @param name defines the name of the mesh to create
  77989. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  77990. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  77991. * @param closePath creates a seam between the first and the last points of each path of the path array
  77992. * @param offset is taken in account only if the `pathArray` is containing a single path
  77993. * @param scene defines the hosting scene
  77994. * @param updatable defines if the mesh must be flagged as updatable
  77995. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77996. * @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)
  77997. * @returns a new Mesh
  77998. */
  77999. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  78000. /**
  78001. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  78002. * @param name defines the name of the mesh to create
  78003. * @param radius sets the radius size (float) of the polygon (default 0.5)
  78004. * @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
  78005. * @param scene defines the hosting scene
  78006. * @param updatable defines if the mesh must be flagged as updatable
  78007. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78008. * @returns a new Mesh
  78009. */
  78010. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  78011. /**
  78012. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  78013. * @param name defines the name of the mesh to create
  78014. * @param size sets the size (float) of each box side (default 1)
  78015. * @param scene defines the hosting scene
  78016. * @param updatable defines if the mesh must be flagged as updatable
  78017. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78018. * @returns a new Mesh
  78019. */
  78020. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  78021. /**
  78022. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  78023. * @param name defines the name of the mesh to create
  78024. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  78025. * @param diameter sets the diameter size (float) of the sphere (default 1)
  78026. * @param scene defines the hosting scene
  78027. * @param updatable defines if the mesh must be flagged as updatable
  78028. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78029. * @returns a new Mesh
  78030. */
  78031. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  78032. /**
  78033. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  78034. * @param name defines the name of the mesh to create
  78035. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  78036. * @param diameterTop set the top cap diameter (floats, default 1)
  78037. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  78038. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  78039. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  78040. * @param scene defines the hosting scene
  78041. * @param updatable defines if the mesh must be flagged as updatable
  78042. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78043. * @returns a new Mesh
  78044. */
  78045. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  78046. /**
  78047. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  78048. * @param name defines the name of the mesh to create
  78049. * @param diameter sets the diameter size (float) of the torus (default 1)
  78050. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  78051. * @param tessellation sets the number of torus sides (postive integer, default 16)
  78052. * @param scene defines the hosting scene
  78053. * @param updatable defines if the mesh must be flagged as updatable
  78054. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78055. * @returns a new Mesh
  78056. */
  78057. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  78058. /**
  78059. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  78060. * @param name defines the name of the mesh to create
  78061. * @param radius sets the global radius size (float) of the torus knot (default 2)
  78062. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  78063. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  78064. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  78065. * @param p the number of windings on X axis (positive integers, default 2)
  78066. * @param q the number of windings on Y axis (positive integers, default 3)
  78067. * @param scene defines the hosting scene
  78068. * @param updatable defines if the mesh must be flagged as updatable
  78069. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78070. * @returns a new Mesh
  78071. */
  78072. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  78073. /**
  78074. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  78075. * @param name defines the name of the mesh to create
  78076. * @param points is an array successive Vector3
  78077. * @param scene defines the hosting scene
  78078. * @param updatable defines if the mesh must be flagged as updatable
  78079. * @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).
  78080. * @returns a new Mesh
  78081. */
  78082. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  78083. /**
  78084. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  78085. * @param name defines the name of the mesh to create
  78086. * @param points is an array successive Vector3
  78087. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  78088. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  78089. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  78090. * @param scene defines the hosting scene
  78091. * @param updatable defines if the mesh must be flagged as updatable
  78092. * @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)
  78093. * @returns a new Mesh
  78094. */
  78095. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  78096. /**
  78097. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  78098. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  78099. * 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.
  78100. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  78101. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  78102. * Remember you can only change the shape positions, not their number when updating a polygon.
  78103. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  78104. * @param name defines the name of the mesh to create
  78105. * @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
  78106. * @param scene defines the hosting scene
  78107. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  78108. * @param updatable defines if the mesh must be flagged as updatable
  78109. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78110. * @param earcutInjection can be used to inject your own earcut reference
  78111. * @returns a new Mesh
  78112. */
  78113. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  78114. /**
  78115. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  78116. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  78117. * @param name defines the name of the mesh to create
  78118. * @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
  78119. * @param depth defines the height of extrusion
  78120. * @param scene defines the hosting scene
  78121. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  78122. * @param updatable defines if the mesh must be flagged as updatable
  78123. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78124. * @param earcutInjection can be used to inject your own earcut reference
  78125. * @returns a new Mesh
  78126. */
  78127. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  78128. /**
  78129. * Creates an extruded shape mesh.
  78130. * 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
  78131. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  78132. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  78133. * @param name defines the name of the mesh to create
  78134. * @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
  78135. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  78136. * @param scale is the value to scale the shape
  78137. * @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
  78138. * @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
  78139. * @param scene defines the hosting scene
  78140. * @param updatable defines if the mesh must be flagged as updatable
  78141. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78142. * @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)
  78143. * @returns a new Mesh
  78144. */
  78145. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  78146. /**
  78147. * Creates an custom extruded shape mesh.
  78148. * The custom extrusion is a parametric shape.
  78149. * It has no predefined shape. Its final shape will depend on the input parameters.
  78150. * Please consider using the same method from the MeshBuilder class instead
  78151. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  78152. * @param name defines the name of the mesh to create
  78153. * @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
  78154. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  78155. * @param scaleFunction is a custom Javascript function called on each path point
  78156. * @param rotationFunction is a custom Javascript function called on each path point
  78157. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  78158. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  78159. * @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
  78160. * @param scene defines the hosting scene
  78161. * @param updatable defines if the mesh must be flagged as updatable
  78162. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78163. * @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)
  78164. * @returns a new Mesh
  78165. */
  78166. 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;
  78167. /**
  78168. * Creates lathe mesh.
  78169. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  78170. * Please consider using the same method from the MeshBuilder class instead
  78171. * @param name defines the name of the mesh to create
  78172. * @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
  78173. * @param radius is the radius value of the lathe
  78174. * @param tessellation is the side number of the lathe.
  78175. * @param scene defines the hosting scene
  78176. * @param updatable defines if the mesh must be flagged as updatable
  78177. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78178. * @returns a new Mesh
  78179. */
  78180. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  78181. /**
  78182. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  78183. * @param name defines the name of the mesh to create
  78184. * @param size sets the size (float) of both sides of the plane at once (default 1)
  78185. * @param scene defines the hosting scene
  78186. * @param updatable defines if the mesh must be flagged as updatable
  78187. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78188. * @returns a new Mesh
  78189. */
  78190. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  78191. /**
  78192. * Creates a ground mesh.
  78193. * Please consider using the same method from the MeshBuilder class instead
  78194. * @param name defines the name of the mesh to create
  78195. * @param width set the width of the ground
  78196. * @param height set the height of the ground
  78197. * @param subdivisions sets the number of subdivisions per side
  78198. * @param scene defines the hosting scene
  78199. * @param updatable defines if the mesh must be flagged as updatable
  78200. * @returns a new Mesh
  78201. */
  78202. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  78203. /**
  78204. * Creates a tiled ground mesh.
  78205. * Please consider using the same method from the MeshBuilder class instead
  78206. * @param name defines the name of the mesh to create
  78207. * @param xmin set the ground minimum X coordinate
  78208. * @param zmin set the ground minimum Y coordinate
  78209. * @param xmax set the ground maximum X coordinate
  78210. * @param zmax set the ground maximum Z coordinate
  78211. * @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
  78212. * @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
  78213. * @param scene defines the hosting scene
  78214. * @param updatable defines if the mesh must be flagged as updatable
  78215. * @returns a new Mesh
  78216. */
  78217. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  78218. w: number;
  78219. h: number;
  78220. }, precision: {
  78221. w: number;
  78222. h: number;
  78223. }, scene: Scene, updatable?: boolean): Mesh;
  78224. /**
  78225. * Creates a ground mesh from a height map.
  78226. * Please consider using the same method from the MeshBuilder class instead
  78227. * @see http://doc.babylonjs.com/babylon101/height_map
  78228. * @param name defines the name of the mesh to create
  78229. * @param url sets the URL of the height map image resource
  78230. * @param width set the ground width size
  78231. * @param height set the ground height size
  78232. * @param subdivisions sets the number of subdivision per side
  78233. * @param minHeight is the minimum altitude on the ground
  78234. * @param maxHeight is the maximum altitude on the ground
  78235. * @param scene defines the hosting scene
  78236. * @param updatable defines if the mesh must be flagged as updatable
  78237. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  78238. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  78239. * @returns a new Mesh
  78240. */
  78241. 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;
  78242. /**
  78243. * Creates a tube mesh.
  78244. * The tube is a parametric shape.
  78245. * It has no predefined shape. Its final shape will depend on the input parameters.
  78246. * Please consider using the same method from the MeshBuilder class instead
  78247. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  78248. * @param name defines the name of the mesh to create
  78249. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  78250. * @param radius sets the tube radius size
  78251. * @param tessellation is the number of sides on the tubular surface
  78252. * @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
  78253. * @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
  78254. * @param scene defines the hosting scene
  78255. * @param updatable defines if the mesh must be flagged as updatable
  78256. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78257. * @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)
  78258. * @returns a new Mesh
  78259. */
  78260. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  78261. (i: number, distance: number): number;
  78262. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  78263. /**
  78264. * Creates a polyhedron mesh.
  78265. * Please consider using the same method from the MeshBuilder class instead.
  78266. * * 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
  78267. * * The parameter `size` (positive float, default 1) sets the polygon size
  78268. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  78269. * * 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`
  78270. * * 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
  78271. * * 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)`)
  78272. * * 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
  78273. * * 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
  78274. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  78275. * * If you create a double-sided mesh, you can choose what parts of 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
  78276. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  78277. * @param name defines the name of the mesh to create
  78278. * @param options defines the options used to create the mesh
  78279. * @param scene defines the hosting scene
  78280. * @returns a new Mesh
  78281. */
  78282. static CreatePolyhedron(name: string, options: {
  78283. type?: number;
  78284. size?: number;
  78285. sizeX?: number;
  78286. sizeY?: number;
  78287. sizeZ?: number;
  78288. custom?: any;
  78289. faceUV?: Vector4[];
  78290. faceColors?: Color4[];
  78291. updatable?: boolean;
  78292. sideOrientation?: number;
  78293. }, scene: Scene): Mesh;
  78294. /**
  78295. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  78296. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  78297. * * 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`)
  78298. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  78299. * * 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
  78300. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  78301. * * If you create a double-sided mesh, you can choose what parts of 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
  78302. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  78303. * @param name defines the name of the mesh
  78304. * @param options defines the options used to create the mesh
  78305. * @param scene defines the hosting scene
  78306. * @returns a new Mesh
  78307. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  78308. */
  78309. static CreateIcoSphere(name: string, options: {
  78310. radius?: number;
  78311. flat?: boolean;
  78312. subdivisions?: number;
  78313. sideOrientation?: number;
  78314. updatable?: boolean;
  78315. }, scene: Scene): Mesh;
  78316. /**
  78317. * Creates a decal mesh.
  78318. * Please consider using the same method from the MeshBuilder class instead.
  78319. * A decal is a mesh usually applied as a model onto the surface of another mesh
  78320. * @param name defines the name of the mesh
  78321. * @param sourceMesh defines the mesh receiving the decal
  78322. * @param position sets the position of the decal in world coordinates
  78323. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  78324. * @param size sets the decal scaling
  78325. * @param angle sets the angle to rotate the decal
  78326. * @returns a new Mesh
  78327. */
  78328. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  78329. /**
  78330. * Prepare internal position array for software CPU skinning
  78331. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  78332. */
  78333. setPositionsForCPUSkinning(): Float32Array;
  78334. /**
  78335. * Prepare internal normal array for software CPU skinning
  78336. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  78337. */
  78338. setNormalsForCPUSkinning(): Float32Array;
  78339. /**
  78340. * Updates the vertex buffer by applying transformation from the bones
  78341. * @param skeleton defines the skeleton to apply to current mesh
  78342. * @returns the current mesh
  78343. */
  78344. applySkeleton(skeleton: Skeleton): Mesh;
  78345. /**
  78346. * 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
  78347. * @param meshes defines the list of meshes to scan
  78348. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  78349. */
  78350. static MinMax(meshes: AbstractMesh[]): {
  78351. min: Vector3;
  78352. max: Vector3;
  78353. };
  78354. /**
  78355. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  78356. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  78357. * @returns a vector3
  78358. */
  78359. static Center(meshesOrMinMaxVector: {
  78360. min: Vector3;
  78361. max: Vector3;
  78362. } | AbstractMesh[]): Vector3;
  78363. /**
  78364. * Merge the array of meshes into a single mesh for performance reasons.
  78365. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  78366. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  78367. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  78368. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  78369. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  78370. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  78371. * @returns a new mesh
  78372. */
  78373. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  78374. /** @hidden */
  78375. addInstance(instance: InstancedMesh): void;
  78376. /** @hidden */
  78377. removeInstance(instance: InstancedMesh): void;
  78378. }
  78379. }
  78380. declare module BABYLON {
  78381. /**
  78382. * Base class for the main features of a material in Babylon.js
  78383. */
  78384. export class Material implements IAnimatable {
  78385. /**
  78386. * Returns the triangle fill mode
  78387. */
  78388. static readonly TriangleFillMode: number;
  78389. /**
  78390. * Returns the wireframe mode
  78391. */
  78392. static readonly WireFrameFillMode: number;
  78393. /**
  78394. * Returns the point fill mode
  78395. */
  78396. static readonly PointFillMode: number;
  78397. /**
  78398. * Returns the point list draw mode
  78399. */
  78400. static readonly PointListDrawMode: number;
  78401. /**
  78402. * Returns the line list draw mode
  78403. */
  78404. static readonly LineListDrawMode: number;
  78405. /**
  78406. * Returns the line loop draw mode
  78407. */
  78408. static readonly LineLoopDrawMode: number;
  78409. /**
  78410. * Returns the line strip draw mode
  78411. */
  78412. static readonly LineStripDrawMode: number;
  78413. /**
  78414. * Returns the triangle strip draw mode
  78415. */
  78416. static readonly TriangleStripDrawMode: number;
  78417. /**
  78418. * Returns the triangle fan draw mode
  78419. */
  78420. static readonly TriangleFanDrawMode: number;
  78421. /**
  78422. * Stores the clock-wise side orientation
  78423. */
  78424. static readonly ClockWiseSideOrientation: number;
  78425. /**
  78426. * Stores the counter clock-wise side orientation
  78427. */
  78428. static readonly CounterClockWiseSideOrientation: number;
  78429. /**
  78430. * The dirty texture flag value
  78431. */
  78432. static readonly TextureDirtyFlag: number;
  78433. /**
  78434. * The dirty light flag value
  78435. */
  78436. static readonly LightDirtyFlag: number;
  78437. /**
  78438. * The dirty fresnel flag value
  78439. */
  78440. static readonly FresnelDirtyFlag: number;
  78441. /**
  78442. * The dirty attribute flag value
  78443. */
  78444. static readonly AttributesDirtyFlag: number;
  78445. /**
  78446. * The dirty misc flag value
  78447. */
  78448. static readonly MiscDirtyFlag: number;
  78449. /**
  78450. * The all dirty flag value
  78451. */
  78452. static readonly AllDirtyFlag: number;
  78453. /**
  78454. * The ID of the material
  78455. */
  78456. id: string;
  78457. /**
  78458. * Gets or sets the unique id of the material
  78459. */
  78460. uniqueId: number;
  78461. /**
  78462. * The name of the material
  78463. */
  78464. name: string;
  78465. /**
  78466. * Gets or sets user defined metadata
  78467. */
  78468. metadata: any;
  78469. /**
  78470. * For internal use only. Please do not use.
  78471. */
  78472. reservedDataStore: any;
  78473. /**
  78474. * Specifies if the ready state should be checked on each call
  78475. */
  78476. checkReadyOnEveryCall: boolean;
  78477. /**
  78478. * Specifies if the ready state should be checked once
  78479. */
  78480. checkReadyOnlyOnce: boolean;
  78481. /**
  78482. * The state of the material
  78483. */
  78484. state: string;
  78485. /**
  78486. * The alpha value of the material
  78487. */
  78488. protected _alpha: number;
  78489. /**
  78490. * Sets the alpha value of the material
  78491. */
  78492. /**
  78493. * Gets the alpha value of the material
  78494. */
  78495. alpha: number;
  78496. /**
  78497. * Specifies if back face culling is enabled
  78498. */
  78499. protected _backFaceCulling: boolean;
  78500. /**
  78501. * Sets the back-face culling state
  78502. */
  78503. /**
  78504. * Gets the back-face culling state
  78505. */
  78506. backFaceCulling: boolean;
  78507. /**
  78508. * Stores the value for side orientation
  78509. */
  78510. sideOrientation: number;
  78511. /**
  78512. * Callback triggered when the material is compiled
  78513. */
  78514. onCompiled: (effect: Effect) => void;
  78515. /**
  78516. * Callback triggered when an error occurs
  78517. */
  78518. onError: (effect: Effect, errors: string) => void;
  78519. /**
  78520. * Callback triggered to get the render target textures
  78521. */
  78522. getRenderTargetTextures: () => SmartArray<RenderTargetTexture>;
  78523. /**
  78524. * Gets a boolean indicating that current material needs to register RTT
  78525. */
  78526. readonly hasRenderTargetTextures: boolean;
  78527. /**
  78528. * Specifies if the material should be serialized
  78529. */
  78530. doNotSerialize: boolean;
  78531. /**
  78532. * @hidden
  78533. */
  78534. _storeEffectOnSubMeshes: boolean;
  78535. /**
  78536. * Stores the animations for the material
  78537. */
  78538. animations: Array<Animation>;
  78539. /**
  78540. * An event triggered when the material is disposed
  78541. */
  78542. onDisposeObservable: Observable<Material>;
  78543. /**
  78544. * An observer which watches for dispose events
  78545. */
  78546. private _onDisposeObserver;
  78547. private _onUnBindObservable;
  78548. /**
  78549. * Called during a dispose event
  78550. */
  78551. onDispose: () => void;
  78552. private _onBindObservable;
  78553. /**
  78554. * An event triggered when the material is bound
  78555. */
  78556. readonly onBindObservable: Observable<AbstractMesh>;
  78557. /**
  78558. * An observer which watches for bind events
  78559. */
  78560. private _onBindObserver;
  78561. /**
  78562. * Called during a bind event
  78563. */
  78564. onBind: (Mesh: AbstractMesh) => void;
  78565. /**
  78566. * An event triggered when the material is unbound
  78567. */
  78568. readonly onUnBindObservable: Observable<Material>;
  78569. /**
  78570. * Stores the value of the alpha mode
  78571. */
  78572. private _alphaMode;
  78573. /**
  78574. * Sets the value of the alpha mode.
  78575. *
  78576. * | Value | Type | Description |
  78577. * | --- | --- | --- |
  78578. * | 0 | ALPHA_DISABLE | |
  78579. * | 1 | ALPHA_ADD | |
  78580. * | 2 | ALPHA_COMBINE | |
  78581. * | 3 | ALPHA_SUBTRACT | |
  78582. * | 4 | ALPHA_MULTIPLY | |
  78583. * | 5 | ALPHA_MAXIMIZED | |
  78584. * | 6 | ALPHA_ONEONE | |
  78585. * | 7 | ALPHA_PREMULTIPLIED | |
  78586. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  78587. * | 9 | ALPHA_INTERPOLATE | |
  78588. * | 10 | ALPHA_SCREENMODE | |
  78589. *
  78590. */
  78591. /**
  78592. * Gets the value of the alpha mode
  78593. */
  78594. alphaMode: number;
  78595. /**
  78596. * Stores the state of the need depth pre-pass value
  78597. */
  78598. private _needDepthPrePass;
  78599. /**
  78600. * Sets the need depth pre-pass value
  78601. */
  78602. /**
  78603. * Gets the depth pre-pass value
  78604. */
  78605. needDepthPrePass: boolean;
  78606. /**
  78607. * Specifies if depth writing should be disabled
  78608. */
  78609. disableDepthWrite: boolean;
  78610. /**
  78611. * Specifies if depth writing should be forced
  78612. */
  78613. forceDepthWrite: boolean;
  78614. /**
  78615. * Specifies if there should be a separate pass for culling
  78616. */
  78617. separateCullingPass: boolean;
  78618. /**
  78619. * Stores the state specifing if fog should be enabled
  78620. */
  78621. private _fogEnabled;
  78622. /**
  78623. * Sets the state for enabling fog
  78624. */
  78625. /**
  78626. * Gets the value of the fog enabled state
  78627. */
  78628. fogEnabled: boolean;
  78629. /**
  78630. * Stores the size of points
  78631. */
  78632. pointSize: number;
  78633. /**
  78634. * Stores the z offset value
  78635. */
  78636. zOffset: number;
  78637. /**
  78638. * Gets a value specifying if wireframe mode is enabled
  78639. */
  78640. /**
  78641. * Sets the state of wireframe mode
  78642. */
  78643. wireframe: boolean;
  78644. /**
  78645. * Gets the value specifying if point clouds are enabled
  78646. */
  78647. /**
  78648. * Sets the state of point cloud mode
  78649. */
  78650. pointsCloud: boolean;
  78651. /**
  78652. * Gets the material fill mode
  78653. */
  78654. /**
  78655. * Sets the material fill mode
  78656. */
  78657. fillMode: number;
  78658. /**
  78659. * @hidden
  78660. * Stores the effects for the material
  78661. */
  78662. _effect: Nullable<Effect>;
  78663. /**
  78664. * @hidden
  78665. * Specifies if the material was previously ready
  78666. */
  78667. _wasPreviouslyReady: boolean;
  78668. /**
  78669. * Specifies if uniform buffers should be used
  78670. */
  78671. private _useUBO;
  78672. /**
  78673. * Stores a reference to the scene
  78674. */
  78675. private _scene;
  78676. /**
  78677. * Stores the fill mode state
  78678. */
  78679. private _fillMode;
  78680. /**
  78681. * Specifies if the depth write state should be cached
  78682. */
  78683. private _cachedDepthWriteState;
  78684. /**
  78685. * Stores the uniform buffer
  78686. */
  78687. protected _uniformBuffer: UniformBuffer;
  78688. /** @hidden */
  78689. _indexInSceneMaterialArray: number;
  78690. /** @hidden */
  78691. meshMap: Nullable<{
  78692. [id: string]: AbstractMesh | undefined;
  78693. }>;
  78694. /**
  78695. * Creates a material instance
  78696. * @param name defines the name of the material
  78697. * @param scene defines the scene to reference
  78698. * @param doNotAdd specifies if the material should be added to the scene
  78699. */
  78700. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  78701. /**
  78702. * Returns a string representation of the current material
  78703. * @param fullDetails defines a boolean indicating which levels of logging is desired
  78704. * @returns a string with material information
  78705. */
  78706. toString(fullDetails?: boolean): string;
  78707. /**
  78708. * Gets the class name of the material
  78709. * @returns a string with the class name of the material
  78710. */
  78711. getClassName(): string;
  78712. /**
  78713. * Specifies if updates for the material been locked
  78714. */
  78715. readonly isFrozen: boolean;
  78716. /**
  78717. * Locks updates for the material
  78718. */
  78719. freeze(): void;
  78720. /**
  78721. * Unlocks updates for the material
  78722. */
  78723. unfreeze(): void;
  78724. /**
  78725. * Specifies if the material is ready to be used
  78726. * @param mesh defines the mesh to check
  78727. * @param useInstances specifies if instances should be used
  78728. * @returns a boolean indicating if the material is ready to be used
  78729. */
  78730. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  78731. /**
  78732. * Specifies that the submesh is ready to be used
  78733. * @param mesh defines the mesh to check
  78734. * @param subMesh defines which submesh to check
  78735. * @param useInstances specifies that instances should be used
  78736. * @returns a boolean indicating that the submesh is ready or not
  78737. */
  78738. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  78739. /**
  78740. * Returns the material effect
  78741. * @returns the effect associated with the material
  78742. */
  78743. getEffect(): Nullable<Effect>;
  78744. /**
  78745. * Returns the current scene
  78746. * @returns a Scene
  78747. */
  78748. getScene(): Scene;
  78749. /**
  78750. * Specifies if the material will require alpha blending
  78751. * @returns a boolean specifying if alpha blending is needed
  78752. */
  78753. needAlphaBlending(): boolean;
  78754. /**
  78755. * Specifies if the mesh will require alpha blending
  78756. * @param mesh defines the mesh to check
  78757. * @returns a boolean specifying if alpha blending is needed for the mesh
  78758. */
  78759. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  78760. /**
  78761. * Specifies if this material should be rendered in alpha test mode
  78762. * @returns a boolean specifying if an alpha test is needed.
  78763. */
  78764. needAlphaTesting(): boolean;
  78765. /**
  78766. * Gets the texture used for the alpha test
  78767. * @returns the texture to use for alpha testing
  78768. */
  78769. getAlphaTestTexture(): Nullable<BaseTexture>;
  78770. /**
  78771. * Marks the material to indicate that it needs to be re-calculated
  78772. */
  78773. markDirty(): void;
  78774. /** @hidden */
  78775. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  78776. /**
  78777. * Binds the material to the mesh
  78778. * @param world defines the world transformation matrix
  78779. * @param mesh defines the mesh to bind the material to
  78780. */
  78781. bind(world: Matrix, mesh?: Mesh): void;
  78782. /**
  78783. * Binds the submesh to the material
  78784. * @param world defines the world transformation matrix
  78785. * @param mesh defines the mesh containing the submesh
  78786. * @param subMesh defines the submesh to bind the material to
  78787. */
  78788. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  78789. /**
  78790. * Binds the world matrix to the material
  78791. * @param world defines the world transformation matrix
  78792. */
  78793. bindOnlyWorldMatrix(world: Matrix): void;
  78794. /**
  78795. * Binds the scene's uniform buffer to the effect.
  78796. * @param effect defines the effect to bind to the scene uniform buffer
  78797. * @param sceneUbo defines the uniform buffer storing scene data
  78798. */
  78799. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  78800. /**
  78801. * Binds the view matrix to the effect
  78802. * @param effect defines the effect to bind the view matrix to
  78803. */
  78804. bindView(effect: Effect): void;
  78805. /**
  78806. * Binds the view projection matrix to the effect
  78807. * @param effect defines the effect to bind the view projection matrix to
  78808. */
  78809. bindViewProjection(effect: Effect): void;
  78810. /**
  78811. * Specifies if material alpha testing should be turned on for the mesh
  78812. * @param mesh defines the mesh to check
  78813. */
  78814. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  78815. /**
  78816. * Processes to execute after binding the material to a mesh
  78817. * @param mesh defines the rendered mesh
  78818. */
  78819. protected _afterBind(mesh?: Mesh): void;
  78820. /**
  78821. * Unbinds the material from the mesh
  78822. */
  78823. unbind(): void;
  78824. /**
  78825. * Gets the active textures from the material
  78826. * @returns an array of textures
  78827. */
  78828. getActiveTextures(): BaseTexture[];
  78829. /**
  78830. * Specifies if the material uses a texture
  78831. * @param texture defines the texture to check against the material
  78832. * @returns a boolean specifying if the material uses the texture
  78833. */
  78834. hasTexture(texture: BaseTexture): boolean;
  78835. /**
  78836. * Makes a duplicate of the material, and gives it a new name
  78837. * @param name defines the new name for the duplicated material
  78838. * @returns the cloned material
  78839. */
  78840. clone(name: string): Nullable<Material>;
  78841. /**
  78842. * Gets the meshes bound to the material
  78843. * @returns an array of meshes bound to the material
  78844. */
  78845. getBindedMeshes(): AbstractMesh[];
  78846. /**
  78847. * Force shader compilation
  78848. * @param mesh defines the mesh associated with this material
  78849. * @param onCompiled defines a function to execute once the material is compiled
  78850. * @param options defines the options to configure the compilation
  78851. */
  78852. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  78853. clipPlane: boolean;
  78854. }>): void;
  78855. /**
  78856. * Force shader compilation
  78857. * @param mesh defines the mesh that will use this material
  78858. * @param options defines additional options for compiling the shaders
  78859. * @returns a promise that resolves when the compilation completes
  78860. */
  78861. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  78862. clipPlane: boolean;
  78863. }>): Promise<void>;
  78864. private static readonly _ImageProcessingDirtyCallBack;
  78865. private static readonly _TextureDirtyCallBack;
  78866. private static readonly _FresnelDirtyCallBack;
  78867. private static readonly _MiscDirtyCallBack;
  78868. private static readonly _LightsDirtyCallBack;
  78869. private static readonly _AttributeDirtyCallBack;
  78870. private static _FresnelAndMiscDirtyCallBack;
  78871. private static _TextureAndMiscDirtyCallBack;
  78872. private static readonly _DirtyCallbackArray;
  78873. private static readonly _RunDirtyCallBacks;
  78874. /**
  78875. * Marks a define in the material to indicate that it needs to be re-computed
  78876. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  78877. */
  78878. markAsDirty(flag: number): void;
  78879. /**
  78880. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  78881. * @param func defines a function which checks material defines against the submeshes
  78882. */
  78883. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  78884. /**
  78885. * Indicates that image processing needs to be re-calculated for all submeshes
  78886. */
  78887. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  78888. /**
  78889. * Indicates that textures need to be re-calculated for all submeshes
  78890. */
  78891. protected _markAllSubMeshesAsTexturesDirty(): void;
  78892. /**
  78893. * Indicates that fresnel needs to be re-calculated for all submeshes
  78894. */
  78895. protected _markAllSubMeshesAsFresnelDirty(): void;
  78896. /**
  78897. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  78898. */
  78899. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  78900. /**
  78901. * Indicates that lights need to be re-calculated for all submeshes
  78902. */
  78903. protected _markAllSubMeshesAsLightsDirty(): void;
  78904. /**
  78905. * Indicates that attributes need to be re-calculated for all submeshes
  78906. */
  78907. protected _markAllSubMeshesAsAttributesDirty(): void;
  78908. /**
  78909. * Indicates that misc needs to be re-calculated for all submeshes
  78910. */
  78911. protected _markAllSubMeshesAsMiscDirty(): void;
  78912. /**
  78913. * Indicates that textures and misc need to be re-calculated for all submeshes
  78914. */
  78915. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  78916. /**
  78917. * Disposes the material
  78918. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  78919. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  78920. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  78921. */
  78922. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  78923. /** @hidden */
  78924. private releaseVertexArrayObject;
  78925. /**
  78926. * Serializes this material
  78927. * @returns the serialized material object
  78928. */
  78929. serialize(): any;
  78930. /**
  78931. * Creates a material from parsed material data
  78932. * @param parsedMaterial defines parsed material data
  78933. * @param scene defines the hosting scene
  78934. * @param rootUrl defines the root URL to use to load textures
  78935. * @returns a new material
  78936. */
  78937. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): any;
  78938. }
  78939. }
  78940. declare module BABYLON {
  78941. /**
  78942. * Base class for submeshes
  78943. */
  78944. export class BaseSubMesh {
  78945. /** @hidden */
  78946. _materialDefines: Nullable<MaterialDefines>;
  78947. /** @hidden */
  78948. _materialEffect: Nullable<Effect>;
  78949. /**
  78950. * Gets associated effect
  78951. */
  78952. readonly effect: Nullable<Effect>;
  78953. /**
  78954. * Sets associated effect (effect used to render this submesh)
  78955. * @param effect defines the effect to associate with
  78956. * @param defines defines the set of defines used to compile this effect
  78957. */
  78958. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  78959. }
  78960. /**
  78961. * Defines a subdivision inside a mesh
  78962. */
  78963. export class SubMesh extends BaseSubMesh implements ICullable {
  78964. /** the material index to use */
  78965. materialIndex: number;
  78966. /** vertex index start */
  78967. verticesStart: number;
  78968. /** vertices count */
  78969. verticesCount: number;
  78970. /** index start */
  78971. indexStart: number;
  78972. /** indices count */
  78973. indexCount: number;
  78974. /** @hidden */
  78975. _linesIndexCount: number;
  78976. private _mesh;
  78977. private _renderingMesh;
  78978. private _boundingInfo;
  78979. private _linesIndexBuffer;
  78980. /** @hidden */
  78981. _lastColliderWorldVertices: Nullable<Vector3[]>;
  78982. /** @hidden */
  78983. _trianglePlanes: Plane[];
  78984. /** @hidden */
  78985. _lastColliderTransformMatrix: Matrix;
  78986. /** @hidden */
  78987. _renderId: number;
  78988. /** @hidden */
  78989. _alphaIndex: number;
  78990. /** @hidden */
  78991. _distanceToCamera: number;
  78992. /** @hidden */
  78993. _id: number;
  78994. private _currentMaterial;
  78995. /**
  78996. * Add a new submesh to a mesh
  78997. * @param materialIndex defines the material index to use
  78998. * @param verticesStart defines vertex index start
  78999. * @param verticesCount defines vertices count
  79000. * @param indexStart defines index start
  79001. * @param indexCount defines indices count
  79002. * @param mesh defines the parent mesh
  79003. * @param renderingMesh defines an optional rendering mesh
  79004. * @param createBoundingBox defines if bounding box should be created for this submesh
  79005. * @returns the new submesh
  79006. */
  79007. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  79008. /**
  79009. * Creates a new submesh
  79010. * @param materialIndex defines the material index to use
  79011. * @param verticesStart defines vertex index start
  79012. * @param verticesCount defines vertices count
  79013. * @param indexStart defines index start
  79014. * @param indexCount defines indices count
  79015. * @param mesh defines the parent mesh
  79016. * @param renderingMesh defines an optional rendering mesh
  79017. * @param createBoundingBox defines if bounding box should be created for this submesh
  79018. */
  79019. constructor(
  79020. /** the material index to use */
  79021. materialIndex: number,
  79022. /** vertex index start */
  79023. verticesStart: number,
  79024. /** vertices count */
  79025. verticesCount: number,
  79026. /** index start */
  79027. indexStart: number,
  79028. /** indices count */
  79029. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  79030. /**
  79031. * Returns true if this submesh covers the entire parent mesh
  79032. * @ignorenaming
  79033. */
  79034. readonly IsGlobal: boolean;
  79035. /**
  79036. * Returns the submesh BoudingInfo object
  79037. * @returns current bounding info (or mesh's one if the submesh is global)
  79038. */
  79039. getBoundingInfo(): BoundingInfo;
  79040. /**
  79041. * Sets the submesh BoundingInfo
  79042. * @param boundingInfo defines the new bounding info to use
  79043. * @returns the SubMesh
  79044. */
  79045. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  79046. /**
  79047. * Returns the mesh of the current submesh
  79048. * @return the parent mesh
  79049. */
  79050. getMesh(): AbstractMesh;
  79051. /**
  79052. * Returns the rendering mesh of the submesh
  79053. * @returns the rendering mesh (could be different from parent mesh)
  79054. */
  79055. getRenderingMesh(): Mesh;
  79056. /**
  79057. * Returns the submesh material
  79058. * @returns null or the current material
  79059. */
  79060. getMaterial(): Nullable<Material>;
  79061. /**
  79062. * Sets a new updated BoundingInfo object to the submesh
  79063. * @returns the SubMesh
  79064. */
  79065. refreshBoundingInfo(): SubMesh;
  79066. /** @hidden */
  79067. _checkCollision(collider: Collider): boolean;
  79068. /**
  79069. * Updates the submesh BoundingInfo
  79070. * @param world defines the world matrix to use to update the bounding info
  79071. * @returns the submesh
  79072. */
  79073. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  79074. /**
  79075. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  79076. * @param frustumPlanes defines the frustum planes
  79077. * @returns true if the submesh is intersecting with the frustum
  79078. */
  79079. isInFrustum(frustumPlanes: Plane[]): boolean;
  79080. /**
  79081. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  79082. * @param frustumPlanes defines the frustum planes
  79083. * @returns true if the submesh is inside the frustum
  79084. */
  79085. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  79086. /**
  79087. * Renders the submesh
  79088. * @param enableAlphaMode defines if alpha needs to be used
  79089. * @returns the submesh
  79090. */
  79091. render(enableAlphaMode: boolean): SubMesh;
  79092. /**
  79093. * @hidden
  79094. */
  79095. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): WebGLBuffer;
  79096. /**
  79097. * Checks if the submesh intersects with a ray
  79098. * @param ray defines the ray to test
  79099. * @returns true is the passed ray intersects the submesh bounding box
  79100. */
  79101. canIntersects(ray: Ray): boolean;
  79102. /**
  79103. * Intersects current submesh with a ray
  79104. * @param ray defines the ray to test
  79105. * @param positions defines mesh's positions array
  79106. * @param indices defines mesh's indices array
  79107. * @param fastCheck defines if only bounding info should be used
  79108. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  79109. * @returns intersection info or null if no intersection
  79110. */
  79111. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  79112. /** @hidden */
  79113. private _intersectLines;
  79114. /** @hidden */
  79115. private _intersectTriangles;
  79116. /** @hidden */
  79117. _rebuild(): void;
  79118. /**
  79119. * Creates a new submesh from the passed mesh
  79120. * @param newMesh defines the new hosting mesh
  79121. * @param newRenderingMesh defines an optional rendering mesh
  79122. * @returns the new submesh
  79123. */
  79124. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  79125. /**
  79126. * Release associated resources
  79127. */
  79128. dispose(): void;
  79129. /**
  79130. * Gets the class name
  79131. * @returns the string "SubMesh".
  79132. */
  79133. getClassName(): string;
  79134. /**
  79135. * Creates a new submesh from indices data
  79136. * @param materialIndex the index of the main mesh material
  79137. * @param startIndex the index where to start the copy in the mesh indices array
  79138. * @param indexCount the number of indices to copy then from the startIndex
  79139. * @param mesh the main mesh to create the submesh from
  79140. * @param renderingMesh the optional rendering mesh
  79141. * @returns a new submesh
  79142. */
  79143. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  79144. }
  79145. }
  79146. declare module BABYLON {
  79147. /**
  79148. * Class used to store geometry data (vertex buffers + index buffer)
  79149. */
  79150. export class Geometry implements IGetSetVerticesData {
  79151. /**
  79152. * Gets or sets the ID of the geometry
  79153. */
  79154. id: string;
  79155. /**
  79156. * Gets or sets the unique ID of the geometry
  79157. */
  79158. uniqueId: number;
  79159. /**
  79160. * Gets the delay loading state of the geometry (none by default which means not delayed)
  79161. */
  79162. delayLoadState: number;
  79163. /**
  79164. * Gets the file containing the data to load when running in delay load state
  79165. */
  79166. delayLoadingFile: Nullable<string>;
  79167. /**
  79168. * Callback called when the geometry is updated
  79169. */
  79170. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  79171. private _scene;
  79172. private _engine;
  79173. private _meshes;
  79174. private _totalVertices;
  79175. /** @hidden */
  79176. _indices: IndicesArray;
  79177. /** @hidden */
  79178. _vertexBuffers: {
  79179. [key: string]: VertexBuffer;
  79180. };
  79181. private _isDisposed;
  79182. private _extend;
  79183. private _boundingBias;
  79184. /** @hidden */
  79185. _delayInfo: Array<string>;
  79186. private _indexBuffer;
  79187. private _indexBufferIsUpdatable;
  79188. /** @hidden */
  79189. _boundingInfo: Nullable<BoundingInfo>;
  79190. /** @hidden */
  79191. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  79192. /** @hidden */
  79193. _softwareSkinningFrameId: number;
  79194. private _vertexArrayObjects;
  79195. private _updatable;
  79196. /** @hidden */
  79197. _positions: Nullable<Vector3[]>;
  79198. /**
  79199. * 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
  79200. */
  79201. /**
  79202. * 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
  79203. */
  79204. boundingBias: Vector2;
  79205. /**
  79206. * Static function used to attach a new empty geometry to a mesh
  79207. * @param mesh defines the mesh to attach the geometry to
  79208. * @returns the new Geometry
  79209. */
  79210. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  79211. /**
  79212. * Creates a new geometry
  79213. * @param id defines the unique ID
  79214. * @param scene defines the hosting scene
  79215. * @param vertexData defines the VertexData used to get geometry data
  79216. * @param updatable defines if geometry must be updatable (false by default)
  79217. * @param mesh defines the mesh that will be associated with the geometry
  79218. */
  79219. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  79220. /**
  79221. * Gets the current extend of the geometry
  79222. */
  79223. readonly extend: {
  79224. minimum: Vector3;
  79225. maximum: Vector3;
  79226. };
  79227. /**
  79228. * Gets the hosting scene
  79229. * @returns the hosting Scene
  79230. */
  79231. getScene(): Scene;
  79232. /**
  79233. * Gets the hosting engine
  79234. * @returns the hosting Engine
  79235. */
  79236. getEngine(): Engine;
  79237. /**
  79238. * Defines if the geometry is ready to use
  79239. * @returns true if the geometry is ready to be used
  79240. */
  79241. isReady(): boolean;
  79242. /**
  79243. * Gets a value indicating that the geometry should not be serialized
  79244. */
  79245. readonly doNotSerialize: boolean;
  79246. /** @hidden */
  79247. _rebuild(): void;
  79248. /**
  79249. * Affects all geometry data in one call
  79250. * @param vertexData defines the geometry data
  79251. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  79252. */
  79253. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  79254. /**
  79255. * Set specific vertex data
  79256. * @param kind defines the data kind (Position, normal, etc...)
  79257. * @param data defines the vertex data to use
  79258. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  79259. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  79260. */
  79261. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  79262. /**
  79263. * Removes a specific vertex data
  79264. * @param kind defines the data kind (Position, normal, etc...)
  79265. */
  79266. removeVerticesData(kind: string): void;
  79267. /**
  79268. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  79269. * @param buffer defines the vertex buffer to use
  79270. * @param totalVertices defines the total number of vertices for position kind (could be null)
  79271. */
  79272. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  79273. /**
  79274. * Update a specific vertex buffer
  79275. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  79276. * It will do nothing if the buffer is not updatable
  79277. * @param kind defines the data kind (Position, normal, etc...)
  79278. * @param data defines the data to use
  79279. * @param offset defines the offset in the target buffer where to store the data
  79280. * @param useBytes set to true if the offset is in bytes
  79281. */
  79282. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  79283. /**
  79284. * Update a specific vertex buffer
  79285. * This function will create a new buffer if the current one is not updatable
  79286. * @param kind defines the data kind (Position, normal, etc...)
  79287. * @param data defines the data to use
  79288. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  79289. */
  79290. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  79291. private _updateBoundingInfo;
  79292. /** @hidden */
  79293. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<WebGLBuffer>): void;
  79294. /**
  79295. * Gets total number of vertices
  79296. * @returns the total number of vertices
  79297. */
  79298. getTotalVertices(): number;
  79299. /**
  79300. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  79301. * @param kind defines the data kind (Position, normal, etc...)
  79302. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  79303. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  79304. * @returns a float array containing vertex data
  79305. */
  79306. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  79307. /**
  79308. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  79309. * @param kind defines the data kind (Position, normal, etc...)
  79310. * @returns true if the vertex buffer with the specified kind is updatable
  79311. */
  79312. isVertexBufferUpdatable(kind: string): boolean;
  79313. /**
  79314. * Gets a specific vertex buffer
  79315. * @param kind defines the data kind (Position, normal, etc...)
  79316. * @returns a VertexBuffer
  79317. */
  79318. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  79319. /**
  79320. * Returns all vertex buffers
  79321. * @return an object holding all vertex buffers indexed by kind
  79322. */
  79323. getVertexBuffers(): Nullable<{
  79324. [key: string]: VertexBuffer;
  79325. }>;
  79326. /**
  79327. * Gets a boolean indicating if specific vertex buffer is present
  79328. * @param kind defines the data kind (Position, normal, etc...)
  79329. * @returns true if data is present
  79330. */
  79331. isVerticesDataPresent(kind: string): boolean;
  79332. /**
  79333. * Gets a list of all attached data kinds (Position, normal, etc...)
  79334. * @returns a list of string containing all kinds
  79335. */
  79336. getVerticesDataKinds(): string[];
  79337. /**
  79338. * Update index buffer
  79339. * @param indices defines the indices to store in the index buffer
  79340. * @param offset defines the offset in the target buffer where to store the data
  79341. */
  79342. updateIndices(indices: IndicesArray, offset?: number): void;
  79343. /**
  79344. * Creates a new index buffer
  79345. * @param indices defines the indices to store in the index buffer
  79346. * @param totalVertices defines the total number of vertices (could be null)
  79347. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  79348. */
  79349. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  79350. /**
  79351. * Return the total number of indices
  79352. * @returns the total number of indices
  79353. */
  79354. getTotalIndices(): number;
  79355. /**
  79356. * Gets the index buffer array
  79357. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  79358. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  79359. * @returns the index buffer array
  79360. */
  79361. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  79362. /**
  79363. * Gets the index buffer
  79364. * @return the index buffer
  79365. */
  79366. getIndexBuffer(): Nullable<WebGLBuffer>;
  79367. /** @hidden */
  79368. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  79369. /**
  79370. * Release the associated resources for a specific mesh
  79371. * @param mesh defines the source mesh
  79372. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  79373. */
  79374. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  79375. /**
  79376. * Apply current geometry to a given mesh
  79377. * @param mesh defines the mesh to apply geometry to
  79378. */
  79379. applyToMesh(mesh: Mesh): void;
  79380. private _updateExtend;
  79381. private _applyToMesh;
  79382. private notifyUpdate;
  79383. /**
  79384. * Load the geometry if it was flagged as delay loaded
  79385. * @param scene defines the hosting scene
  79386. * @param onLoaded defines a callback called when the geometry is loaded
  79387. */
  79388. load(scene: Scene, onLoaded?: () => void): void;
  79389. private _queueLoad;
  79390. /**
  79391. * Invert the geometry to move from a right handed system to a left handed one.
  79392. */
  79393. toLeftHanded(): void;
  79394. /** @hidden */
  79395. _resetPointsArrayCache(): void;
  79396. /** @hidden */
  79397. _generatePointsArray(): boolean;
  79398. /**
  79399. * Gets a value indicating if the geometry is disposed
  79400. * @returns true if the geometry was disposed
  79401. */
  79402. isDisposed(): boolean;
  79403. private _disposeVertexArrayObjects;
  79404. /**
  79405. * Free all associated resources
  79406. */
  79407. dispose(): void;
  79408. /**
  79409. * Clone the current geometry into a new geometry
  79410. * @param id defines the unique ID of the new geometry
  79411. * @returns a new geometry object
  79412. */
  79413. copy(id: string): Geometry;
  79414. /**
  79415. * Serialize the current geometry info (and not the vertices data) into a JSON object
  79416. * @return a JSON representation of the current geometry data (without the vertices data)
  79417. */
  79418. serialize(): any;
  79419. private toNumberArray;
  79420. /**
  79421. * Serialize all vertices data into a JSON oject
  79422. * @returns a JSON representation of the current geometry data
  79423. */
  79424. serializeVerticeData(): any;
  79425. /**
  79426. * Extracts a clone of a mesh geometry
  79427. * @param mesh defines the source mesh
  79428. * @param id defines the unique ID of the new geometry object
  79429. * @returns the new geometry object
  79430. */
  79431. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  79432. /**
  79433. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  79434. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  79435. * Be aware Math.random() could cause collisions, but:
  79436. * "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"
  79437. * @returns a string containing a new GUID
  79438. */
  79439. static RandomId(): string;
  79440. /** @hidden */
  79441. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  79442. private static _CleanMatricesWeights;
  79443. /**
  79444. * Create a new geometry from persisted data (Using .babylon file format)
  79445. * @param parsedVertexData defines the persisted data
  79446. * @param scene defines the hosting scene
  79447. * @param rootUrl defines the root url to use to load assets (like delayed data)
  79448. * @returns the new geometry object
  79449. */
  79450. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  79451. }
  79452. }
  79453. declare module BABYLON {
  79454. /**
  79455. * Define an interface for all classes that will get and set the data on vertices
  79456. */
  79457. export interface IGetSetVerticesData {
  79458. /**
  79459. * Gets a boolean indicating if specific vertex data is present
  79460. * @param kind defines the vertex data kind to use
  79461. * @returns true is data kind is present
  79462. */
  79463. isVerticesDataPresent(kind: string): boolean;
  79464. /**
  79465. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  79466. * @param kind defines the data kind (Position, normal, etc...)
  79467. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  79468. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  79469. * @returns a float array containing vertex data
  79470. */
  79471. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  79472. /**
  79473. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  79474. * @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.
  79475. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  79476. * @returns the indices array or an empty array if the mesh has no geometry
  79477. */
  79478. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  79479. /**
  79480. * Set specific vertex data
  79481. * @param kind defines the data kind (Position, normal, etc...)
  79482. * @param data defines the vertex data to use
  79483. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  79484. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  79485. */
  79486. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  79487. /**
  79488. * Update a specific associated vertex buffer
  79489. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  79490. * - VertexBuffer.PositionKind
  79491. * - VertexBuffer.UVKind
  79492. * - VertexBuffer.UV2Kind
  79493. * - VertexBuffer.UV3Kind
  79494. * - VertexBuffer.UV4Kind
  79495. * - VertexBuffer.UV5Kind
  79496. * - VertexBuffer.UV6Kind
  79497. * - VertexBuffer.ColorKind
  79498. * - VertexBuffer.MatricesIndicesKind
  79499. * - VertexBuffer.MatricesIndicesExtraKind
  79500. * - VertexBuffer.MatricesWeightsKind
  79501. * - VertexBuffer.MatricesWeightsExtraKind
  79502. * @param data defines the data source
  79503. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  79504. * @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)
  79505. */
  79506. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  79507. /**
  79508. * Creates a new index buffer
  79509. * @param indices defines the indices to store in the index buffer
  79510. * @param totalVertices defines the total number of vertices (could be null)
  79511. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  79512. */
  79513. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  79514. }
  79515. /**
  79516. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  79517. */
  79518. export class VertexData {
  79519. /**
  79520. * Mesh side orientation : usually the external or front surface
  79521. */
  79522. static readonly FRONTSIDE: number;
  79523. /**
  79524. * Mesh side orientation : usually the internal or back surface
  79525. */
  79526. static readonly BACKSIDE: number;
  79527. /**
  79528. * Mesh side orientation : both internal and external or front and back surfaces
  79529. */
  79530. static readonly DOUBLESIDE: number;
  79531. /**
  79532. * Mesh side orientation : by default, `FRONTSIDE`
  79533. */
  79534. static readonly DEFAULTSIDE: number;
  79535. /**
  79536. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  79537. */
  79538. positions: Nullable<FloatArray>;
  79539. /**
  79540. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  79541. */
  79542. normals: Nullable<FloatArray>;
  79543. /**
  79544. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  79545. */
  79546. tangents: Nullable<FloatArray>;
  79547. /**
  79548. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  79549. */
  79550. uvs: Nullable<FloatArray>;
  79551. /**
  79552. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  79553. */
  79554. uvs2: Nullable<FloatArray>;
  79555. /**
  79556. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  79557. */
  79558. uvs3: Nullable<FloatArray>;
  79559. /**
  79560. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  79561. */
  79562. uvs4: Nullable<FloatArray>;
  79563. /**
  79564. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  79565. */
  79566. uvs5: Nullable<FloatArray>;
  79567. /**
  79568. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  79569. */
  79570. uvs6: Nullable<FloatArray>;
  79571. /**
  79572. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  79573. */
  79574. colors: Nullable<FloatArray>;
  79575. /**
  79576. * 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).
  79577. */
  79578. matricesIndices: Nullable<FloatArray>;
  79579. /**
  79580. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  79581. */
  79582. matricesWeights: Nullable<FloatArray>;
  79583. /**
  79584. * An array extending the number of possible indices
  79585. */
  79586. matricesIndicesExtra: Nullable<FloatArray>;
  79587. /**
  79588. * An array extending the number of possible weights when the number of indices is extended
  79589. */
  79590. matricesWeightsExtra: Nullable<FloatArray>;
  79591. /**
  79592. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  79593. */
  79594. indices: Nullable<IndicesArray>;
  79595. /**
  79596. * Uses the passed data array to set the set the values for the specified kind of data
  79597. * @param data a linear array of floating numbers
  79598. * @param kind the type of data that is being set, eg positions, colors etc
  79599. */
  79600. set(data: FloatArray, kind: string): void;
  79601. /**
  79602. * Associates the vertexData to the passed Mesh.
  79603. * Sets it as updatable or not (default `false`)
  79604. * @param mesh the mesh the vertexData is applied to
  79605. * @param updatable when used and having the value true allows new data to update the vertexData
  79606. * @returns the VertexData
  79607. */
  79608. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  79609. /**
  79610. * Associates the vertexData to the passed Geometry.
  79611. * Sets it as updatable or not (default `false`)
  79612. * @param geometry the geometry the vertexData is applied to
  79613. * @param updatable when used and having the value true allows new data to update the vertexData
  79614. * @returns VertexData
  79615. */
  79616. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  79617. /**
  79618. * Updates the associated mesh
  79619. * @param mesh the mesh to be updated
  79620. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  79621. * @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
  79622. * @returns VertexData
  79623. */
  79624. updateMesh(mesh: Mesh): VertexData;
  79625. /**
  79626. * Updates the associated geometry
  79627. * @param geometry the geometry to be updated
  79628. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  79629. * @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
  79630. * @returns VertexData.
  79631. */
  79632. updateGeometry(geometry: Geometry): VertexData;
  79633. private _applyTo;
  79634. private _update;
  79635. /**
  79636. * Transforms each position and each normal of the vertexData according to the passed Matrix
  79637. * @param matrix the transforming matrix
  79638. * @returns the VertexData
  79639. */
  79640. transform(matrix: Matrix): VertexData;
  79641. /**
  79642. * Merges the passed VertexData into the current one
  79643. * @param other the VertexData to be merged into the current one
  79644. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  79645. * @returns the modified VertexData
  79646. */
  79647. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  79648. private _mergeElement;
  79649. private _validate;
  79650. /**
  79651. * Serializes the VertexData
  79652. * @returns a serialized object
  79653. */
  79654. serialize(): any;
  79655. /**
  79656. * Extracts the vertexData from a mesh
  79657. * @param mesh the mesh from which to extract the VertexData
  79658. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  79659. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  79660. * @returns the object VertexData associated to the passed mesh
  79661. */
  79662. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  79663. /**
  79664. * Extracts the vertexData from the geometry
  79665. * @param geometry the geometry from which to extract the VertexData
  79666. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  79667. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  79668. * @returns the object VertexData associated to the passed mesh
  79669. */
  79670. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  79671. private static _ExtractFrom;
  79672. /**
  79673. * Creates the VertexData for a Ribbon
  79674. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  79675. * * pathArray array of paths, each of which an array of successive Vector3
  79676. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  79677. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  79678. * * 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
  79679. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  79680. * * 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)
  79681. * * 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)
  79682. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  79683. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  79684. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  79685. * @returns the VertexData of the ribbon
  79686. */
  79687. static CreateRibbon(options: {
  79688. pathArray: Vector3[][];
  79689. closeArray?: boolean;
  79690. closePath?: boolean;
  79691. offset?: number;
  79692. sideOrientation?: number;
  79693. frontUVs?: Vector4;
  79694. backUVs?: Vector4;
  79695. invertUV?: boolean;
  79696. uvs?: Vector2[];
  79697. colors?: Color4[];
  79698. }): VertexData;
  79699. /**
  79700. * Creates the VertexData for a box
  79701. * @param options an object used to set the following optional parameters for the box, required but can be empty
  79702. * * size sets the width, height and depth of the box to the value of size, optional default 1
  79703. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  79704. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  79705. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  79706. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  79707. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  79708. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  79709. * * 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)
  79710. * * 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)
  79711. * @returns the VertexData of the box
  79712. */
  79713. static CreateBox(options: {
  79714. size?: number;
  79715. width?: number;
  79716. height?: number;
  79717. depth?: number;
  79718. faceUV?: Vector4[];
  79719. faceColors?: Color4[];
  79720. sideOrientation?: number;
  79721. frontUVs?: Vector4;
  79722. backUVs?: Vector4;
  79723. }): VertexData;
  79724. /**
  79725. * Creates the VertexData for an ellipsoid, defaults to a sphere
  79726. * @param options an object used to set the following optional parameters for the box, required but can be empty
  79727. * * segments sets the number of horizontal strips optional, default 32
  79728. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  79729. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  79730. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  79731. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  79732. * * 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
  79733. * * 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
  79734. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  79735. * * 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)
  79736. * * 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)
  79737. * @returns the VertexData of the ellipsoid
  79738. */
  79739. static CreateSphere(options: {
  79740. segments?: number;
  79741. diameter?: number;
  79742. diameterX?: number;
  79743. diameterY?: number;
  79744. diameterZ?: number;
  79745. arc?: number;
  79746. slice?: number;
  79747. sideOrientation?: number;
  79748. frontUVs?: Vector4;
  79749. backUVs?: Vector4;
  79750. }): VertexData;
  79751. /**
  79752. * Creates the VertexData for a cylinder, cone or prism
  79753. * @param options an object used to set the following optional parameters for the box, required but can be empty
  79754. * * height sets the height (y direction) of the cylinder, optional, default 2
  79755. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  79756. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  79757. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  79758. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  79759. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  79760. * * 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
  79761. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  79762. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  79763. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  79764. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  79765. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  79766. * * 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)
  79767. * * 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)
  79768. * @returns the VertexData of the cylinder, cone or prism
  79769. */
  79770. static CreateCylinder(options: {
  79771. height?: number;
  79772. diameterTop?: number;
  79773. diameterBottom?: number;
  79774. diameter?: number;
  79775. tessellation?: number;
  79776. subdivisions?: number;
  79777. arc?: number;
  79778. faceColors?: Color4[];
  79779. faceUV?: Vector4[];
  79780. hasRings?: boolean;
  79781. enclose?: boolean;
  79782. sideOrientation?: number;
  79783. frontUVs?: Vector4;
  79784. backUVs?: Vector4;
  79785. }): VertexData;
  79786. /**
  79787. * Creates the VertexData for a torus
  79788. * @param options an object used to set the following optional parameters for the box, required but can be empty
  79789. * * diameter the diameter of the torus, optional default 1
  79790. * * thickness the diameter of the tube forming the torus, optional default 0.5
  79791. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  79792. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  79793. * * 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)
  79794. * * 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)
  79795. * @returns the VertexData of the torus
  79796. */
  79797. static CreateTorus(options: {
  79798. diameter?: number;
  79799. thickness?: number;
  79800. tessellation?: number;
  79801. sideOrientation?: number;
  79802. frontUVs?: Vector4;
  79803. backUVs?: Vector4;
  79804. }): VertexData;
  79805. /**
  79806. * Creates the VertexData of the LineSystem
  79807. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  79808. * - lines an array of lines, each line being an array of successive Vector3
  79809. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  79810. * @returns the VertexData of the LineSystem
  79811. */
  79812. static CreateLineSystem(options: {
  79813. lines: Vector3[][];
  79814. colors?: Nullable<Color4[][]>;
  79815. }): VertexData;
  79816. /**
  79817. * Create the VertexData for a DashedLines
  79818. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  79819. * - points an array successive Vector3
  79820. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  79821. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  79822. * - dashNb the intended total number of dashes, optional, default 200
  79823. * @returns the VertexData for the DashedLines
  79824. */
  79825. static CreateDashedLines(options: {
  79826. points: Vector3[];
  79827. dashSize?: number;
  79828. gapSize?: number;
  79829. dashNb?: number;
  79830. }): VertexData;
  79831. /**
  79832. * Creates the VertexData for a Ground
  79833. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  79834. * - width the width (x direction) of the ground, optional, default 1
  79835. * - height the height (z direction) of the ground, optional, default 1
  79836. * - subdivisions the number of subdivisions per side, optional, default 1
  79837. * @returns the VertexData of the Ground
  79838. */
  79839. static CreateGround(options: {
  79840. width?: number;
  79841. height?: number;
  79842. subdivisions?: number;
  79843. subdivisionsX?: number;
  79844. subdivisionsY?: number;
  79845. }): VertexData;
  79846. /**
  79847. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  79848. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  79849. * * xmin the ground minimum X coordinate, optional, default -1
  79850. * * zmin the ground minimum Z coordinate, optional, default -1
  79851. * * xmax the ground maximum X coordinate, optional, default 1
  79852. * * zmax the ground maximum Z coordinate, optional, default 1
  79853. * * 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}
  79854. * * 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}
  79855. * @returns the VertexData of the TiledGround
  79856. */
  79857. static CreateTiledGround(options: {
  79858. xmin: number;
  79859. zmin: number;
  79860. xmax: number;
  79861. zmax: number;
  79862. subdivisions?: {
  79863. w: number;
  79864. h: number;
  79865. };
  79866. precision?: {
  79867. w: number;
  79868. h: number;
  79869. };
  79870. }): VertexData;
  79871. /**
  79872. * Creates the VertexData of the Ground designed from a heightmap
  79873. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  79874. * * width the width (x direction) of the ground
  79875. * * height the height (z direction) of the ground
  79876. * * subdivisions the number of subdivisions per side
  79877. * * minHeight the minimum altitude on the ground, optional, default 0
  79878. * * maxHeight the maximum altitude on the ground, optional default 1
  79879. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  79880. * * buffer the array holding the image color data
  79881. * * bufferWidth the width of image
  79882. * * bufferHeight the height of image
  79883. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  79884. * @returns the VertexData of the Ground designed from a heightmap
  79885. */
  79886. static CreateGroundFromHeightMap(options: {
  79887. width: number;
  79888. height: number;
  79889. subdivisions: number;
  79890. minHeight: number;
  79891. maxHeight: number;
  79892. colorFilter: Color3;
  79893. buffer: Uint8Array;
  79894. bufferWidth: number;
  79895. bufferHeight: number;
  79896. alphaFilter: number;
  79897. }): VertexData;
  79898. /**
  79899. * Creates the VertexData for a Plane
  79900. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  79901. * * size sets the width and height of the plane to the value of size, optional default 1
  79902. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  79903. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  79904. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  79905. * * 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)
  79906. * * 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)
  79907. * @returns the VertexData of the box
  79908. */
  79909. static CreatePlane(options: {
  79910. size?: number;
  79911. width?: number;
  79912. height?: number;
  79913. sideOrientation?: number;
  79914. frontUVs?: Vector4;
  79915. backUVs?: Vector4;
  79916. }): VertexData;
  79917. /**
  79918. * Creates the VertexData of the Disc or regular Polygon
  79919. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  79920. * * radius the radius of the disc, optional default 0.5
  79921. * * tessellation the number of polygon sides, optional, default 64
  79922. * * 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
  79923. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  79924. * * 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)
  79925. * * 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)
  79926. * @returns the VertexData of the box
  79927. */
  79928. static CreateDisc(options: {
  79929. radius?: number;
  79930. tessellation?: number;
  79931. arc?: number;
  79932. sideOrientation?: number;
  79933. frontUVs?: Vector4;
  79934. backUVs?: Vector4;
  79935. }): VertexData;
  79936. /**
  79937. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  79938. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  79939. * @param polygon a mesh built from polygonTriangulation.build()
  79940. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  79941. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  79942. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  79943. * @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)
  79944. * @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)
  79945. * @returns the VertexData of the Polygon
  79946. */
  79947. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  79948. /**
  79949. * Creates the VertexData of the IcoSphere
  79950. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  79951. * * radius the radius of the IcoSphere, optional default 1
  79952. * * radiusX allows stretching in the x direction, optional, default radius
  79953. * * radiusY allows stretching in the y direction, optional, default radius
  79954. * * radiusZ allows stretching in the z direction, optional, default radius
  79955. * * flat when true creates a flat shaded mesh, optional, default true
  79956. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  79957. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  79958. * * 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)
  79959. * * 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)
  79960. * @returns the VertexData of the IcoSphere
  79961. */
  79962. static CreateIcoSphere(options: {
  79963. radius?: number;
  79964. radiusX?: number;
  79965. radiusY?: number;
  79966. radiusZ?: number;
  79967. flat?: boolean;
  79968. subdivisions?: number;
  79969. sideOrientation?: number;
  79970. frontUVs?: Vector4;
  79971. backUVs?: Vector4;
  79972. }): VertexData;
  79973. /**
  79974. * Creates the VertexData for a Polyhedron
  79975. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  79976. * * type provided types are:
  79977. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  79978. * * 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)
  79979. * * size the size of the IcoSphere, optional default 1
  79980. * * sizeX allows stretching in the x direction, optional, default size
  79981. * * sizeY allows stretching in the y direction, optional, default size
  79982. * * sizeZ allows stretching in the z direction, optional, default size
  79983. * * 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
  79984. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  79985. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  79986. * * flat when true creates a flat shaded mesh, optional, default true
  79987. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  79988. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  79989. * * 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)
  79990. * * 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)
  79991. * @returns the VertexData of the Polyhedron
  79992. */
  79993. static CreatePolyhedron(options: {
  79994. type?: number;
  79995. size?: number;
  79996. sizeX?: number;
  79997. sizeY?: number;
  79998. sizeZ?: number;
  79999. custom?: any;
  80000. faceUV?: Vector4[];
  80001. faceColors?: Color4[];
  80002. flat?: boolean;
  80003. sideOrientation?: number;
  80004. frontUVs?: Vector4;
  80005. backUVs?: Vector4;
  80006. }): VertexData;
  80007. /**
  80008. * Creates the VertexData for a TorusKnot
  80009. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  80010. * * radius the radius of the torus knot, optional, default 2
  80011. * * tube the thickness of the tube, optional, default 0.5
  80012. * * radialSegments the number of sides on each tube segments, optional, default 32
  80013. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  80014. * * p the number of windings around the z axis, optional, default 2
  80015. * * q the number of windings around the x axis, optional, default 3
  80016. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  80017. * * 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)
  80018. * * 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)
  80019. * @returns the VertexData of the Torus Knot
  80020. */
  80021. static CreateTorusKnot(options: {
  80022. radius?: number;
  80023. tube?: number;
  80024. radialSegments?: number;
  80025. tubularSegments?: number;
  80026. p?: number;
  80027. q?: number;
  80028. sideOrientation?: number;
  80029. frontUVs?: Vector4;
  80030. backUVs?: Vector4;
  80031. }): VertexData;
  80032. /**
  80033. * Compute normals for given positions and indices
  80034. * @param positions an array of vertex positions, [...., x, y, z, ......]
  80035. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  80036. * @param normals an array of vertex normals, [...., x, y, z, ......]
  80037. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  80038. * * facetNormals : optional array of facet normals (vector3)
  80039. * * facetPositions : optional array of facet positions (vector3)
  80040. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  80041. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  80042. * * bInfo : optional bounding info, required for facetPartitioning computation
  80043. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  80044. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  80045. * * useRightHandedSystem: optional boolean to for right handed system computation
  80046. * * depthSort : optional boolean to enable the facet depth sort computation
  80047. * * distanceTo : optional Vector3 to compute the facet depth from this location
  80048. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  80049. */
  80050. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  80051. facetNormals?: any;
  80052. facetPositions?: any;
  80053. facetPartitioning?: any;
  80054. ratio?: number;
  80055. bInfo?: any;
  80056. bbSize?: Vector3;
  80057. subDiv?: any;
  80058. useRightHandedSystem?: boolean;
  80059. depthSort?: boolean;
  80060. distanceTo?: Vector3;
  80061. depthSortedFacets?: any;
  80062. }): void;
  80063. /** @hidden */
  80064. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  80065. /**
  80066. * Applies VertexData created from the imported parameters to the geometry
  80067. * @param parsedVertexData the parsed data from an imported file
  80068. * @param geometry the geometry to apply the VertexData to
  80069. */
  80070. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  80071. }
  80072. }
  80073. declare module BABYLON {
  80074. /**
  80075. * Class containing static functions to help procedurally build meshes
  80076. */
  80077. export class DiscBuilder {
  80078. /**
  80079. * Creates a plane polygonal mesh. By default, this is a disc
  80080. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  80081. * * 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
  80082. * * 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
  80083. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  80084. * * If you create a double-sided mesh, you can choose what parts of 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
  80085. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  80086. * @param name defines the name of the mesh
  80087. * @param options defines the options used to create the mesh
  80088. * @param scene defines the hosting scene
  80089. * @returns the plane polygonal mesh
  80090. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  80091. */
  80092. static CreateDisc(name: string, options: {
  80093. radius?: number;
  80094. tessellation?: number;
  80095. arc?: number;
  80096. updatable?: boolean;
  80097. sideOrientation?: number;
  80098. frontUVs?: Vector4;
  80099. backUVs?: Vector4;
  80100. }, scene?: Nullable<Scene>): Mesh;
  80101. }
  80102. }
  80103. declare module BABYLON {
  80104. /**
  80105. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  80106. *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.
  80107. * The SPS is also a particle system. It provides some methods to manage the particles.
  80108. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  80109. *
  80110. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  80111. */
  80112. export class SolidParticleSystem implements IDisposable {
  80113. /**
  80114. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  80115. * Example : var p = SPS.particles[i];
  80116. */
  80117. particles: SolidParticle[];
  80118. /**
  80119. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  80120. */
  80121. nbParticles: number;
  80122. /**
  80123. * If the particles must ever face the camera (default false). Useful for planar particles.
  80124. */
  80125. billboard: boolean;
  80126. /**
  80127. * Recompute normals when adding a shape
  80128. */
  80129. recomputeNormals: boolean;
  80130. /**
  80131. * This a counter ofr your own usage. It's not set by any SPS functions.
  80132. */
  80133. counter: number;
  80134. /**
  80135. * The SPS name. This name is also given to the underlying mesh.
  80136. */
  80137. name: string;
  80138. /**
  80139. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  80140. */
  80141. mesh: Mesh;
  80142. /**
  80143. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  80144. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  80145. */
  80146. vars: any;
  80147. /**
  80148. * This array is populated when the SPS is set as 'pickable'.
  80149. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  80150. * Each element of this array is an object `{idx: int, faceId: int}`.
  80151. * `idx` is the picked particle index in the `SPS.particles` array
  80152. * `faceId` is the picked face index counted within this particle.
  80153. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  80154. */
  80155. pickedParticles: {
  80156. idx: number;
  80157. faceId: number;
  80158. }[];
  80159. /**
  80160. * This array is populated when `enableDepthSort` is set to true.
  80161. * Each element of this array is an instance of the class DepthSortedParticle.
  80162. */
  80163. depthSortedParticles: DepthSortedParticle[];
  80164. /**
  80165. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  80166. * @hidden
  80167. */
  80168. _bSphereOnly: boolean;
  80169. /**
  80170. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  80171. * @hidden
  80172. */
  80173. _bSphereRadiusFactor: number;
  80174. private _scene;
  80175. private _positions;
  80176. private _indices;
  80177. private _normals;
  80178. private _colors;
  80179. private _uvs;
  80180. private _indices32;
  80181. private _positions32;
  80182. private _normals32;
  80183. private _fixedNormal32;
  80184. private _colors32;
  80185. private _uvs32;
  80186. private _index;
  80187. private _updatable;
  80188. private _pickable;
  80189. private _isVisibilityBoxLocked;
  80190. private _alwaysVisible;
  80191. private _depthSort;
  80192. private _shapeCounter;
  80193. private _copy;
  80194. private _color;
  80195. private _computeParticleColor;
  80196. private _computeParticleTexture;
  80197. private _computeParticleRotation;
  80198. private _computeParticleVertex;
  80199. private _computeBoundingBox;
  80200. private _depthSortParticles;
  80201. private _camera;
  80202. private _mustUnrotateFixedNormals;
  80203. private _particlesIntersect;
  80204. private _needs32Bits;
  80205. /**
  80206. * Creates a SPS (Solid Particle System) object.
  80207. * @param name (String) is the SPS name, this will be the underlying mesh name.
  80208. * @param scene (Scene) is the scene in which the SPS is added.
  80209. * @param options defines the options of the sps e.g.
  80210. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  80211. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  80212. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  80213. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  80214. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  80215. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  80216. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  80217. */
  80218. constructor(name: string, scene: Scene, options?: {
  80219. updatable?: boolean;
  80220. isPickable?: boolean;
  80221. enableDepthSort?: boolean;
  80222. particleIntersection?: boolean;
  80223. boundingSphereOnly?: boolean;
  80224. bSphereRadiusFactor?: number;
  80225. });
  80226. /**
  80227. * Builds the SPS underlying mesh. Returns a standard Mesh.
  80228. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  80229. * @returns the created mesh
  80230. */
  80231. buildMesh(): Mesh;
  80232. /**
  80233. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  80234. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  80235. * Thus the particles generated from `digest()` have their property `position` set yet.
  80236. * @param mesh ( Mesh ) is the mesh to be digested
  80237. * @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
  80238. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  80239. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  80240. * @returns the current SPS
  80241. */
  80242. digest(mesh: Mesh, options?: {
  80243. facetNb?: number;
  80244. number?: number;
  80245. delta?: number;
  80246. }): SolidParticleSystem;
  80247. private _unrotateFixedNormals;
  80248. private _resetCopy;
  80249. private _meshBuilder;
  80250. private _posToShape;
  80251. private _uvsToShapeUV;
  80252. private _addParticle;
  80253. /**
  80254. * Adds some particles to the SPS from the model shape. Returns the shape id.
  80255. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  80256. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  80257. * @param nb (positive integer) the number of particles to be created from this model
  80258. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  80259. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  80260. * @returns the number of shapes in the system
  80261. */
  80262. addShape(mesh: Mesh, nb: number, options?: {
  80263. positionFunction?: any;
  80264. vertexFunction?: any;
  80265. }): number;
  80266. private _rebuildParticle;
  80267. /**
  80268. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  80269. * @returns the SPS.
  80270. */
  80271. rebuildMesh(): SolidParticleSystem;
  80272. /**
  80273. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  80274. * This method calls `updateParticle()` for each particle of the SPS.
  80275. * For an animated SPS, it is usually called within the render loop.
  80276. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  80277. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  80278. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  80279. * @returns the SPS.
  80280. */
  80281. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  80282. /**
  80283. * Disposes the SPS.
  80284. */
  80285. dispose(): void;
  80286. /**
  80287. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  80288. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  80289. * @returns the SPS.
  80290. */
  80291. refreshVisibleSize(): SolidParticleSystem;
  80292. /**
  80293. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  80294. * @param size the size (float) of the visibility box
  80295. * note : this doesn't lock the SPS mesh bounding box.
  80296. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  80297. */
  80298. setVisibilityBox(size: number): void;
  80299. /**
  80300. * Gets whether the SPS as always visible or not
  80301. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  80302. */
  80303. /**
  80304. * Sets the SPS as always visible or not
  80305. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  80306. */
  80307. isAlwaysVisible: boolean;
  80308. /**
  80309. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  80310. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  80311. */
  80312. /**
  80313. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  80314. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  80315. */
  80316. isVisibilityBoxLocked: boolean;
  80317. /**
  80318. * Tells to `setParticles()` to compute the particle rotations or not.
  80319. * Default value : true. The SPS is faster when it's set to false.
  80320. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  80321. */
  80322. /**
  80323. * Gets if `setParticles()` computes the particle rotations or not.
  80324. * Default value : true. The SPS is faster when it's set to false.
  80325. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  80326. */
  80327. computeParticleRotation: boolean;
  80328. /**
  80329. * Tells to `setParticles()` to compute the particle colors or not.
  80330. * Default value : true. The SPS is faster when it's set to false.
  80331. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  80332. */
  80333. /**
  80334. * Gets if `setParticles()` computes the particle colors or not.
  80335. * Default value : true. The SPS is faster when it's set to false.
  80336. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  80337. */
  80338. computeParticleColor: boolean;
  80339. /**
  80340. * Gets if `setParticles()` computes the particle textures or not.
  80341. * Default value : true. The SPS is faster when it's set to false.
  80342. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  80343. */
  80344. computeParticleTexture: boolean;
  80345. /**
  80346. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  80347. * Default value : false. The SPS is faster when it's set to false.
  80348. * Note : the particle custom vertex positions aren't stored values.
  80349. */
  80350. /**
  80351. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  80352. * Default value : false. The SPS is faster when it's set to false.
  80353. * Note : the particle custom vertex positions aren't stored values.
  80354. */
  80355. computeParticleVertex: boolean;
  80356. /**
  80357. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  80358. */
  80359. /**
  80360. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  80361. */
  80362. computeBoundingBox: boolean;
  80363. /**
  80364. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  80365. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  80366. * Default : `true`
  80367. */
  80368. /**
  80369. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  80370. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  80371. * Default : `true`
  80372. */
  80373. depthSortParticles: boolean;
  80374. /**
  80375. * This function does nothing. It may be overwritten to set all the particle first values.
  80376. * The SPS doesn't call this function, you may have to call it by your own.
  80377. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  80378. */
  80379. initParticles(): void;
  80380. /**
  80381. * This function does nothing. It may be overwritten to recycle a particle.
  80382. * The SPS doesn't call this function, you may have to call it by your own.
  80383. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  80384. * @param particle The particle to recycle
  80385. * @returns the recycled particle
  80386. */
  80387. recycleParticle(particle: SolidParticle): SolidParticle;
  80388. /**
  80389. * Updates a particle : this function should be overwritten by the user.
  80390. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  80391. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  80392. * @example : just set a particle position or velocity and recycle conditions
  80393. * @param particle The particle to update
  80394. * @returns the updated particle
  80395. */
  80396. updateParticle(particle: SolidParticle): SolidParticle;
  80397. /**
  80398. * Updates a vertex of a particle : it can be overwritten by the user.
  80399. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  80400. * @param particle the current particle
  80401. * @param vertex the current index of the current particle
  80402. * @param pt the index of the current vertex in the particle shape
  80403. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  80404. * @example : just set a vertex particle position
  80405. * @returns the updated vertex
  80406. */
  80407. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  80408. /**
  80409. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  80410. * This does nothing and may be overwritten by the user.
  80411. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  80412. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  80413. * @param update the boolean update value actually passed to setParticles()
  80414. */
  80415. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  80416. /**
  80417. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  80418. * This will be passed three parameters.
  80419. * This does nothing and may be overwritten by the user.
  80420. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  80421. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  80422. * @param update the boolean update value actually passed to setParticles()
  80423. */
  80424. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  80425. }
  80426. }
  80427. declare module BABYLON {
  80428. /**
  80429. * Represents one particle of a solid particle system.
  80430. */
  80431. export class SolidParticle {
  80432. /**
  80433. * particle global index
  80434. */
  80435. idx: number;
  80436. /**
  80437. * The color of the particle
  80438. */
  80439. color: Nullable<Color4>;
  80440. /**
  80441. * The world space position of the particle.
  80442. */
  80443. position: Vector3;
  80444. /**
  80445. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  80446. */
  80447. rotation: Vector3;
  80448. /**
  80449. * The world space rotation quaternion of the particle.
  80450. */
  80451. rotationQuaternion: Nullable<Quaternion>;
  80452. /**
  80453. * The scaling of the particle.
  80454. */
  80455. scaling: Vector3;
  80456. /**
  80457. * The uvs of the particle.
  80458. */
  80459. uvs: Vector4;
  80460. /**
  80461. * The current speed of the particle.
  80462. */
  80463. velocity: Vector3;
  80464. /**
  80465. * The pivot point in the particle local space.
  80466. */
  80467. pivot: Vector3;
  80468. /**
  80469. * Must the particle be translated from its pivot point in its local space ?
  80470. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  80471. * Default : false
  80472. */
  80473. translateFromPivot: boolean;
  80474. /**
  80475. * Is the particle active or not ?
  80476. */
  80477. alive: boolean;
  80478. /**
  80479. * Is the particle visible or not ?
  80480. */
  80481. isVisible: boolean;
  80482. /**
  80483. * Index of this particle in the global "positions" array (Internal use)
  80484. * @hidden
  80485. */
  80486. _pos: number;
  80487. /**
  80488. * @hidden Index of this particle in the global "indices" array (Internal use)
  80489. */
  80490. _ind: number;
  80491. /**
  80492. * @hidden ModelShape of this particle (Internal use)
  80493. */
  80494. _model: ModelShape;
  80495. /**
  80496. * ModelShape id of this particle
  80497. */
  80498. shapeId: number;
  80499. /**
  80500. * Index of the particle in its shape id (Internal use)
  80501. */
  80502. idxInShape: number;
  80503. /**
  80504. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  80505. */
  80506. _modelBoundingInfo: BoundingInfo;
  80507. /**
  80508. * @hidden Particle BoundingInfo object (Internal use)
  80509. */
  80510. _boundingInfo: BoundingInfo;
  80511. /**
  80512. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  80513. */
  80514. _sps: SolidParticleSystem;
  80515. /**
  80516. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  80517. */
  80518. _stillInvisible: boolean;
  80519. /**
  80520. * @hidden Last computed particle rotation matrix
  80521. */
  80522. _rotationMatrix: number[];
  80523. /**
  80524. * Parent particle Id, if any.
  80525. * Default null.
  80526. */
  80527. parentId: Nullable<number>;
  80528. /**
  80529. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  80530. * The possible values are :
  80531. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  80532. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  80533. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  80534. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  80535. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  80536. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  80537. * */
  80538. cullingStrategy: number;
  80539. /**
  80540. * @hidden Internal global position in the SPS.
  80541. */
  80542. _globalPosition: Vector3;
  80543. /**
  80544. * Creates a Solid Particle object.
  80545. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  80546. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  80547. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  80548. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  80549. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  80550. * @param shapeId (integer) is the model shape identifier in the SPS.
  80551. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  80552. * @param sps defines the sps it is associated to
  80553. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  80554. */
  80555. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  80556. /**
  80557. * Legacy support, changed scale to scaling
  80558. */
  80559. /**
  80560. * Legacy support, changed scale to scaling
  80561. */
  80562. scale: Vector3;
  80563. /**
  80564. * Legacy support, changed quaternion to rotationQuaternion
  80565. */
  80566. /**
  80567. * Legacy support, changed quaternion to rotationQuaternion
  80568. */
  80569. quaternion: Nullable<Quaternion>;
  80570. /**
  80571. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  80572. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  80573. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  80574. * @returns true if it intersects
  80575. */
  80576. intersectsMesh(target: Mesh | SolidParticle): boolean;
  80577. /**
  80578. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  80579. * A particle is in the frustum if its bounding box intersects the frustum
  80580. * @param frustumPlanes defines the frustum to test
  80581. * @returns true if the particle is in the frustum planes
  80582. */
  80583. isInFrustum(frustumPlanes: Plane[]): boolean;
  80584. /**
  80585. * get the rotation matrix of the particle
  80586. * @hidden
  80587. */
  80588. getRotationMatrix(m: Matrix): void;
  80589. }
  80590. /**
  80591. * Represents the shape of the model used by one particle of a solid particle system.
  80592. * SPS internal tool, don't use it manually.
  80593. */
  80594. export class ModelShape {
  80595. /**
  80596. * The shape id
  80597. * @hidden
  80598. */
  80599. shapeID: number;
  80600. /**
  80601. * flat array of model positions (internal use)
  80602. * @hidden
  80603. */
  80604. _shape: Vector3[];
  80605. /**
  80606. * flat array of model UVs (internal use)
  80607. * @hidden
  80608. */
  80609. _shapeUV: number[];
  80610. /**
  80611. * length of the shape in the model indices array (internal use)
  80612. * @hidden
  80613. */
  80614. _indicesLength: number;
  80615. /**
  80616. * Custom position function (internal use)
  80617. * @hidden
  80618. */
  80619. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  80620. /**
  80621. * Custom vertex function (internal use)
  80622. * @hidden
  80623. */
  80624. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  80625. /**
  80626. * 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.
  80627. * SPS internal tool, don't use it manually.
  80628. * @hidden
  80629. */
  80630. 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>);
  80631. }
  80632. /**
  80633. * Represents a Depth Sorted Particle in the solid particle system.
  80634. */
  80635. export class DepthSortedParticle {
  80636. /**
  80637. * Index of the particle in the "indices" array
  80638. */
  80639. ind: number;
  80640. /**
  80641. * Length of the particle shape in the "indices" array
  80642. */
  80643. indicesLength: number;
  80644. /**
  80645. * Squared distance from the particle to the camera
  80646. */
  80647. sqDistance: number;
  80648. }
  80649. }
  80650. declare module BABYLON {
  80651. /**
  80652. * Class used to store all common mesh properties
  80653. */
  80654. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  80655. /** No occlusion */
  80656. static OCCLUSION_TYPE_NONE: number;
  80657. /** Occlusion set to optimisitic */
  80658. static OCCLUSION_TYPE_OPTIMISTIC: number;
  80659. /** Occlusion set to strict */
  80660. static OCCLUSION_TYPE_STRICT: number;
  80661. /** Use an accurante occlusion algorithm */
  80662. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  80663. /** Use a conservative occlusion algorithm */
  80664. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  80665. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  80666. * Test order :
  80667. * Is the bounding sphere outside the frustum ?
  80668. * If not, are the bounding box vertices outside the frustum ?
  80669. * It not, then the cullable object is in the frustum.
  80670. */
  80671. static readonly CULLINGSTRATEGY_STANDARD: number;
  80672. /** Culling strategy : Bounding Sphere Only.
  80673. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  80674. * It's also less accurate than the standard because some not visible objects can still be selected.
  80675. * Test : is the bounding sphere outside the frustum ?
  80676. * If not, then the cullable object is in the frustum.
  80677. */
  80678. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  80679. /** Culling strategy : Optimistic Inclusion.
  80680. * This in an inclusion test first, then the standard exclusion test.
  80681. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  80682. * 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.
  80683. * Anyway, it's as accurate as the standard strategy.
  80684. * Test :
  80685. * Is the cullable object bounding sphere center in the frustum ?
  80686. * If not, apply the default culling strategy.
  80687. */
  80688. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  80689. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  80690. * This in an inclusion test first, then the bounding sphere only exclusion test.
  80691. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  80692. * 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.
  80693. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  80694. * Test :
  80695. * Is the cullable object bounding sphere center in the frustum ?
  80696. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  80697. */
  80698. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  80699. /**
  80700. * No billboard
  80701. */
  80702. static readonly BILLBOARDMODE_NONE: number;
  80703. /** Billboard on X axis */
  80704. static readonly BILLBOARDMODE_X: number;
  80705. /** Billboard on Y axis */
  80706. static readonly BILLBOARDMODE_Y: number;
  80707. /** Billboard on Z axis */
  80708. static readonly BILLBOARDMODE_Z: number;
  80709. /** Billboard on all axes */
  80710. static readonly BILLBOARDMODE_ALL: number;
  80711. private _facetData;
  80712. /**
  80713. * The culling strategy to use to check whether the mesh must be rendered or not.
  80714. * This value can be changed at any time and will be used on the next render mesh selection.
  80715. * The possible values are :
  80716. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  80717. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  80718. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  80719. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  80720. * Please read each static variable documentation to get details about the culling process.
  80721. * */
  80722. cullingStrategy: number;
  80723. /**
  80724. * Gets the number of facets in the mesh
  80725. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  80726. */
  80727. readonly facetNb: number;
  80728. /**
  80729. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  80730. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  80731. */
  80732. partitioningSubdivisions: number;
  80733. /**
  80734. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  80735. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  80736. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  80737. */
  80738. partitioningBBoxRatio: number;
  80739. /**
  80740. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  80741. * Works only for updatable meshes.
  80742. * Doesn't work with multi-materials
  80743. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  80744. */
  80745. mustDepthSortFacets: boolean;
  80746. /**
  80747. * The location (Vector3) where the facet depth sort must be computed from.
  80748. * By default, the active camera position.
  80749. * Used only when facet depth sort is enabled
  80750. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  80751. */
  80752. facetDepthSortFrom: Vector3;
  80753. /**
  80754. * gets a boolean indicating if facetData is enabled
  80755. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  80756. */
  80757. readonly isFacetDataEnabled: boolean;
  80758. /** @hidden */
  80759. _updateNonUniformScalingState(value: boolean): boolean;
  80760. /**
  80761. * An event triggered when this mesh collides with another one
  80762. */
  80763. onCollideObservable: Observable<AbstractMesh>;
  80764. private _onCollideObserver;
  80765. /** Set a function to call when this mesh collides with another one */
  80766. onCollide: () => void;
  80767. /**
  80768. * An event triggered when the collision's position changes
  80769. */
  80770. onCollisionPositionChangeObservable: Observable<Vector3>;
  80771. private _onCollisionPositionChangeObserver;
  80772. /** Set a function to call when the collision's position changes */
  80773. onCollisionPositionChange: () => void;
  80774. /**
  80775. * An event triggered when material is changed
  80776. */
  80777. onMaterialChangedObservable: Observable<AbstractMesh>;
  80778. /**
  80779. * Gets or sets the orientation for POV movement & rotation
  80780. */
  80781. definedFacingForward: boolean;
  80782. /** @hidden */
  80783. _occlusionQuery: Nullable<WebGLQuery>;
  80784. private _visibility;
  80785. /**
  80786. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  80787. */
  80788. /**
  80789. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  80790. */
  80791. visibility: number;
  80792. /** Gets or sets the alpha index used to sort transparent meshes
  80793. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  80794. */
  80795. alphaIndex: number;
  80796. /**
  80797. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  80798. */
  80799. isVisible: boolean;
  80800. /**
  80801. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  80802. */
  80803. isPickable: boolean;
  80804. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  80805. showSubMeshesBoundingBox: boolean;
  80806. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  80807. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  80808. */
  80809. isBlocker: boolean;
  80810. /**
  80811. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  80812. */
  80813. enablePointerMoveEvents: boolean;
  80814. /**
  80815. * Specifies the rendering group id for this mesh (0 by default)
  80816. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  80817. */
  80818. renderingGroupId: number;
  80819. private _material;
  80820. /** Gets or sets current material */
  80821. material: Nullable<Material>;
  80822. private _receiveShadows;
  80823. /**
  80824. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  80825. * @see http://doc.babylonjs.com/babylon101/shadows
  80826. */
  80827. receiveShadows: boolean;
  80828. /** Defines color to use when rendering outline */
  80829. outlineColor: Color3;
  80830. /** Define width to use when rendering outline */
  80831. outlineWidth: number;
  80832. /** Defines color to use when rendering overlay */
  80833. overlayColor: Color3;
  80834. /** Defines alpha to use when rendering overlay */
  80835. overlayAlpha: number;
  80836. private _hasVertexAlpha;
  80837. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  80838. hasVertexAlpha: boolean;
  80839. private _useVertexColors;
  80840. /** 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) */
  80841. useVertexColors: boolean;
  80842. private _computeBonesUsingShaders;
  80843. /**
  80844. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  80845. */
  80846. computeBonesUsingShaders: boolean;
  80847. private _numBoneInfluencers;
  80848. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  80849. numBoneInfluencers: number;
  80850. private _applyFog;
  80851. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  80852. applyFog: boolean;
  80853. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  80854. useOctreeForRenderingSelection: boolean;
  80855. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  80856. useOctreeForPicking: boolean;
  80857. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  80858. useOctreeForCollisions: boolean;
  80859. private _layerMask;
  80860. /**
  80861. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  80862. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  80863. */
  80864. layerMask: number;
  80865. /**
  80866. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  80867. */
  80868. alwaysSelectAsActiveMesh: boolean;
  80869. /**
  80870. * Gets or sets the current action manager
  80871. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  80872. */
  80873. actionManager: Nullable<AbstractActionManager>;
  80874. private _checkCollisions;
  80875. private _collisionMask;
  80876. private _collisionGroup;
  80877. /**
  80878. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  80879. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  80880. */
  80881. ellipsoid: Vector3;
  80882. /**
  80883. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  80884. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  80885. */
  80886. ellipsoidOffset: Vector3;
  80887. private _collider;
  80888. private _oldPositionForCollisions;
  80889. private _diffPositionForCollisions;
  80890. /**
  80891. * Gets or sets a collision mask used to mask collisions (default is -1).
  80892. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  80893. */
  80894. collisionMask: number;
  80895. /**
  80896. * Gets or sets the current collision group mask (-1 by default).
  80897. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  80898. */
  80899. collisionGroup: number;
  80900. /**
  80901. * Defines edge width used when edgesRenderer is enabled
  80902. * @see https://www.babylonjs-playground.com/#10OJSG#13
  80903. */
  80904. edgesWidth: number;
  80905. /**
  80906. * Defines edge color used when edgesRenderer is enabled
  80907. * @see https://www.babylonjs-playground.com/#10OJSG#13
  80908. */
  80909. edgesColor: Color4;
  80910. /** @hidden */
  80911. _edgesRenderer: Nullable<IEdgesRenderer>;
  80912. /** @hidden */
  80913. _masterMesh: Nullable<AbstractMesh>;
  80914. /** @hidden */
  80915. _boundingInfo: Nullable<BoundingInfo>;
  80916. /** @hidden */
  80917. _renderId: number;
  80918. /**
  80919. * Gets or sets the list of subMeshes
  80920. * @see http://doc.babylonjs.com/how_to/multi_materials
  80921. */
  80922. subMeshes: SubMesh[];
  80923. /** @hidden */
  80924. _intersectionsInProgress: AbstractMesh[];
  80925. /** @hidden */
  80926. _unIndexed: boolean;
  80927. /** @hidden */
  80928. _lightSources: Light[];
  80929. /** @hidden */
  80930. readonly _positions: Nullable<Vector3[]>;
  80931. /** @hidden */
  80932. _waitingActions: any;
  80933. /** @hidden */
  80934. _waitingFreezeWorldMatrix: Nullable<boolean>;
  80935. private _skeleton;
  80936. /** @hidden */
  80937. _bonesTransformMatrices: Nullable<Float32Array>;
  80938. /**
  80939. * Gets or sets a skeleton to apply skining transformations
  80940. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  80941. */
  80942. skeleton: Nullable<Skeleton>;
  80943. /**
  80944. * An event triggered when the mesh is rebuilt.
  80945. */
  80946. onRebuildObservable: Observable<AbstractMesh>;
  80947. /**
  80948. * Creates a new AbstractMesh
  80949. * @param name defines the name of the mesh
  80950. * @param scene defines the hosting scene
  80951. */
  80952. constructor(name: string, scene?: Nullable<Scene>);
  80953. /**
  80954. * Returns the string "AbstractMesh"
  80955. * @returns "AbstractMesh"
  80956. */
  80957. getClassName(): string;
  80958. /**
  80959. * Gets a string representation of the current mesh
  80960. * @param fullDetails defines a boolean indicating if full details must be included
  80961. * @returns a string representation of the current mesh
  80962. */
  80963. toString(fullDetails?: boolean): string;
  80964. /** @hidden */
  80965. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  80966. /** @hidden */
  80967. _rebuild(): void;
  80968. /** @hidden */
  80969. _resyncLightSources(): void;
  80970. /** @hidden */
  80971. _resyncLighSource(light: Light): void;
  80972. /** @hidden */
  80973. _unBindEffect(): void;
  80974. /** @hidden */
  80975. _removeLightSource(light: Light): void;
  80976. private _markSubMeshesAsDirty;
  80977. /** @hidden */
  80978. _markSubMeshesAsLightDirty(): void;
  80979. /** @hidden */
  80980. _markSubMeshesAsAttributesDirty(): void;
  80981. /** @hidden */
  80982. _markSubMeshesAsMiscDirty(): void;
  80983. /**
  80984. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  80985. */
  80986. scaling: Vector3;
  80987. /**
  80988. * Returns true if the mesh is blocked. Implemented by child classes
  80989. */
  80990. readonly isBlocked: boolean;
  80991. /**
  80992. * Returns the mesh itself by default. Implemented by child classes
  80993. * @param camera defines the camera to use to pick the right LOD level
  80994. * @returns the currentAbstractMesh
  80995. */
  80996. getLOD(camera: Camera): Nullable<AbstractMesh>;
  80997. /**
  80998. * Returns 0 by default. Implemented by child classes
  80999. * @returns an integer
  81000. */
  81001. getTotalVertices(): number;
  81002. /**
  81003. * Returns a positive integer : the total number of indices in this mesh geometry.
  81004. * @returns the numner of indices or zero if the mesh has no geometry.
  81005. */
  81006. getTotalIndices(): number;
  81007. /**
  81008. * Returns null by default. Implemented by child classes
  81009. * @returns null
  81010. */
  81011. getIndices(): Nullable<IndicesArray>;
  81012. /**
  81013. * Returns the array of the requested vertex data kind. Implemented by child classes
  81014. * @param kind defines the vertex data kind to use
  81015. * @returns null
  81016. */
  81017. getVerticesData(kind: string): Nullable<FloatArray>;
  81018. /**
  81019. * Sets the vertex data of the mesh geometry for the requested `kind`.
  81020. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  81021. * Note that a new underlying VertexBuffer object is created each call.
  81022. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  81023. * @param kind defines vertex data kind:
  81024. * * VertexBuffer.PositionKind
  81025. * * VertexBuffer.UVKind
  81026. * * VertexBuffer.UV2Kind
  81027. * * VertexBuffer.UV3Kind
  81028. * * VertexBuffer.UV4Kind
  81029. * * VertexBuffer.UV5Kind
  81030. * * VertexBuffer.UV6Kind
  81031. * * VertexBuffer.ColorKind
  81032. * * VertexBuffer.MatricesIndicesKind
  81033. * * VertexBuffer.MatricesIndicesExtraKind
  81034. * * VertexBuffer.MatricesWeightsKind
  81035. * * VertexBuffer.MatricesWeightsExtraKind
  81036. * @param data defines the data source
  81037. * @param updatable defines if the data must be flagged as updatable (or static)
  81038. * @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
  81039. * @returns the current mesh
  81040. */
  81041. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  81042. /**
  81043. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  81044. * If the mesh has no geometry, it is simply returned as it is.
  81045. * @param kind defines vertex data kind:
  81046. * * VertexBuffer.PositionKind
  81047. * * VertexBuffer.UVKind
  81048. * * VertexBuffer.UV2Kind
  81049. * * VertexBuffer.UV3Kind
  81050. * * VertexBuffer.UV4Kind
  81051. * * VertexBuffer.UV5Kind
  81052. * * VertexBuffer.UV6Kind
  81053. * * VertexBuffer.ColorKind
  81054. * * VertexBuffer.MatricesIndicesKind
  81055. * * VertexBuffer.MatricesIndicesExtraKind
  81056. * * VertexBuffer.MatricesWeightsKind
  81057. * * VertexBuffer.MatricesWeightsExtraKind
  81058. * @param data defines the data source
  81059. * @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
  81060. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  81061. * @returns the current mesh
  81062. */
  81063. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  81064. /**
  81065. * Sets the mesh indices,
  81066. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  81067. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  81068. * @param totalVertices Defines the total number of vertices
  81069. * @returns the current mesh
  81070. */
  81071. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  81072. /**
  81073. * Gets a boolean indicating if specific vertex data is present
  81074. * @param kind defines the vertex data kind to use
  81075. * @returns true is data kind is present
  81076. */
  81077. isVerticesDataPresent(kind: string): boolean;
  81078. /**
  81079. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  81080. * @returns a BoundingInfo
  81081. */
  81082. getBoundingInfo(): BoundingInfo;
  81083. /**
  81084. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  81085. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box
  81086. * @returns the current mesh
  81087. */
  81088. normalizeToUnitCube(includeDescendants?: boolean): AbstractMesh;
  81089. /**
  81090. * Overwrite the current bounding info
  81091. * @param boundingInfo defines the new bounding info
  81092. * @returns the current mesh
  81093. */
  81094. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  81095. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  81096. readonly useBones: boolean;
  81097. /** @hidden */
  81098. _preActivate(): void;
  81099. /** @hidden */
  81100. _preActivateForIntermediateRendering(renderId: number): void;
  81101. /** @hidden */
  81102. _activate(renderId: number): void;
  81103. /**
  81104. * Gets the current world matrix
  81105. * @returns a Matrix
  81106. */
  81107. getWorldMatrix(): Matrix;
  81108. /** @hidden */
  81109. _getWorldMatrixDeterminant(): number;
  81110. /**
  81111. * Perform relative position change from the point of view of behind the front of the mesh.
  81112. * This is performed taking into account the meshes current rotation, so you do not have to care.
  81113. * Supports definition of mesh facing forward or backward
  81114. * @param amountRight defines the distance on the right axis
  81115. * @param amountUp defines the distance on the up axis
  81116. * @param amountForward defines the distance on the forward axis
  81117. * @returns the current mesh
  81118. */
  81119. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  81120. /**
  81121. * Calculate relative position change from the point of view of behind the front of the mesh.
  81122. * This is performed taking into account the meshes current rotation, so you do not have to care.
  81123. * Supports definition of mesh facing forward or backward
  81124. * @param amountRight defines the distance on the right axis
  81125. * @param amountUp defines the distance on the up axis
  81126. * @param amountForward defines the distance on the forward axis
  81127. * @returns the new displacement vector
  81128. */
  81129. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  81130. /**
  81131. * Perform relative rotation change from the point of view of behind the front of the mesh.
  81132. * Supports definition of mesh facing forward or backward
  81133. * @param flipBack defines the flip
  81134. * @param twirlClockwise defines the twirl
  81135. * @param tiltRight defines the tilt
  81136. * @returns the current mesh
  81137. */
  81138. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  81139. /**
  81140. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  81141. * Supports definition of mesh facing forward or backward.
  81142. * @param flipBack defines the flip
  81143. * @param twirlClockwise defines the twirl
  81144. * @param tiltRight defines the tilt
  81145. * @returns the new rotation vector
  81146. */
  81147. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  81148. /**
  81149. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  81150. * @param includeDescendants Include bounding info from descendants as well (true by default)
  81151. * @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
  81152. * @returns the new bounding vectors
  81153. */
  81154. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  81155. min: Vector3;
  81156. max: Vector3;
  81157. };
  81158. /**
  81159. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  81160. * This means the mesh underlying bounding box and sphere are recomputed.
  81161. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  81162. * @returns the current mesh
  81163. */
  81164. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  81165. /** @hidden */
  81166. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  81167. /** @hidden */
  81168. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  81169. /** @hidden */
  81170. _updateBoundingInfo(): AbstractMesh;
  81171. /** @hidden */
  81172. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  81173. /** @hidden */
  81174. protected _afterComputeWorldMatrix(): void;
  81175. /**
  81176. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  81177. * A mesh is in the frustum if its bounding box intersects the frustum
  81178. * @param frustumPlanes defines the frustum to test
  81179. * @returns true if the mesh is in the frustum planes
  81180. */
  81181. isInFrustum(frustumPlanes: Plane[]): boolean;
  81182. /**
  81183. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  81184. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  81185. * @param frustumPlanes defines the frustum to test
  81186. * @returns true if the mesh is completely in the frustum planes
  81187. */
  81188. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  81189. /**
  81190. * True if the mesh intersects another mesh or a SolidParticle object
  81191. * @param mesh defines a target mesh or SolidParticle to test
  81192. * @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)
  81193. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  81194. * @returns true if there is an intersection
  81195. */
  81196. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  81197. /**
  81198. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  81199. * @param point defines the point to test
  81200. * @returns true if there is an intersection
  81201. */
  81202. intersectsPoint(point: Vector3): boolean;
  81203. /**
  81204. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  81205. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  81206. */
  81207. checkCollisions: boolean;
  81208. /**
  81209. * Gets Collider object used to compute collisions (not physics)
  81210. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  81211. */
  81212. readonly collider: Collider;
  81213. /**
  81214. * Move the mesh using collision engine
  81215. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  81216. * @param displacement defines the requested displacement vector
  81217. * @returns the current mesh
  81218. */
  81219. moveWithCollisions(displacement: Vector3): AbstractMesh;
  81220. private _onCollisionPositionChange;
  81221. /** @hidden */
  81222. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  81223. /** @hidden */
  81224. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  81225. /** @hidden */
  81226. _checkCollision(collider: Collider): AbstractMesh;
  81227. /** @hidden */
  81228. _generatePointsArray(): boolean;
  81229. /**
  81230. * Checks if the passed Ray intersects with the mesh
  81231. * @param ray defines the ray to use
  81232. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  81233. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  81234. * @returns the picking info
  81235. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  81236. */
  81237. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  81238. /**
  81239. * Clones the current mesh
  81240. * @param name defines the mesh name
  81241. * @param newParent defines the new mesh parent
  81242. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  81243. * @returns the new mesh
  81244. */
  81245. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  81246. /**
  81247. * Disposes all the submeshes of the current meshnp
  81248. * @returns the current mesh
  81249. */
  81250. releaseSubMeshes(): AbstractMesh;
  81251. /**
  81252. * Releases resources associated with this abstract mesh.
  81253. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  81254. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  81255. */
  81256. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  81257. /**
  81258. * Adds the passed mesh as a child to the current mesh
  81259. * @param mesh defines the child mesh
  81260. * @returns the current mesh
  81261. */
  81262. addChild(mesh: AbstractMesh): AbstractMesh;
  81263. /**
  81264. * Removes the passed mesh from the current mesh children list
  81265. * @param mesh defines the child mesh
  81266. * @returns the current mesh
  81267. */
  81268. removeChild(mesh: AbstractMesh): AbstractMesh;
  81269. /** @hidden */
  81270. private _initFacetData;
  81271. /**
  81272. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  81273. * This method can be called within the render loop.
  81274. * 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
  81275. * @returns the current mesh
  81276. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81277. */
  81278. updateFacetData(): AbstractMesh;
  81279. /**
  81280. * Returns the facetLocalNormals array.
  81281. * The normals are expressed in the mesh local spac
  81282. * @returns an array of Vector3
  81283. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81284. */
  81285. getFacetLocalNormals(): Vector3[];
  81286. /**
  81287. * Returns the facetLocalPositions array.
  81288. * The facet positions are expressed in the mesh local space
  81289. * @returns an array of Vector3
  81290. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81291. */
  81292. getFacetLocalPositions(): Vector3[];
  81293. /**
  81294. * Returns the facetLocalPartioning array
  81295. * @returns an array of array of numbers
  81296. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81297. */
  81298. getFacetLocalPartitioning(): number[][];
  81299. /**
  81300. * Returns the i-th facet position in the world system.
  81301. * This method allocates a new Vector3 per call
  81302. * @param i defines the facet index
  81303. * @returns a new Vector3
  81304. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81305. */
  81306. getFacetPosition(i: number): Vector3;
  81307. /**
  81308. * Sets the reference Vector3 with the i-th facet position in the world system
  81309. * @param i defines the facet index
  81310. * @param ref defines the target vector
  81311. * @returns the current mesh
  81312. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81313. */
  81314. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  81315. /**
  81316. * Returns the i-th facet normal in the world system.
  81317. * This method allocates a new Vector3 per call
  81318. * @param i defines the facet index
  81319. * @returns a new Vector3
  81320. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81321. */
  81322. getFacetNormal(i: number): Vector3;
  81323. /**
  81324. * Sets the reference Vector3 with the i-th facet normal in the world system
  81325. * @param i defines the facet index
  81326. * @param ref defines the target vector
  81327. * @returns the current mesh
  81328. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81329. */
  81330. getFacetNormalToRef(i: number, ref: Vector3): this;
  81331. /**
  81332. * 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)
  81333. * @param x defines x coordinate
  81334. * @param y defines y coordinate
  81335. * @param z defines z coordinate
  81336. * @returns the array of facet indexes
  81337. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81338. */
  81339. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  81340. /**
  81341. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  81342. * @param projected sets as the (x,y,z) world projection on the facet
  81343. * @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
  81344. * @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
  81345. * @param x defines x coordinate
  81346. * @param y defines y coordinate
  81347. * @param z defines z coordinate
  81348. * @returns the face index if found (or null instead)
  81349. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81350. */
  81351. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  81352. /**
  81353. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  81354. * @param projected sets as the (x,y,z) local projection on the facet
  81355. * @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
  81356. * @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
  81357. * @param x defines x coordinate
  81358. * @param y defines y coordinate
  81359. * @param z defines z coordinate
  81360. * @returns the face index if found (or null instead)
  81361. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81362. */
  81363. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  81364. /**
  81365. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  81366. * @returns the parameters
  81367. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81368. */
  81369. getFacetDataParameters(): any;
  81370. /**
  81371. * Disables the feature FacetData and frees the related memory
  81372. * @returns the current mesh
  81373. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81374. */
  81375. disableFacetData(): AbstractMesh;
  81376. /**
  81377. * Updates the AbstractMesh indices array
  81378. * @param indices defines the data source
  81379. * @returns the current mesh
  81380. */
  81381. updateIndices(indices: IndicesArray): AbstractMesh;
  81382. /**
  81383. * Creates new normals data for the mesh
  81384. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  81385. * @returns the current mesh
  81386. */
  81387. createNormals(updatable: boolean): AbstractMesh;
  81388. /**
  81389. * Align the mesh with a normal
  81390. * @param normal defines the normal to use
  81391. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  81392. * @returns the current mesh
  81393. */
  81394. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  81395. /** @hidden */
  81396. _checkOcclusionQuery(): boolean;
  81397. }
  81398. }
  81399. declare module BABYLON {
  81400. /**
  81401. * Interface used to define ActionEvent
  81402. */
  81403. export interface IActionEvent {
  81404. /** The mesh or sprite that triggered the action */
  81405. source: any;
  81406. /** The X mouse cursor position at the time of the event */
  81407. pointerX: number;
  81408. /** The Y mouse cursor position at the time of the event */
  81409. pointerY: number;
  81410. /** The mesh that is currently pointed at (can be null) */
  81411. meshUnderPointer: Nullable<AbstractMesh>;
  81412. /** the original (browser) event that triggered the ActionEvent */
  81413. sourceEvent?: any;
  81414. /** additional data for the event */
  81415. additionalData?: any;
  81416. }
  81417. /**
  81418. * ActionEvent is the event being sent when an action is triggered.
  81419. */
  81420. export class ActionEvent implements IActionEvent {
  81421. /** The mesh or sprite that triggered the action */
  81422. source: any;
  81423. /** The X mouse cursor position at the time of the event */
  81424. pointerX: number;
  81425. /** The Y mouse cursor position at the time of the event */
  81426. pointerY: number;
  81427. /** The mesh that is currently pointed at (can be null) */
  81428. meshUnderPointer: Nullable<AbstractMesh>;
  81429. /** the original (browser) event that triggered the ActionEvent */
  81430. sourceEvent?: any;
  81431. /** additional data for the event */
  81432. additionalData?: any;
  81433. /**
  81434. * Creates a new ActionEvent
  81435. * @param source The mesh or sprite that triggered the action
  81436. * @param pointerX The X mouse cursor position at the time of the event
  81437. * @param pointerY The Y mouse cursor position at the time of the event
  81438. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  81439. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  81440. * @param additionalData additional data for the event
  81441. */
  81442. constructor(
  81443. /** The mesh or sprite that triggered the action */
  81444. source: any,
  81445. /** The X mouse cursor position at the time of the event */
  81446. pointerX: number,
  81447. /** The Y mouse cursor position at the time of the event */
  81448. pointerY: number,
  81449. /** The mesh that is currently pointed at (can be null) */
  81450. meshUnderPointer: Nullable<AbstractMesh>,
  81451. /** the original (browser) event that triggered the ActionEvent */
  81452. sourceEvent?: any,
  81453. /** additional data for the event */
  81454. additionalData?: any);
  81455. /**
  81456. * Helper function to auto-create an ActionEvent from a source mesh.
  81457. * @param source The source mesh that triggered the event
  81458. * @param evt The original (browser) event
  81459. * @param additionalData additional data for the event
  81460. * @returns the new ActionEvent
  81461. */
  81462. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  81463. /**
  81464. * Helper function to auto-create an ActionEvent from a source sprite
  81465. * @param source The source sprite that triggered the event
  81466. * @param scene Scene associated with the sprite
  81467. * @param evt The original (browser) event
  81468. * @param additionalData additional data for the event
  81469. * @returns the new ActionEvent
  81470. */
  81471. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  81472. /**
  81473. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  81474. * @param scene the scene where the event occurred
  81475. * @param evt The original (browser) event
  81476. * @returns the new ActionEvent
  81477. */
  81478. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  81479. /**
  81480. * Helper function to auto-create an ActionEvent from a primitive
  81481. * @param prim defines the target primitive
  81482. * @param pointerPos defines the pointer position
  81483. * @param evt The original (browser) event
  81484. * @param additionalData additional data for the event
  81485. * @returns the new ActionEvent
  81486. */
  81487. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  81488. }
  81489. }
  81490. declare module BABYLON {
  81491. /**
  81492. * Abstract class used to decouple action Manager from scene and meshes.
  81493. * Do not instantiate.
  81494. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  81495. */
  81496. export abstract class AbstractActionManager implements IDisposable {
  81497. /** Gets the list of active triggers */
  81498. static Triggers: {
  81499. [key: string]: number;
  81500. };
  81501. /** Gets the cursor to use when hovering items */
  81502. hoverCursor: string;
  81503. /** Gets the list of actions */
  81504. actions: IAction[];
  81505. /**
  81506. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  81507. */
  81508. isRecursive: boolean;
  81509. /**
  81510. * Releases all associated resources
  81511. */
  81512. abstract dispose(): void;
  81513. /**
  81514. * Does this action manager has pointer triggers
  81515. */
  81516. abstract readonly hasPointerTriggers: boolean;
  81517. /**
  81518. * Does this action manager has pick triggers
  81519. */
  81520. abstract readonly hasPickTriggers: boolean;
  81521. /**
  81522. * Process a specific trigger
  81523. * @param trigger defines the trigger to process
  81524. * @param evt defines the event details to be processed
  81525. */
  81526. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  81527. /**
  81528. * Does this action manager handles actions of any of the given triggers
  81529. * @param triggers defines the triggers to be tested
  81530. * @return a boolean indicating whether one (or more) of the triggers is handled
  81531. */
  81532. abstract hasSpecificTriggers(triggers: number[]): boolean;
  81533. /**
  81534. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  81535. * speed.
  81536. * @param triggerA defines the trigger to be tested
  81537. * @param triggerB defines the trigger to be tested
  81538. * @return a boolean indicating whether one (or more) of the triggers is handled
  81539. */
  81540. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  81541. /**
  81542. * Does this action manager handles actions of a given trigger
  81543. * @param trigger defines the trigger to be tested
  81544. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  81545. * @return whether the trigger is handled
  81546. */
  81547. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  81548. /**
  81549. * Serialize this manager to a JSON object
  81550. * @param name defines the property name to store this manager
  81551. * @returns a JSON representation of this manager
  81552. */
  81553. abstract serialize(name: string): any;
  81554. /**
  81555. * Registers an action to this action manager
  81556. * @param action defines the action to be registered
  81557. * @return the action amended (prepared) after registration
  81558. */
  81559. abstract registerAction(action: IAction): Nullable<IAction>;
  81560. /**
  81561. * Unregisters an action to this action manager
  81562. * @param action defines the action to be unregistered
  81563. * @return a boolean indicating whether the action has been unregistered
  81564. */
  81565. abstract unregisterAction(action: IAction): Boolean;
  81566. /**
  81567. * Does exist one action manager with at least one trigger
  81568. **/
  81569. static readonly HasTriggers: boolean;
  81570. /**
  81571. * Does exist one action manager with at least one pick trigger
  81572. **/
  81573. static readonly HasPickTriggers: boolean;
  81574. /**
  81575. * Does exist one action manager that handles actions of a given trigger
  81576. * @param trigger defines the trigger to be tested
  81577. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  81578. **/
  81579. static HasSpecificTrigger(trigger: number): boolean;
  81580. }
  81581. }
  81582. declare module BABYLON {
  81583. /**
  81584. * Defines how a node can be built from a string name.
  81585. */
  81586. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  81587. /**
  81588. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  81589. */
  81590. export class Node implements IBehaviorAware<Node> {
  81591. /** @hidden */
  81592. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  81593. private static _NodeConstructors;
  81594. /**
  81595. * Add a new node constructor
  81596. * @param type defines the type name of the node to construct
  81597. * @param constructorFunc defines the constructor function
  81598. */
  81599. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  81600. /**
  81601. * Returns a node constructor based on type name
  81602. * @param type defines the type name
  81603. * @param name defines the new node name
  81604. * @param scene defines the hosting scene
  81605. * @param options defines optional options to transmit to constructors
  81606. * @returns the new constructor or null
  81607. */
  81608. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  81609. /**
  81610. * Gets or sets the name of the node
  81611. */
  81612. name: string;
  81613. /**
  81614. * Gets or sets the id of the node
  81615. */
  81616. id: string;
  81617. /**
  81618. * Gets or sets the unique id of the node
  81619. */
  81620. uniqueId: number;
  81621. /**
  81622. * Gets or sets a string used to store user defined state for the node
  81623. */
  81624. state: string;
  81625. /**
  81626. * Gets or sets an object used to store user defined information for the node
  81627. */
  81628. metadata: any;
  81629. /**
  81630. * For internal use only. Please do not use.
  81631. */
  81632. reservedDataStore: any;
  81633. /**
  81634. * Gets or sets a boolean used to define if the node must be serialized
  81635. */
  81636. doNotSerialize: boolean;
  81637. /** @hidden */
  81638. _isDisposed: boolean;
  81639. /**
  81640. * Gets a list of Animations associated with the node
  81641. */
  81642. animations: Animation[];
  81643. protected _ranges: {
  81644. [name: string]: Nullable<AnimationRange>;
  81645. };
  81646. /**
  81647. * Callback raised when the node is ready to be used
  81648. */
  81649. onReady: (node: Node) => void;
  81650. private _isEnabled;
  81651. private _isParentEnabled;
  81652. private _isReady;
  81653. /** @hidden */
  81654. _currentRenderId: number;
  81655. private _parentRenderId;
  81656. protected _childRenderId: number;
  81657. /** @hidden */
  81658. _waitingParentId: Nullable<string>;
  81659. /** @hidden */
  81660. _scene: Scene;
  81661. /** @hidden */
  81662. _cache: any;
  81663. private _parentNode;
  81664. private _children;
  81665. /** @hidden */
  81666. _worldMatrix: Matrix;
  81667. /** @hidden */
  81668. _worldMatrixDeterminant: number;
  81669. /** @hidden */
  81670. private _sceneRootNodesIndex;
  81671. /**
  81672. * Gets a boolean indicating if the node has been disposed
  81673. * @returns true if the node was disposed
  81674. */
  81675. isDisposed(): boolean;
  81676. /**
  81677. * Gets or sets the parent of the node
  81678. */
  81679. parent: Nullable<Node>;
  81680. private addToSceneRootNodes;
  81681. private removeFromSceneRootNodes;
  81682. private _animationPropertiesOverride;
  81683. /**
  81684. * Gets or sets the animation properties override
  81685. */
  81686. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  81687. /**
  81688. * Gets a string idenfifying the name of the class
  81689. * @returns "Node" string
  81690. */
  81691. getClassName(): string;
  81692. /** @hidden */
  81693. readonly _isNode: boolean;
  81694. /**
  81695. * An event triggered when the mesh is disposed
  81696. */
  81697. onDisposeObservable: Observable<Node>;
  81698. private _onDisposeObserver;
  81699. /**
  81700. * Sets a callback that will be raised when the node will be disposed
  81701. */
  81702. onDispose: () => void;
  81703. /**
  81704. * Creates a new Node
  81705. * @param name the name and id to be given to this node
  81706. * @param scene the scene this node will be added to
  81707. * @param addToRootNodes the node will be added to scene.rootNodes
  81708. */
  81709. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  81710. /**
  81711. * Gets the scene of the node
  81712. * @returns a scene
  81713. */
  81714. getScene(): Scene;
  81715. /**
  81716. * Gets the engine of the node
  81717. * @returns a Engine
  81718. */
  81719. getEngine(): Engine;
  81720. private _behaviors;
  81721. /**
  81722. * Attach a behavior to the node
  81723. * @see http://doc.babylonjs.com/features/behaviour
  81724. * @param behavior defines the behavior to attach
  81725. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  81726. * @returns the current Node
  81727. */
  81728. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  81729. /**
  81730. * Remove an attached behavior
  81731. * @see http://doc.babylonjs.com/features/behaviour
  81732. * @param behavior defines the behavior to attach
  81733. * @returns the current Node
  81734. */
  81735. removeBehavior(behavior: Behavior<Node>): Node;
  81736. /**
  81737. * Gets the list of attached behaviors
  81738. * @see http://doc.babylonjs.com/features/behaviour
  81739. */
  81740. readonly behaviors: Behavior<Node>[];
  81741. /**
  81742. * Gets an attached behavior by name
  81743. * @param name defines the name of the behavior to look for
  81744. * @see http://doc.babylonjs.com/features/behaviour
  81745. * @returns null if behavior was not found else the requested behavior
  81746. */
  81747. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  81748. /**
  81749. * Returns the latest update of the World matrix
  81750. * @returns a Matrix
  81751. */
  81752. getWorldMatrix(): Matrix;
  81753. /** @hidden */
  81754. _getWorldMatrixDeterminant(): number;
  81755. /**
  81756. * Returns directly the latest state of the mesh World matrix.
  81757. * A Matrix is returned.
  81758. */
  81759. readonly worldMatrixFromCache: Matrix;
  81760. /** @hidden */
  81761. _initCache(): void;
  81762. /** @hidden */
  81763. updateCache(force?: boolean): void;
  81764. /** @hidden */
  81765. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  81766. /** @hidden */
  81767. _updateCache(ignoreParentClass?: boolean): void;
  81768. /** @hidden */
  81769. _isSynchronized(): boolean;
  81770. /** @hidden */
  81771. _markSyncedWithParent(): void;
  81772. /** @hidden */
  81773. isSynchronizedWithParent(): boolean;
  81774. /** @hidden */
  81775. isSynchronized(): boolean;
  81776. /**
  81777. * Is this node ready to be used/rendered
  81778. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  81779. * @return true if the node is ready
  81780. */
  81781. isReady(completeCheck?: boolean): boolean;
  81782. /**
  81783. * Is this node enabled?
  81784. * 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
  81785. * @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
  81786. * @return whether this node (and its parent) is enabled
  81787. */
  81788. isEnabled(checkAncestors?: boolean): boolean;
  81789. /** @hidden */
  81790. protected _syncParentEnabledState(): void;
  81791. /**
  81792. * Set the enabled state of this node
  81793. * @param value defines the new enabled state
  81794. */
  81795. setEnabled(value: boolean): void;
  81796. /**
  81797. * Is this node a descendant of the given node?
  81798. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  81799. * @param ancestor defines the parent node to inspect
  81800. * @returns a boolean indicating if this node is a descendant of the given node
  81801. */
  81802. isDescendantOf(ancestor: Node): boolean;
  81803. /** @hidden */
  81804. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  81805. /**
  81806. * Will return all nodes that have this node as ascendant
  81807. * @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
  81808. * @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
  81809. * @return all children nodes of all types
  81810. */
  81811. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  81812. /**
  81813. * Get all child-meshes of this node
  81814. * @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)
  81815. * @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
  81816. * @returns an array of AbstractMesh
  81817. */
  81818. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  81819. /**
  81820. * Get all direct children of this node
  81821. * @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
  81822. * @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)
  81823. * @returns an array of Node
  81824. */
  81825. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  81826. /** @hidden */
  81827. _setReady(state: boolean): void;
  81828. /**
  81829. * Get an animation by name
  81830. * @param name defines the name of the animation to look for
  81831. * @returns null if not found else the requested animation
  81832. */
  81833. getAnimationByName(name: string): Nullable<Animation>;
  81834. /**
  81835. * Creates an animation range for this node
  81836. * @param name defines the name of the range
  81837. * @param from defines the starting key
  81838. * @param to defines the end key
  81839. */
  81840. createAnimationRange(name: string, from: number, to: number): void;
  81841. /**
  81842. * Delete a specific animation range
  81843. * @param name defines the name of the range to delete
  81844. * @param deleteFrames defines if animation frames from the range must be deleted as well
  81845. */
  81846. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  81847. /**
  81848. * Get an animation range by name
  81849. * @param name defines the name of the animation range to look for
  81850. * @returns null if not found else the requested animation range
  81851. */
  81852. getAnimationRange(name: string): Nullable<AnimationRange>;
  81853. /**
  81854. * Gets the list of all animation ranges defined on this node
  81855. * @returns an array
  81856. */
  81857. getAnimationRanges(): Nullable<AnimationRange>[];
  81858. /**
  81859. * Will start the animation sequence
  81860. * @param name defines the range frames for animation sequence
  81861. * @param loop defines if the animation should loop (false by default)
  81862. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  81863. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  81864. * @returns the object created for this animation. If range does not exist, it will return null
  81865. */
  81866. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  81867. /**
  81868. * Serialize animation ranges into a JSON compatible object
  81869. * @returns serialization object
  81870. */
  81871. serializeAnimationRanges(): any;
  81872. /**
  81873. * Computes the world matrix of the node
  81874. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  81875. * @returns the world matrix
  81876. */
  81877. computeWorldMatrix(force?: boolean): Matrix;
  81878. /**
  81879. * Releases resources associated with this node.
  81880. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  81881. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  81882. */
  81883. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  81884. /**
  81885. * Parse animation range data from a serialization object and store them into a given node
  81886. * @param node defines where to store the animation ranges
  81887. * @param parsedNode defines the serialization object to read data from
  81888. * @param scene defines the hosting scene
  81889. */
  81890. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  81891. }
  81892. }
  81893. declare module BABYLON {
  81894. /**
  81895. * Class used to store any kind of animation
  81896. */
  81897. export class Animation {
  81898. /**Name of the animation */
  81899. name: string;
  81900. /**Property to animate */
  81901. targetProperty: string;
  81902. /**The frames per second of the animation */
  81903. framePerSecond: number;
  81904. /**The data type of the animation */
  81905. dataType: number;
  81906. /**The loop mode of the animation */
  81907. loopMode?: number | undefined;
  81908. /**Specifies if blending should be enabled */
  81909. enableBlending?: boolean | undefined;
  81910. /**
  81911. * Use matrix interpolation instead of using direct key value when animating matrices
  81912. */
  81913. static AllowMatricesInterpolation: boolean;
  81914. /**
  81915. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  81916. */
  81917. static AllowMatrixDecomposeForInterpolation: boolean;
  81918. /**
  81919. * Stores the key frames of the animation
  81920. */
  81921. private _keys;
  81922. /**
  81923. * Stores the easing function of the animation
  81924. */
  81925. private _easingFunction;
  81926. /**
  81927. * @hidden Internal use only
  81928. */
  81929. _runtimeAnimations: RuntimeAnimation[];
  81930. /**
  81931. * The set of event that will be linked to this animation
  81932. */
  81933. private _events;
  81934. /**
  81935. * Stores an array of target property paths
  81936. */
  81937. targetPropertyPath: string[];
  81938. /**
  81939. * Stores the blending speed of the animation
  81940. */
  81941. blendingSpeed: number;
  81942. /**
  81943. * Stores the animation ranges for the animation
  81944. */
  81945. private _ranges;
  81946. /**
  81947. * @hidden Internal use
  81948. */
  81949. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  81950. /**
  81951. * Sets up an animation
  81952. * @param property The property to animate
  81953. * @param animationType The animation type to apply
  81954. * @param framePerSecond The frames per second of the animation
  81955. * @param easingFunction The easing function used in the animation
  81956. * @returns The created animation
  81957. */
  81958. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  81959. /**
  81960. * Create and start an animation on a node
  81961. * @param name defines the name of the global animation that will be run on all nodes
  81962. * @param node defines the root node where the animation will take place
  81963. * @param targetProperty defines property to animate
  81964. * @param framePerSecond defines the number of frame per second yo use
  81965. * @param totalFrame defines the number of frames in total
  81966. * @param from defines the initial value
  81967. * @param to defines the final value
  81968. * @param loopMode defines which loop mode you want to use (off by default)
  81969. * @param easingFunction defines the easing function to use (linear by default)
  81970. * @param onAnimationEnd defines the callback to call when animation end
  81971. * @returns the animatable created for this animation
  81972. */
  81973. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  81974. /**
  81975. * Create and start an animation on a node and its descendants
  81976. * @param name defines the name of the global animation that will be run on all nodes
  81977. * @param node defines the root node where the animation will take place
  81978. * @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
  81979. * @param targetProperty defines property to animate
  81980. * @param framePerSecond defines the number of frame per second to use
  81981. * @param totalFrame defines the number of frames in total
  81982. * @param from defines the initial value
  81983. * @param to defines the final value
  81984. * @param loopMode defines which loop mode you want to use (off by default)
  81985. * @param easingFunction defines the easing function to use (linear by default)
  81986. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  81987. * @returns the list of animatables created for all nodes
  81988. * @example https://www.babylonjs-playground.com/#MH0VLI
  81989. */
  81990. 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[]>;
  81991. /**
  81992. * Creates a new animation, merges it with the existing animations and starts it
  81993. * @param name Name of the animation
  81994. * @param node Node which contains the scene that begins the animations
  81995. * @param targetProperty Specifies which property to animate
  81996. * @param framePerSecond The frames per second of the animation
  81997. * @param totalFrame The total number of frames
  81998. * @param from The frame at the beginning of the animation
  81999. * @param to The frame at the end of the animation
  82000. * @param loopMode Specifies the loop mode of the animation
  82001. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  82002. * @param onAnimationEnd Callback to run once the animation is complete
  82003. * @returns Nullable animation
  82004. */
  82005. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  82006. /**
  82007. * Transition property of an host to the target Value
  82008. * @param property The property to transition
  82009. * @param targetValue The target Value of the property
  82010. * @param host The object where the property to animate belongs
  82011. * @param scene Scene used to run the animation
  82012. * @param frameRate Framerate (in frame/s) to use
  82013. * @param transition The transition type we want to use
  82014. * @param duration The duration of the animation, in milliseconds
  82015. * @param onAnimationEnd Callback trigger at the end of the animation
  82016. * @returns Nullable animation
  82017. */
  82018. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  82019. /**
  82020. * Return the array of runtime animations currently using this animation
  82021. */
  82022. readonly runtimeAnimations: RuntimeAnimation[];
  82023. /**
  82024. * Specifies if any of the runtime animations are currently running
  82025. */
  82026. readonly hasRunningRuntimeAnimations: boolean;
  82027. /**
  82028. * Initializes the animation
  82029. * @param name Name of the animation
  82030. * @param targetProperty Property to animate
  82031. * @param framePerSecond The frames per second of the animation
  82032. * @param dataType The data type of the animation
  82033. * @param loopMode The loop mode of the animation
  82034. * @param enableBlending Specifies if blending should be enabled
  82035. */
  82036. constructor(
  82037. /**Name of the animation */
  82038. name: string,
  82039. /**Property to animate */
  82040. targetProperty: string,
  82041. /**The frames per second of the animation */
  82042. framePerSecond: number,
  82043. /**The data type of the animation */
  82044. dataType: number,
  82045. /**The loop mode of the animation */
  82046. loopMode?: number | undefined,
  82047. /**Specifies if blending should be enabled */
  82048. enableBlending?: boolean | undefined);
  82049. /**
  82050. * Converts the animation to a string
  82051. * @param fullDetails support for multiple levels of logging within scene loading
  82052. * @returns String form of the animation
  82053. */
  82054. toString(fullDetails?: boolean): string;
  82055. /**
  82056. * Add an event to this animation
  82057. * @param event Event to add
  82058. */
  82059. addEvent(event: AnimationEvent): void;
  82060. /**
  82061. * Remove all events found at the given frame
  82062. * @param frame The frame to remove events from
  82063. */
  82064. removeEvents(frame: number): void;
  82065. /**
  82066. * Retrieves all the events from the animation
  82067. * @returns Events from the animation
  82068. */
  82069. getEvents(): AnimationEvent[];
  82070. /**
  82071. * Creates an animation range
  82072. * @param name Name of the animation range
  82073. * @param from Starting frame of the animation range
  82074. * @param to Ending frame of the animation
  82075. */
  82076. createRange(name: string, from: number, to: number): void;
  82077. /**
  82078. * Deletes an animation range by name
  82079. * @param name Name of the animation range to delete
  82080. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  82081. */
  82082. deleteRange(name: string, deleteFrames?: boolean): void;
  82083. /**
  82084. * Gets the animation range by name, or null if not defined
  82085. * @param name Name of the animation range
  82086. * @returns Nullable animation range
  82087. */
  82088. getRange(name: string): Nullable<AnimationRange>;
  82089. /**
  82090. * Gets the key frames from the animation
  82091. * @returns The key frames of the animation
  82092. */
  82093. getKeys(): Array<IAnimationKey>;
  82094. /**
  82095. * Gets the highest frame rate of the animation
  82096. * @returns Highest frame rate of the animation
  82097. */
  82098. getHighestFrame(): number;
  82099. /**
  82100. * Gets the easing function of the animation
  82101. * @returns Easing function of the animation
  82102. */
  82103. getEasingFunction(): IEasingFunction;
  82104. /**
  82105. * Sets the easing function of the animation
  82106. * @param easingFunction A custom mathematical formula for animation
  82107. */
  82108. setEasingFunction(easingFunction: EasingFunction): void;
  82109. /**
  82110. * Interpolates a scalar linearly
  82111. * @param startValue Start value of the animation curve
  82112. * @param endValue End value of the animation curve
  82113. * @param gradient Scalar amount to interpolate
  82114. * @returns Interpolated scalar value
  82115. */
  82116. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  82117. /**
  82118. * Interpolates a scalar cubically
  82119. * @param startValue Start value of the animation curve
  82120. * @param outTangent End tangent of the animation
  82121. * @param endValue End value of the animation curve
  82122. * @param inTangent Start tangent of the animation curve
  82123. * @param gradient Scalar amount to interpolate
  82124. * @returns Interpolated scalar value
  82125. */
  82126. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  82127. /**
  82128. * Interpolates a quaternion using a spherical linear interpolation
  82129. * @param startValue Start value of the animation curve
  82130. * @param endValue End value of the animation curve
  82131. * @param gradient Scalar amount to interpolate
  82132. * @returns Interpolated quaternion value
  82133. */
  82134. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  82135. /**
  82136. * Interpolates a quaternion cubically
  82137. * @param startValue Start value of the animation curve
  82138. * @param outTangent End tangent of the animation curve
  82139. * @param endValue End value of the animation curve
  82140. * @param inTangent Start tangent of the animation curve
  82141. * @param gradient Scalar amount to interpolate
  82142. * @returns Interpolated quaternion value
  82143. */
  82144. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  82145. /**
  82146. * Interpolates a Vector3 linearl
  82147. * @param startValue Start value of the animation curve
  82148. * @param endValue End value of the animation curve
  82149. * @param gradient Scalar amount to interpolate
  82150. * @returns Interpolated scalar value
  82151. */
  82152. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  82153. /**
  82154. * Interpolates a Vector3 cubically
  82155. * @param startValue Start value of the animation curve
  82156. * @param outTangent End tangent of the animation
  82157. * @param endValue End value of the animation curve
  82158. * @param inTangent Start tangent of the animation curve
  82159. * @param gradient Scalar amount to interpolate
  82160. * @returns InterpolatedVector3 value
  82161. */
  82162. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  82163. /**
  82164. * Interpolates a Vector2 linearly
  82165. * @param startValue Start value of the animation curve
  82166. * @param endValue End value of the animation curve
  82167. * @param gradient Scalar amount to interpolate
  82168. * @returns Interpolated Vector2 value
  82169. */
  82170. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  82171. /**
  82172. * Interpolates a Vector2 cubically
  82173. * @param startValue Start value of the animation curve
  82174. * @param outTangent End tangent of the animation
  82175. * @param endValue End value of the animation curve
  82176. * @param inTangent Start tangent of the animation curve
  82177. * @param gradient Scalar amount to interpolate
  82178. * @returns Interpolated Vector2 value
  82179. */
  82180. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  82181. /**
  82182. * Interpolates a size linearly
  82183. * @param startValue Start value of the animation curve
  82184. * @param endValue End value of the animation curve
  82185. * @param gradient Scalar amount to interpolate
  82186. * @returns Interpolated Size value
  82187. */
  82188. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  82189. /**
  82190. * Interpolates a Color3 linearly
  82191. * @param startValue Start value of the animation curve
  82192. * @param endValue End value of the animation curve
  82193. * @param gradient Scalar amount to interpolate
  82194. * @returns Interpolated Color3 value
  82195. */
  82196. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  82197. /**
  82198. * @hidden Internal use only
  82199. */
  82200. _getKeyValue(value: any): any;
  82201. /**
  82202. * @hidden Internal use only
  82203. */
  82204. _interpolate(currentFrame: number, repeatCount: number, workValue?: any, loopMode?: number, offsetValue?: any, highLimitValue?: any): any;
  82205. /**
  82206. * Defines the function to use to interpolate matrices
  82207. * @param startValue defines the start matrix
  82208. * @param endValue defines the end matrix
  82209. * @param gradient defines the gradient between both matrices
  82210. * @param result defines an optional target matrix where to store the interpolation
  82211. * @returns the interpolated matrix
  82212. */
  82213. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  82214. /**
  82215. * Makes a copy of the animation
  82216. * @returns Cloned animation
  82217. */
  82218. clone(): Animation;
  82219. /**
  82220. * Sets the key frames of the animation
  82221. * @param values The animation key frames to set
  82222. */
  82223. setKeys(values: Array<IAnimationKey>): void;
  82224. /**
  82225. * Serializes the animation to an object
  82226. * @returns Serialized object
  82227. */
  82228. serialize(): any;
  82229. /**
  82230. * Float animation type
  82231. */
  82232. private static _ANIMATIONTYPE_FLOAT;
  82233. /**
  82234. * Vector3 animation type
  82235. */
  82236. private static _ANIMATIONTYPE_VECTOR3;
  82237. /**
  82238. * Quaternion animation type
  82239. */
  82240. private static _ANIMATIONTYPE_QUATERNION;
  82241. /**
  82242. * Matrix animation type
  82243. */
  82244. private static _ANIMATIONTYPE_MATRIX;
  82245. /**
  82246. * Color3 animation type
  82247. */
  82248. private static _ANIMATIONTYPE_COLOR3;
  82249. /**
  82250. * Vector2 animation type
  82251. */
  82252. private static _ANIMATIONTYPE_VECTOR2;
  82253. /**
  82254. * Size animation type
  82255. */
  82256. private static _ANIMATIONTYPE_SIZE;
  82257. /**
  82258. * Relative Loop Mode
  82259. */
  82260. private static _ANIMATIONLOOPMODE_RELATIVE;
  82261. /**
  82262. * Cycle Loop Mode
  82263. */
  82264. private static _ANIMATIONLOOPMODE_CYCLE;
  82265. /**
  82266. * Constant Loop Mode
  82267. */
  82268. private static _ANIMATIONLOOPMODE_CONSTANT;
  82269. /**
  82270. * Get the float animation type
  82271. */
  82272. static readonly ANIMATIONTYPE_FLOAT: number;
  82273. /**
  82274. * Get the Vector3 animation type
  82275. */
  82276. static readonly ANIMATIONTYPE_VECTOR3: number;
  82277. /**
  82278. * Get the Vector2 animation type
  82279. */
  82280. static readonly ANIMATIONTYPE_VECTOR2: number;
  82281. /**
  82282. * Get the Size animation type
  82283. */
  82284. static readonly ANIMATIONTYPE_SIZE: number;
  82285. /**
  82286. * Get the Quaternion animation type
  82287. */
  82288. static readonly ANIMATIONTYPE_QUATERNION: number;
  82289. /**
  82290. * Get the Matrix animation type
  82291. */
  82292. static readonly ANIMATIONTYPE_MATRIX: number;
  82293. /**
  82294. * Get the Color3 animation type
  82295. */
  82296. static readonly ANIMATIONTYPE_COLOR3: number;
  82297. /**
  82298. * Get the Relative Loop Mode
  82299. */
  82300. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  82301. /**
  82302. * Get the Cycle Loop Mode
  82303. */
  82304. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  82305. /**
  82306. * Get the Constant Loop Mode
  82307. */
  82308. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  82309. /** @hidden */
  82310. static _UniversalLerp(left: any, right: any, amount: number): any;
  82311. /**
  82312. * Parses an animation object and creates an animation
  82313. * @param parsedAnimation Parsed animation object
  82314. * @returns Animation object
  82315. */
  82316. static Parse(parsedAnimation: any): Animation;
  82317. /**
  82318. * Appends the serialized animations from the source animations
  82319. * @param source Source containing the animations
  82320. * @param destination Target to store the animations
  82321. */
  82322. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  82323. }
  82324. }
  82325. declare module BABYLON {
  82326. /**
  82327. * Base class of all the textures in babylon.
  82328. * It groups all the common properties the materials, post process, lights... might need
  82329. * in order to make a correct use of the texture.
  82330. */
  82331. export class BaseTexture implements IAnimatable {
  82332. /**
  82333. * Default anisotropic filtering level for the application.
  82334. * It is set to 4 as a good tradeoff between perf and quality.
  82335. */
  82336. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  82337. /**
  82338. * Gets or sets the unique id of the texture
  82339. */
  82340. uniqueId: number;
  82341. /**
  82342. * Define the name of the texture.
  82343. */
  82344. name: string;
  82345. /**
  82346. * Gets or sets an object used to store user defined information.
  82347. */
  82348. metadata: any;
  82349. /**
  82350. * For internal use only. Please do not use.
  82351. */
  82352. reservedDataStore: any;
  82353. private _hasAlpha;
  82354. /**
  82355. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  82356. */
  82357. hasAlpha: boolean;
  82358. /**
  82359. * Defines if the alpha value should be determined via the rgb values.
  82360. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  82361. */
  82362. getAlphaFromRGB: boolean;
  82363. /**
  82364. * Intensity or strength of the texture.
  82365. * It is commonly used by materials to fine tune the intensity of the texture
  82366. */
  82367. level: number;
  82368. /**
  82369. * Define the UV chanel to use starting from 0 and defaulting to 0.
  82370. * This is part of the texture as textures usually maps to one uv set.
  82371. */
  82372. coordinatesIndex: number;
  82373. private _coordinatesMode;
  82374. /**
  82375. * How a texture is mapped.
  82376. *
  82377. * | Value | Type | Description |
  82378. * | ----- | ----------------------------------- | ----------- |
  82379. * | 0 | EXPLICIT_MODE | |
  82380. * | 1 | SPHERICAL_MODE | |
  82381. * | 2 | PLANAR_MODE | |
  82382. * | 3 | CUBIC_MODE | |
  82383. * | 4 | PROJECTION_MODE | |
  82384. * | 5 | SKYBOX_MODE | |
  82385. * | 6 | INVCUBIC_MODE | |
  82386. * | 7 | EQUIRECTANGULAR_MODE | |
  82387. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  82388. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  82389. */
  82390. coordinatesMode: number;
  82391. /**
  82392. * | Value | Type | Description |
  82393. * | ----- | ------------------ | ----------- |
  82394. * | 0 | CLAMP_ADDRESSMODE | |
  82395. * | 1 | WRAP_ADDRESSMODE | |
  82396. * | 2 | MIRROR_ADDRESSMODE | |
  82397. */
  82398. wrapU: number;
  82399. /**
  82400. * | Value | Type | Description |
  82401. * | ----- | ------------------ | ----------- |
  82402. * | 0 | CLAMP_ADDRESSMODE | |
  82403. * | 1 | WRAP_ADDRESSMODE | |
  82404. * | 2 | MIRROR_ADDRESSMODE | |
  82405. */
  82406. wrapV: number;
  82407. /**
  82408. * | Value | Type | Description |
  82409. * | ----- | ------------------ | ----------- |
  82410. * | 0 | CLAMP_ADDRESSMODE | |
  82411. * | 1 | WRAP_ADDRESSMODE | |
  82412. * | 2 | MIRROR_ADDRESSMODE | |
  82413. */
  82414. wrapR: number;
  82415. /**
  82416. * With compliant hardware and browser (supporting anisotropic filtering)
  82417. * this defines the level of anisotropic filtering in the texture.
  82418. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  82419. */
  82420. anisotropicFilteringLevel: number;
  82421. /**
  82422. * Define if the texture is a cube texture or if false a 2d texture.
  82423. */
  82424. isCube: boolean;
  82425. /**
  82426. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  82427. */
  82428. is3D: boolean;
  82429. /**
  82430. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  82431. * HDR texture are usually stored in linear space.
  82432. * This only impacts the PBR and Background materials
  82433. */
  82434. gammaSpace: boolean;
  82435. /**
  82436. * Gets whether or not the texture contains RGBD data.
  82437. */
  82438. readonly isRGBD: boolean;
  82439. /**
  82440. * Is Z inverted in the texture (useful in a cube texture).
  82441. */
  82442. invertZ: boolean;
  82443. /**
  82444. * Are mip maps generated for this texture or not.
  82445. */
  82446. readonly noMipmap: boolean;
  82447. /**
  82448. * @hidden
  82449. */
  82450. lodLevelInAlpha: boolean;
  82451. /**
  82452. * With prefiltered texture, defined the offset used during the prefiltering steps.
  82453. */
  82454. lodGenerationOffset: number;
  82455. /**
  82456. * With prefiltered texture, defined the scale used during the prefiltering steps.
  82457. */
  82458. lodGenerationScale: number;
  82459. /**
  82460. * Define if the texture is a render target.
  82461. */
  82462. isRenderTarget: boolean;
  82463. /**
  82464. * Define the unique id of the texture in the scene.
  82465. */
  82466. readonly uid: string;
  82467. /**
  82468. * Return a string representation of the texture.
  82469. * @returns the texture as a string
  82470. */
  82471. toString(): string;
  82472. /**
  82473. * Get the class name of the texture.
  82474. * @returns "BaseTexture"
  82475. */
  82476. getClassName(): string;
  82477. /**
  82478. * Define the list of animation attached to the texture.
  82479. */
  82480. animations: Animation[];
  82481. /**
  82482. * An event triggered when the texture is disposed.
  82483. */
  82484. onDisposeObservable: Observable<BaseTexture>;
  82485. private _onDisposeObserver;
  82486. /**
  82487. * Callback triggered when the texture has been disposed.
  82488. * Kept for back compatibility, you can use the onDisposeObservable instead.
  82489. */
  82490. onDispose: () => void;
  82491. /**
  82492. * Define the current state of the loading sequence when in delayed load mode.
  82493. */
  82494. delayLoadState: number;
  82495. private _scene;
  82496. /** @hidden */
  82497. _texture: Nullable<InternalTexture>;
  82498. private _uid;
  82499. /**
  82500. * Define if the texture is preventinga material to render or not.
  82501. * If not and the texture is not ready, the engine will use a default black texture instead.
  82502. */
  82503. readonly isBlocking: boolean;
  82504. /**
  82505. * Instantiates a new BaseTexture.
  82506. * Base class of all the textures in babylon.
  82507. * It groups all the common properties the materials, post process, lights... might need
  82508. * in order to make a correct use of the texture.
  82509. * @param scene Define the scene the texture blongs to
  82510. */
  82511. constructor(scene: Nullable<Scene>);
  82512. /**
  82513. * Get the scene the texture belongs to.
  82514. * @returns the scene or null if undefined
  82515. */
  82516. getScene(): Nullable<Scene>;
  82517. /**
  82518. * Get the texture transform matrix used to offset tile the texture for istance.
  82519. * @returns the transformation matrix
  82520. */
  82521. getTextureMatrix(): Matrix;
  82522. /**
  82523. * Get the texture reflection matrix used to rotate/transform the reflection.
  82524. * @returns the reflection matrix
  82525. */
  82526. getReflectionTextureMatrix(): Matrix;
  82527. /**
  82528. * Get the underlying lower level texture from Babylon.
  82529. * @returns the insternal texture
  82530. */
  82531. getInternalTexture(): Nullable<InternalTexture>;
  82532. /**
  82533. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  82534. * @returns true if ready or not blocking
  82535. */
  82536. isReadyOrNotBlocking(): boolean;
  82537. /**
  82538. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  82539. * @returns true if fully ready
  82540. */
  82541. isReady(): boolean;
  82542. private _cachedSize;
  82543. /**
  82544. * Get the size of the texture.
  82545. * @returns the texture size.
  82546. */
  82547. getSize(): ISize;
  82548. /**
  82549. * Get the base size of the texture.
  82550. * It can be different from the size if the texture has been resized for POT for instance
  82551. * @returns the base size
  82552. */
  82553. getBaseSize(): ISize;
  82554. /**
  82555. * Update the sampling mode of the texture.
  82556. * Default is Trilinear mode.
  82557. *
  82558. * | Value | Type | Description |
  82559. * | ----- | ------------------ | ----------- |
  82560. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  82561. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  82562. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  82563. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  82564. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  82565. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  82566. * | 7 | NEAREST_LINEAR | |
  82567. * | 8 | NEAREST_NEAREST | |
  82568. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  82569. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  82570. * | 11 | LINEAR_LINEAR | |
  82571. * | 12 | LINEAR_NEAREST | |
  82572. *
  82573. * > _mag_: magnification filter (close to the viewer)
  82574. * > _min_: minification filter (far from the viewer)
  82575. * > _mip_: filter used between mip map levels
  82576. *@param samplingMode Define the new sampling mode of the texture
  82577. */
  82578. updateSamplingMode(samplingMode: number): void;
  82579. /**
  82580. * Scales the texture if is `canRescale()`
  82581. * @param ratio the resize factor we want to use to rescale
  82582. */
  82583. scale(ratio: number): void;
  82584. /**
  82585. * Get if the texture can rescale.
  82586. */
  82587. readonly canRescale: boolean;
  82588. /** @hidden */
  82589. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  82590. /** @hidden */
  82591. _rebuild(): void;
  82592. /**
  82593. * Triggers the load sequence in delayed load mode.
  82594. */
  82595. delayLoad(): void;
  82596. /**
  82597. * Clones the texture.
  82598. * @returns the cloned texture
  82599. */
  82600. clone(): Nullable<BaseTexture>;
  82601. /**
  82602. * Get the texture underlying type (INT, FLOAT...)
  82603. */
  82604. readonly textureType: number;
  82605. /**
  82606. * Get the texture underlying format (RGB, RGBA...)
  82607. */
  82608. readonly textureFormat: number;
  82609. /**
  82610. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  82611. * This will returns an RGBA array buffer containing either in values (0-255) or
  82612. * float values (0-1) depending of the underlying buffer type.
  82613. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  82614. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  82615. * @param buffer defines a user defined buffer to fill with data (can be null)
  82616. * @returns The Array buffer containing the pixels data.
  82617. */
  82618. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  82619. /**
  82620. * Release and destroy the underlying lower level texture aka internalTexture.
  82621. */
  82622. releaseInternalTexture(): void;
  82623. /**
  82624. * Get the polynomial representation of the texture data.
  82625. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  82626. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  82627. */
  82628. sphericalPolynomial: Nullable<SphericalPolynomial>;
  82629. /** @hidden */
  82630. readonly _lodTextureHigh: Nullable<BaseTexture>;
  82631. /** @hidden */
  82632. readonly _lodTextureMid: Nullable<BaseTexture>;
  82633. /** @hidden */
  82634. readonly _lodTextureLow: Nullable<BaseTexture>;
  82635. /**
  82636. * Dispose the texture and release its associated resources.
  82637. */
  82638. dispose(): void;
  82639. /**
  82640. * Serialize the texture into a JSON representation that can be parsed later on.
  82641. * @returns the JSON representation of the texture
  82642. */
  82643. serialize(): any;
  82644. /**
  82645. * Helper function to be called back once a list of texture contains only ready textures.
  82646. * @param textures Define the list of textures to wait for
  82647. * @param callback Define the callback triggered once the entire list will be ready
  82648. */
  82649. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  82650. }
  82651. }
  82652. declare module BABYLON {
  82653. /**
  82654. * Uniform buffer objects.
  82655. *
  82656. * Handles blocks of uniform on the GPU.
  82657. *
  82658. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  82659. *
  82660. * For more information, please refer to :
  82661. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  82662. */
  82663. export class UniformBuffer {
  82664. private _engine;
  82665. private _buffer;
  82666. private _data;
  82667. private _bufferData;
  82668. private _dynamic?;
  82669. private _uniformLocations;
  82670. private _uniformSizes;
  82671. private _uniformLocationPointer;
  82672. private _needSync;
  82673. private _noUBO;
  82674. private _currentEffect;
  82675. private static _MAX_UNIFORM_SIZE;
  82676. private static _tempBuffer;
  82677. /**
  82678. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  82679. * This is dynamic to allow compat with webgl 1 and 2.
  82680. * You will need to pass the name of the uniform as well as the value.
  82681. */
  82682. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  82683. /**
  82684. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  82685. * This is dynamic to allow compat with webgl 1 and 2.
  82686. * You will need to pass the name of the uniform as well as the value.
  82687. */
  82688. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  82689. /**
  82690. * Lambda to Update a single float in a uniform buffer.
  82691. * This is dynamic to allow compat with webgl 1 and 2.
  82692. * You will need to pass the name of the uniform as well as the value.
  82693. */
  82694. updateFloat: (name: string, x: number) => void;
  82695. /**
  82696. * Lambda to Update a vec2 of float in a uniform buffer.
  82697. * This is dynamic to allow compat with webgl 1 and 2.
  82698. * You will need to pass the name of the uniform as well as the value.
  82699. */
  82700. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  82701. /**
  82702. * Lambda to Update a vec3 of float in a uniform buffer.
  82703. * This is dynamic to allow compat with webgl 1 and 2.
  82704. * You will need to pass the name of the uniform as well as the value.
  82705. */
  82706. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  82707. /**
  82708. * Lambda to Update a vec4 of float in a uniform buffer.
  82709. * This is dynamic to allow compat with webgl 1 and 2.
  82710. * You will need to pass the name of the uniform as well as the value.
  82711. */
  82712. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  82713. /**
  82714. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  82715. * This is dynamic to allow compat with webgl 1 and 2.
  82716. * You will need to pass the name of the uniform as well as the value.
  82717. */
  82718. updateMatrix: (name: string, mat: Matrix) => void;
  82719. /**
  82720. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  82721. * This is dynamic to allow compat with webgl 1 and 2.
  82722. * You will need to pass the name of the uniform as well as the value.
  82723. */
  82724. updateVector3: (name: string, vector: Vector3) => void;
  82725. /**
  82726. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  82727. * This is dynamic to allow compat with webgl 1 and 2.
  82728. * You will need to pass the name of the uniform as well as the value.
  82729. */
  82730. updateVector4: (name: string, vector: Vector4) => void;
  82731. /**
  82732. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  82733. * This is dynamic to allow compat with webgl 1 and 2.
  82734. * You will need to pass the name of the uniform as well as the value.
  82735. */
  82736. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  82737. /**
  82738. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  82739. * This is dynamic to allow compat with webgl 1 and 2.
  82740. * You will need to pass the name of the uniform as well as the value.
  82741. */
  82742. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  82743. /**
  82744. * Instantiates a new Uniform buffer objects.
  82745. *
  82746. * Handles blocks of uniform on the GPU.
  82747. *
  82748. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  82749. *
  82750. * For more information, please refer to :
  82751. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  82752. * @param engine Define the engine the buffer is associated with
  82753. * @param data Define the data contained in the buffer
  82754. * @param dynamic Define if the buffer is updatable
  82755. */
  82756. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  82757. /**
  82758. * Indicates if the buffer is using the WebGL2 UBO implementation,
  82759. * or just falling back on setUniformXXX calls.
  82760. */
  82761. readonly useUbo: boolean;
  82762. /**
  82763. * Indicates if the WebGL underlying uniform buffer is in sync
  82764. * with the javascript cache data.
  82765. */
  82766. readonly isSync: boolean;
  82767. /**
  82768. * Indicates if the WebGL underlying uniform buffer is dynamic.
  82769. * Also, a dynamic UniformBuffer will disable cache verification and always
  82770. * update the underlying WebGL uniform buffer to the GPU.
  82771. * @returns if Dynamic, otherwise false
  82772. */
  82773. isDynamic(): boolean;
  82774. /**
  82775. * The data cache on JS side.
  82776. * @returns the underlying data as a float array
  82777. */
  82778. getData(): Float32Array;
  82779. /**
  82780. * The underlying WebGL Uniform buffer.
  82781. * @returns the webgl buffer
  82782. */
  82783. getBuffer(): Nullable<WebGLBuffer>;
  82784. /**
  82785. * std140 layout specifies how to align data within an UBO structure.
  82786. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  82787. * for specs.
  82788. */
  82789. private _fillAlignment;
  82790. /**
  82791. * Adds an uniform in the buffer.
  82792. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  82793. * for the layout to be correct !
  82794. * @param name Name of the uniform, as used in the uniform block in the shader.
  82795. * @param size Data size, or data directly.
  82796. */
  82797. addUniform(name: string, size: number | number[]): void;
  82798. /**
  82799. * Adds a Matrix 4x4 to the uniform buffer.
  82800. * @param name Name of the uniform, as used in the uniform block in the shader.
  82801. * @param mat A 4x4 matrix.
  82802. */
  82803. addMatrix(name: string, mat: Matrix): void;
  82804. /**
  82805. * Adds a vec2 to the uniform buffer.
  82806. * @param name Name of the uniform, as used in the uniform block in the shader.
  82807. * @param x Define the x component value of the vec2
  82808. * @param y Define the y component value of the vec2
  82809. */
  82810. addFloat2(name: string, x: number, y: number): void;
  82811. /**
  82812. * Adds a vec3 to the uniform buffer.
  82813. * @param name Name of the uniform, as used in the uniform block in the shader.
  82814. * @param x Define the x component value of the vec3
  82815. * @param y Define the y component value of the vec3
  82816. * @param z Define the z component value of the vec3
  82817. */
  82818. addFloat3(name: string, x: number, y: number, z: number): void;
  82819. /**
  82820. * Adds a vec3 to the uniform buffer.
  82821. * @param name Name of the uniform, as used in the uniform block in the shader.
  82822. * @param color Define the vec3 from a Color
  82823. */
  82824. addColor3(name: string, color: Color3): void;
  82825. /**
  82826. * Adds a vec4 to the uniform buffer.
  82827. * @param name Name of the uniform, as used in the uniform block in the shader.
  82828. * @param color Define the rgb components from a Color
  82829. * @param alpha Define the a component of the vec4
  82830. */
  82831. addColor4(name: string, color: Color3, alpha: number): void;
  82832. /**
  82833. * Adds a vec3 to the uniform buffer.
  82834. * @param name Name of the uniform, as used in the uniform block in the shader.
  82835. * @param vector Define the vec3 components from a Vector
  82836. */
  82837. addVector3(name: string, vector: Vector3): void;
  82838. /**
  82839. * Adds a Matrix 3x3 to the uniform buffer.
  82840. * @param name Name of the uniform, as used in the uniform block in the shader.
  82841. */
  82842. addMatrix3x3(name: string): void;
  82843. /**
  82844. * Adds a Matrix 2x2 to the uniform buffer.
  82845. * @param name Name of the uniform, as used in the uniform block in the shader.
  82846. */
  82847. addMatrix2x2(name: string): void;
  82848. /**
  82849. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  82850. */
  82851. create(): void;
  82852. /** @hidden */
  82853. _rebuild(): void;
  82854. /**
  82855. * Updates the WebGL Uniform Buffer on the GPU.
  82856. * If the `dynamic` flag is set to true, no cache comparison is done.
  82857. * Otherwise, the buffer will be updated only if the cache differs.
  82858. */
  82859. update(): void;
  82860. /**
  82861. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  82862. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  82863. * @param data Define the flattened data
  82864. * @param size Define the size of the data.
  82865. */
  82866. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  82867. private _updateMatrix3x3ForUniform;
  82868. private _updateMatrix3x3ForEffect;
  82869. private _updateMatrix2x2ForEffect;
  82870. private _updateMatrix2x2ForUniform;
  82871. private _updateFloatForEffect;
  82872. private _updateFloatForUniform;
  82873. private _updateFloat2ForEffect;
  82874. private _updateFloat2ForUniform;
  82875. private _updateFloat3ForEffect;
  82876. private _updateFloat3ForUniform;
  82877. private _updateFloat4ForEffect;
  82878. private _updateFloat4ForUniform;
  82879. private _updateMatrixForEffect;
  82880. private _updateMatrixForUniform;
  82881. private _updateVector3ForEffect;
  82882. private _updateVector3ForUniform;
  82883. private _updateVector4ForEffect;
  82884. private _updateVector4ForUniform;
  82885. private _updateColor3ForEffect;
  82886. private _updateColor3ForUniform;
  82887. private _updateColor4ForEffect;
  82888. private _updateColor4ForUniform;
  82889. /**
  82890. * Sets a sampler uniform on the effect.
  82891. * @param name Define the name of the sampler.
  82892. * @param texture Define the texture to set in the sampler
  82893. */
  82894. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  82895. /**
  82896. * Directly updates the value of the uniform in the cache AND on the GPU.
  82897. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  82898. * @param data Define the flattened data
  82899. */
  82900. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  82901. /**
  82902. * Binds this uniform buffer to an effect.
  82903. * @param effect Define the effect to bind the buffer to
  82904. * @param name Name of the uniform block in the shader.
  82905. */
  82906. bindToEffect(effect: Effect, name: string): void;
  82907. /**
  82908. * Disposes the uniform buffer.
  82909. */
  82910. dispose(): void;
  82911. }
  82912. }
  82913. declare module BABYLON {
  82914. /**
  82915. * This represents the required contract to create a new type of texture loader.
  82916. */
  82917. export interface IInternalTextureLoader {
  82918. /**
  82919. * Defines wether the loader supports cascade loading the different faces.
  82920. */
  82921. supportCascades: boolean;
  82922. /**
  82923. * This returns if the loader support the current file information.
  82924. * @param extension defines the file extension of the file being loaded
  82925. * @param textureFormatInUse defines the current compressed format in use iun the engine
  82926. * @param fallback defines the fallback internal texture if any
  82927. * @param isBase64 defines whether the texture is encoded as a base64
  82928. * @param isBuffer defines whether the texture data are stored as a buffer
  82929. * @returns true if the loader can load the specified file
  82930. */
  82931. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  82932. /**
  82933. * Transform the url before loading if required.
  82934. * @param rootUrl the url of the texture
  82935. * @param textureFormatInUse defines the current compressed format in use iun the engine
  82936. * @returns the transformed texture
  82937. */
  82938. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  82939. /**
  82940. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  82941. * @param rootUrl the url of the texture
  82942. * @param textureFormatInUse defines the current compressed format in use iun the engine
  82943. * @returns the fallback texture
  82944. */
  82945. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  82946. /**
  82947. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  82948. * @param data contains the texture data
  82949. * @param texture defines the BabylonJS internal texture
  82950. * @param createPolynomials will be true if polynomials have been requested
  82951. * @param onLoad defines the callback to trigger once the texture is ready
  82952. * @param onError defines the callback to trigger in case of error
  82953. */
  82954. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  82955. /**
  82956. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  82957. * @param data contains the texture data
  82958. * @param texture defines the BabylonJS internal texture
  82959. * @param callback defines the method to call once ready to upload
  82960. */
  82961. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  82962. }
  82963. }
  82964. declare module BABYLON {
  82965. /**
  82966. * Creation options of the multi render target texture.
  82967. */
  82968. export interface IMultiRenderTargetOptions {
  82969. /**
  82970. * Define if the texture needs to create mip maps after render.
  82971. */
  82972. generateMipMaps?: boolean;
  82973. /**
  82974. * Define the types of all the draw buffers we want to create
  82975. */
  82976. types?: number[];
  82977. /**
  82978. * Define the sampling modes of all the draw buffers we want to create
  82979. */
  82980. samplingModes?: number[];
  82981. /**
  82982. * Define if a depth buffer is required
  82983. */
  82984. generateDepthBuffer?: boolean;
  82985. /**
  82986. * Define if a stencil buffer is required
  82987. */
  82988. generateStencilBuffer?: boolean;
  82989. /**
  82990. * Define if a depth texture is required instead of a depth buffer
  82991. */
  82992. generateDepthTexture?: boolean;
  82993. /**
  82994. * Define the number of desired draw buffers
  82995. */
  82996. textureCount?: number;
  82997. /**
  82998. * Define if aspect ratio should be adapted to the texture or stay the scene one
  82999. */
  83000. doNotChangeAspectRatio?: boolean;
  83001. /**
  83002. * Define the default type of the buffers we are creating
  83003. */
  83004. defaultType?: number;
  83005. }
  83006. /**
  83007. * A multi render target, like a render target provides the ability to render to a texture.
  83008. * Unlike the render target, it can render to several draw buffers in one draw.
  83009. * This is specially interesting in deferred rendering or for any effects requiring more than
  83010. * just one color from a single pass.
  83011. */
  83012. export class MultiRenderTarget extends RenderTargetTexture {
  83013. private _internalTextures;
  83014. private _textures;
  83015. private _multiRenderTargetOptions;
  83016. /**
  83017. * Get if draw buffers are currently supported by the used hardware and browser.
  83018. */
  83019. readonly isSupported: boolean;
  83020. /**
  83021. * Get the list of textures generated by the multi render target.
  83022. */
  83023. readonly textures: Texture[];
  83024. /**
  83025. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  83026. */
  83027. readonly depthTexture: Texture;
  83028. /**
  83029. * Set the wrapping mode on U of all the textures we are rendering to.
  83030. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  83031. */
  83032. wrapU: number;
  83033. /**
  83034. * Set the wrapping mode on V of all the textures we are rendering to.
  83035. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  83036. */
  83037. wrapV: number;
  83038. /**
  83039. * Instantiate a new multi render target texture.
  83040. * A multi render target, like a render target provides the ability to render to a texture.
  83041. * Unlike the render target, it can render to several draw buffers in one draw.
  83042. * This is specially interesting in deferred rendering or for any effects requiring more than
  83043. * just one color from a single pass.
  83044. * @param name Define the name of the texture
  83045. * @param size Define the size of the buffers to render to
  83046. * @param count Define the number of target we are rendering into
  83047. * @param scene Define the scene the texture belongs to
  83048. * @param options Define the options used to create the multi render target
  83049. */
  83050. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  83051. /** @hidden */
  83052. _rebuild(): void;
  83053. private _createInternalTextures;
  83054. private _createTextures;
  83055. /**
  83056. * Define the number of samples used if MSAA is enabled.
  83057. */
  83058. samples: number;
  83059. /**
  83060. * Resize all the textures in the multi render target.
  83061. * Be carrefull as it will recreate all the data in the new texture.
  83062. * @param size Define the new size
  83063. */
  83064. resize(size: any): void;
  83065. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  83066. /**
  83067. * Dispose the render targets and their associated resources
  83068. */
  83069. dispose(): void;
  83070. /**
  83071. * Release all the underlying texture used as draw buffers.
  83072. */
  83073. releaseInternalTextures(): void;
  83074. }
  83075. }
  83076. declare module BABYLON {
  83077. /**
  83078. * Class used to work with sound analyzer using fast fourier transform (FFT)
  83079. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  83080. */
  83081. export class Analyser {
  83082. /**
  83083. * Gets or sets the smoothing
  83084. * @ignorenaming
  83085. */
  83086. SMOOTHING: number;
  83087. /**
  83088. * Gets or sets the FFT table size
  83089. * @ignorenaming
  83090. */
  83091. FFT_SIZE: number;
  83092. /**
  83093. * Gets or sets the bar graph amplitude
  83094. * @ignorenaming
  83095. */
  83096. BARGRAPHAMPLITUDE: number;
  83097. /**
  83098. * Gets or sets the position of the debug canvas
  83099. * @ignorenaming
  83100. */
  83101. DEBUGCANVASPOS: {
  83102. x: number;
  83103. y: number;
  83104. };
  83105. /**
  83106. * Gets or sets the debug canvas size
  83107. * @ignorenaming
  83108. */
  83109. DEBUGCANVASSIZE: {
  83110. width: number;
  83111. height: number;
  83112. };
  83113. private _byteFreqs;
  83114. private _byteTime;
  83115. private _floatFreqs;
  83116. private _webAudioAnalyser;
  83117. private _debugCanvas;
  83118. private _debugCanvasContext;
  83119. private _scene;
  83120. private _registerFunc;
  83121. private _audioEngine;
  83122. /**
  83123. * Creates a new analyser
  83124. * @param scene defines hosting scene
  83125. */
  83126. constructor(scene: Scene);
  83127. /**
  83128. * Get the number of data values you will have to play with for the visualization
  83129. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  83130. * @returns a number
  83131. */
  83132. getFrequencyBinCount(): number;
  83133. /**
  83134. * Gets the current frequency data as a byte array
  83135. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  83136. * @returns a Uint8Array
  83137. */
  83138. getByteFrequencyData(): Uint8Array;
  83139. /**
  83140. * Gets the current waveform as a byte array
  83141. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  83142. * @returns a Uint8Array
  83143. */
  83144. getByteTimeDomainData(): Uint8Array;
  83145. /**
  83146. * Gets the current frequency data as a float array
  83147. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  83148. * @returns a Float32Array
  83149. */
  83150. getFloatFrequencyData(): Float32Array;
  83151. /**
  83152. * Renders the debug canvas
  83153. */
  83154. drawDebugCanvas(): void;
  83155. /**
  83156. * Stops rendering the debug canvas and removes it
  83157. */
  83158. stopDebugCanvas(): void;
  83159. /**
  83160. * Connects two audio nodes
  83161. * @param inputAudioNode defines first node to connect
  83162. * @param outputAudioNode defines second node to connect
  83163. */
  83164. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  83165. /**
  83166. * Releases all associated resources
  83167. */
  83168. dispose(): void;
  83169. }
  83170. }
  83171. declare module BABYLON {
  83172. /**
  83173. * This represents an audio engine and it is responsible
  83174. * to play, synchronize and analyse sounds throughout the application.
  83175. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  83176. */
  83177. export interface IAudioEngine extends IDisposable {
  83178. /**
  83179. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  83180. */
  83181. readonly canUseWebAudio: boolean;
  83182. /**
  83183. * Gets the current AudioContext if available.
  83184. */
  83185. readonly audioContext: Nullable<AudioContext>;
  83186. /**
  83187. * The master gain node defines the global audio volume of your audio engine.
  83188. */
  83189. readonly masterGain: GainNode;
  83190. /**
  83191. * Gets whether or not mp3 are supported by your browser.
  83192. */
  83193. readonly isMP3supported: boolean;
  83194. /**
  83195. * Gets whether or not ogg are supported by your browser.
  83196. */
  83197. readonly isOGGsupported: boolean;
  83198. /**
  83199. * Defines if Babylon should emit a warning if WebAudio is not supported.
  83200. * @ignoreNaming
  83201. */
  83202. WarnedWebAudioUnsupported: boolean;
  83203. /**
  83204. * Defines if the audio engine relies on a custom unlocked button.
  83205. * In this case, the embedded button will not be displayed.
  83206. */
  83207. useCustomUnlockedButton: boolean;
  83208. /**
  83209. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  83210. */
  83211. readonly unlocked: boolean;
  83212. /**
  83213. * Event raised when audio has been unlocked on the browser.
  83214. */
  83215. onAudioUnlockedObservable: Observable<AudioEngine>;
  83216. /**
  83217. * Event raised when audio has been locked on the browser.
  83218. */
  83219. onAudioLockedObservable: Observable<AudioEngine>;
  83220. /**
  83221. * Flags the audio engine in Locked state.
  83222. * This happens due to new browser policies preventing audio to autoplay.
  83223. */
  83224. lock(): void;
  83225. /**
  83226. * Unlocks the audio engine once a user action has been done on the dom.
  83227. * This is helpful to resume play once browser policies have been satisfied.
  83228. */
  83229. unlock(): void;
  83230. }
  83231. /**
  83232. * This represents the default audio engine used in babylon.
  83233. * It is responsible to play, synchronize and analyse sounds throughout the application.
  83234. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  83235. */
  83236. export class AudioEngine implements IAudioEngine {
  83237. private _audioContext;
  83238. private _audioContextInitialized;
  83239. private _muteButton;
  83240. private _hostElement;
  83241. /**
  83242. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  83243. */
  83244. canUseWebAudio: boolean;
  83245. /**
  83246. * The master gain node defines the global audio volume of your audio engine.
  83247. */
  83248. masterGain: GainNode;
  83249. /**
  83250. * Defines if Babylon should emit a warning if WebAudio is not supported.
  83251. * @ignoreNaming
  83252. */
  83253. WarnedWebAudioUnsupported: boolean;
  83254. /**
  83255. * Gets whether or not mp3 are supported by your browser.
  83256. */
  83257. isMP3supported: boolean;
  83258. /**
  83259. * Gets whether or not ogg are supported by your browser.
  83260. */
  83261. isOGGsupported: boolean;
  83262. /**
  83263. * Gets whether audio has been unlocked on the device.
  83264. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  83265. * a user interaction has happened.
  83266. */
  83267. unlocked: boolean;
  83268. /**
  83269. * Defines if the audio engine relies on a custom unlocked button.
  83270. * In this case, the embedded button will not be displayed.
  83271. */
  83272. useCustomUnlockedButton: boolean;
  83273. /**
  83274. * Event raised when audio has been unlocked on the browser.
  83275. */
  83276. onAudioUnlockedObservable: Observable<AudioEngine>;
  83277. /**
  83278. * Event raised when audio has been locked on the browser.
  83279. */
  83280. onAudioLockedObservable: Observable<AudioEngine>;
  83281. /**
  83282. * Gets the current AudioContext if available.
  83283. */
  83284. readonly audioContext: Nullable<AudioContext>;
  83285. private _connectedAnalyser;
  83286. /**
  83287. * Instantiates a new audio engine.
  83288. *
  83289. * There should be only one per page as some browsers restrict the number
  83290. * of audio contexts you can create.
  83291. * @param hostElement defines the host element where to display the mute icon if necessary
  83292. */
  83293. constructor(hostElement?: Nullable<HTMLElement>);
  83294. /**
  83295. * Flags the audio engine in Locked state.
  83296. * This happens due to new browser policies preventing audio to autoplay.
  83297. */
  83298. lock(): void;
  83299. /**
  83300. * Unlocks the audio engine once a user action has been done on the dom.
  83301. * This is helpful to resume play once browser policies have been satisfied.
  83302. */
  83303. unlock(): void;
  83304. private _resumeAudioContext;
  83305. private _initializeAudioContext;
  83306. private _tryToRun;
  83307. private _triggerRunningState;
  83308. private _triggerSuspendedState;
  83309. private _displayMuteButton;
  83310. private _moveButtonToTopLeft;
  83311. private _onResize;
  83312. private _hideMuteButton;
  83313. /**
  83314. * Destroy and release the resources associated with the audio ccontext.
  83315. */
  83316. dispose(): void;
  83317. /**
  83318. * Gets the global volume sets on the master gain.
  83319. * @returns the global volume if set or -1 otherwise
  83320. */
  83321. getGlobalVolume(): number;
  83322. /**
  83323. * Sets the global volume of your experience (sets on the master gain).
  83324. * @param newVolume Defines the new global volume of the application
  83325. */
  83326. setGlobalVolume(newVolume: number): void;
  83327. /**
  83328. * Connect the audio engine to an audio analyser allowing some amazing
  83329. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  83330. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  83331. * @param analyser The analyser to connect to the engine
  83332. */
  83333. connectToAnalyser(analyser: Analyser): void;
  83334. }
  83335. }
  83336. declare module BABYLON {
  83337. /**
  83338. * Interface used to present a loading screen while loading a scene
  83339. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  83340. */
  83341. export interface ILoadingScreen {
  83342. /**
  83343. * Function called to display the loading screen
  83344. */
  83345. displayLoadingUI: () => void;
  83346. /**
  83347. * Function called to hide the loading screen
  83348. */
  83349. hideLoadingUI: () => void;
  83350. /**
  83351. * Gets or sets the color to use for the background
  83352. */
  83353. loadingUIBackgroundColor: string;
  83354. /**
  83355. * Gets or sets the text to display while loading
  83356. */
  83357. loadingUIText: string;
  83358. }
  83359. /**
  83360. * Class used for the default loading screen
  83361. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  83362. */
  83363. export class DefaultLoadingScreen implements ILoadingScreen {
  83364. private _renderingCanvas;
  83365. private _loadingText;
  83366. private _loadingDivBackgroundColor;
  83367. private _loadingDiv;
  83368. private _loadingTextDiv;
  83369. /**
  83370. * Creates a new default loading screen
  83371. * @param _renderingCanvas defines the canvas used to render the scene
  83372. * @param _loadingText defines the default text to display
  83373. * @param _loadingDivBackgroundColor defines the default background color
  83374. */
  83375. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  83376. /**
  83377. * Function called to display the loading screen
  83378. */
  83379. displayLoadingUI(): void;
  83380. /**
  83381. * Function called to hide the loading screen
  83382. */
  83383. hideLoadingUI(): void;
  83384. /**
  83385. * Gets or sets the text to display while loading
  83386. */
  83387. loadingUIText: string;
  83388. /**
  83389. * Gets or sets the color to use for the background
  83390. */
  83391. loadingUIBackgroundColor: string;
  83392. private _resizeLoadingUI;
  83393. }
  83394. }
  83395. declare module BABYLON {
  83396. /**
  83397. * Settings for finer control over video usage
  83398. */
  83399. export interface VideoTextureSettings {
  83400. /**
  83401. * Applies `autoplay` to video, if specified
  83402. */
  83403. autoPlay?: boolean;
  83404. /**
  83405. * Applies `loop` to video, if specified
  83406. */
  83407. loop?: boolean;
  83408. /**
  83409. * Automatically updates internal texture from video at every frame in the render loop
  83410. */
  83411. autoUpdateTexture: boolean;
  83412. /**
  83413. * Image src displayed during the video loading or until the user interacts with the video.
  83414. */
  83415. poster?: string;
  83416. }
  83417. /**
  83418. * If you want to display a video in your scene, this is the special texture for that.
  83419. * This special texture works similar to other textures, with the exception of a few parameters.
  83420. * @see https://doc.babylonjs.com/how_to/video_texture
  83421. */
  83422. export class VideoTexture extends Texture {
  83423. /**
  83424. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  83425. */
  83426. readonly autoUpdateTexture: boolean;
  83427. /**
  83428. * The video instance used by the texture internally
  83429. */
  83430. readonly video: HTMLVideoElement;
  83431. private _onUserActionRequestedObservable;
  83432. /**
  83433. * Event triggerd when a dom action is required by the user to play the video.
  83434. * This happens due to recent changes in browser policies preventing video to auto start.
  83435. */
  83436. readonly onUserActionRequestedObservable: Observable<Texture>;
  83437. private _generateMipMaps;
  83438. private _engine;
  83439. private _stillImageCaptured;
  83440. private _displayingPosterTexture;
  83441. private _settings;
  83442. private _createInternalTextureOnEvent;
  83443. /**
  83444. * Creates a video texture.
  83445. * If you want to display a video in your scene, this is the special texture for that.
  83446. * This special texture works similar to other textures, with the exception of a few parameters.
  83447. * @see https://doc.babylonjs.com/how_to/video_texture
  83448. * @param name optional name, will detect from video source, if not defined
  83449. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  83450. * @param scene is obviously the current scene.
  83451. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  83452. * @param invertY is false by default but can be used to invert video on Y axis
  83453. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  83454. * @param settings allows finer control over video usage
  83455. */
  83456. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  83457. private _getName;
  83458. private _getVideo;
  83459. private _createInternalTexture;
  83460. private reset;
  83461. /**
  83462. * @hidden Internal method to initiate `update`.
  83463. */
  83464. _rebuild(): void;
  83465. /**
  83466. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  83467. */
  83468. update(): void;
  83469. /**
  83470. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  83471. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  83472. */
  83473. updateTexture(isVisible: boolean): void;
  83474. protected _updateInternalTexture: () => void;
  83475. /**
  83476. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  83477. * @param url New url.
  83478. */
  83479. updateURL(url: string): void;
  83480. /**
  83481. * Dispose the texture and release its associated resources.
  83482. */
  83483. dispose(): void;
  83484. /**
  83485. * Creates a video texture straight from a stream.
  83486. * @param scene Define the scene the texture should be created in
  83487. * @param stream Define the stream the texture should be created from
  83488. * @returns The created video texture as a promise
  83489. */
  83490. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  83491. /**
  83492. * Creates a video texture straight from your WebCam video feed.
  83493. * @param scene Define the scene the texture should be created in
  83494. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  83495. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  83496. * @returns The created video texture as a promise
  83497. */
  83498. static CreateFromWebCamAsync(scene: Scene, constraints: {
  83499. minWidth: number;
  83500. maxWidth: number;
  83501. minHeight: number;
  83502. maxHeight: number;
  83503. deviceId: string;
  83504. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  83505. /**
  83506. * Creates a video texture straight from your WebCam video feed.
  83507. * @param scene Define the scene the texture should be created in
  83508. * @param onReady Define a callback to triggered once the texture will be ready
  83509. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  83510. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  83511. */
  83512. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  83513. minWidth: number;
  83514. maxWidth: number;
  83515. minHeight: number;
  83516. maxHeight: number;
  83517. deviceId: string;
  83518. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  83519. }
  83520. }
  83521. declare module BABYLON {
  83522. /**
  83523. * Interface for attribute information associated with buffer instanciation
  83524. */
  83525. export class InstancingAttributeInfo {
  83526. /**
  83527. * Index/offset of the attribute in the vertex shader
  83528. */
  83529. index: number;
  83530. /**
  83531. * size of the attribute, 1, 2, 3 or 4
  83532. */
  83533. attributeSize: number;
  83534. /**
  83535. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  83536. * default is FLOAT
  83537. */
  83538. attribyteType: number;
  83539. /**
  83540. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  83541. */
  83542. normalized: boolean;
  83543. /**
  83544. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  83545. */
  83546. offset: number;
  83547. /**
  83548. * Name of the GLSL attribute, for debugging purpose only
  83549. */
  83550. attributeName: string;
  83551. }
  83552. /**
  83553. * Define options used to create a depth texture
  83554. */
  83555. export class DepthTextureCreationOptions {
  83556. /** Specifies whether or not a stencil should be allocated in the texture */
  83557. generateStencil?: boolean;
  83558. /** Specifies whether or not bilinear filtering is enable on the texture */
  83559. bilinearFiltering?: boolean;
  83560. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  83561. comparisonFunction?: number;
  83562. /** Specifies if the created texture is a cube texture */
  83563. isCube?: boolean;
  83564. }
  83565. /**
  83566. * Class used to describe the capabilities of the engine relatively to the current browser
  83567. */
  83568. export class EngineCapabilities {
  83569. /** Maximum textures units per fragment shader */
  83570. maxTexturesImageUnits: number;
  83571. /** Maximum texture units per vertex shader */
  83572. maxVertexTextureImageUnits: number;
  83573. /** Maximum textures units in the entire pipeline */
  83574. maxCombinedTexturesImageUnits: number;
  83575. /** Maximum texture size */
  83576. maxTextureSize: number;
  83577. /** Maximum cube texture size */
  83578. maxCubemapTextureSize: number;
  83579. /** Maximum render texture size */
  83580. maxRenderTextureSize: number;
  83581. /** Maximum number of vertex attributes */
  83582. maxVertexAttribs: number;
  83583. /** Maximum number of varyings */
  83584. maxVaryingVectors: number;
  83585. /** Maximum number of uniforms per vertex shader */
  83586. maxVertexUniformVectors: number;
  83587. /** Maximum number of uniforms per fragment shader */
  83588. maxFragmentUniformVectors: number;
  83589. /** Defines if standard derivates (dx/dy) are supported */
  83590. standardDerivatives: boolean;
  83591. /** Defines if s3tc texture compression is supported */
  83592. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  83593. /** Defines if pvrtc texture compression is supported */
  83594. pvrtc: any;
  83595. /** Defines if etc1 texture compression is supported */
  83596. etc1: any;
  83597. /** Defines if etc2 texture compression is supported */
  83598. etc2: any;
  83599. /** Defines if astc texture compression is supported */
  83600. astc: any;
  83601. /** Defines if float textures are supported */
  83602. textureFloat: boolean;
  83603. /** Defines if vertex array objects are supported */
  83604. vertexArrayObject: boolean;
  83605. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  83606. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  83607. /** Gets the maximum level of anisotropy supported */
  83608. maxAnisotropy: number;
  83609. /** Defines if instancing is supported */
  83610. instancedArrays: boolean;
  83611. /** Defines if 32 bits indices are supported */
  83612. uintIndices: boolean;
  83613. /** Defines if high precision shaders are supported */
  83614. highPrecisionShaderSupported: boolean;
  83615. /** Defines if depth reading in the fragment shader is supported */
  83616. fragmentDepthSupported: boolean;
  83617. /** Defines if float texture linear filtering is supported*/
  83618. textureFloatLinearFiltering: boolean;
  83619. /** Defines if rendering to float textures is supported */
  83620. textureFloatRender: boolean;
  83621. /** Defines if half float textures are supported*/
  83622. textureHalfFloat: boolean;
  83623. /** Defines if half float texture linear filtering is supported*/
  83624. textureHalfFloatLinearFiltering: boolean;
  83625. /** Defines if rendering to half float textures is supported */
  83626. textureHalfFloatRender: boolean;
  83627. /** Defines if textureLOD shader command is supported */
  83628. textureLOD: boolean;
  83629. /** Defines if draw buffers extension is supported */
  83630. drawBuffersExtension: boolean;
  83631. /** Defines if depth textures are supported */
  83632. depthTextureExtension: boolean;
  83633. /** Defines if float color buffer are supported */
  83634. colorBufferFloat: boolean;
  83635. /** Gets disjoint timer query extension (null if not supported) */
  83636. timerQuery: EXT_disjoint_timer_query;
  83637. /** Defines if timestamp can be used with timer query */
  83638. canUseTimestampForTimerQuery: boolean;
  83639. /** Function used to let the system compiles shaders in background */
  83640. parallelShaderCompile: {
  83641. MAX_SHADER_COMPILER_THREADS_KHR: number;
  83642. maxShaderCompilerThreadsKHR: (thread: number) => void;
  83643. COMPLETION_STATUS_KHR: number;
  83644. };
  83645. }
  83646. /** Interface defining initialization parameters for Engine class */
  83647. export interface EngineOptions extends WebGLContextAttributes {
  83648. /**
  83649. * Defines if the engine should no exceed a specified device ratio
  83650. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  83651. */
  83652. limitDeviceRatio?: number;
  83653. /**
  83654. * Defines if webvr should be enabled automatically
  83655. * @see http://doc.babylonjs.com/how_to/webvr_camera
  83656. */
  83657. autoEnableWebVR?: boolean;
  83658. /**
  83659. * Defines if webgl2 should be turned off even if supported
  83660. * @see http://doc.babylonjs.com/features/webgl2
  83661. */
  83662. disableWebGL2Support?: boolean;
  83663. /**
  83664. * Defines if webaudio should be initialized as well
  83665. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  83666. */
  83667. audioEngine?: boolean;
  83668. /**
  83669. * Defines if animations should run using a deterministic lock step
  83670. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  83671. */
  83672. deterministicLockstep?: boolean;
  83673. /** Defines the maximum steps to use with deterministic lock step mode */
  83674. lockstepMaxSteps?: number;
  83675. /**
  83676. * Defines that engine should ignore context lost events
  83677. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  83678. */
  83679. doNotHandleContextLost?: boolean;
  83680. /**
  83681. * Defines that engine should ignore modifying touch action attribute and style
  83682. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  83683. */
  83684. doNotHandleTouchAction?: boolean;
  83685. }
  83686. /**
  83687. * Defines the interface used by display changed events
  83688. */
  83689. export interface IDisplayChangedEventArgs {
  83690. /** Gets the vrDisplay object (if any) */
  83691. vrDisplay: Nullable<any>;
  83692. /** Gets a boolean indicating if webVR is supported */
  83693. vrSupported: boolean;
  83694. }
  83695. /**
  83696. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  83697. */
  83698. export class Engine {
  83699. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  83700. static ExceptionList: ({
  83701. key: string;
  83702. capture: string;
  83703. captureConstraint: number;
  83704. targets: string[];
  83705. } | {
  83706. key: string;
  83707. capture: null;
  83708. captureConstraint: null;
  83709. targets: string[];
  83710. })[];
  83711. /** Gets the list of created engines */
  83712. static readonly Instances: Engine[];
  83713. /**
  83714. * Gets the latest created engine
  83715. */
  83716. static readonly LastCreatedEngine: Nullable<Engine>;
  83717. /**
  83718. * Gets the latest created scene
  83719. */
  83720. static readonly LastCreatedScene: Nullable<Scene>;
  83721. /**
  83722. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  83723. * @param flag defines which part of the materials must be marked as dirty
  83724. * @param predicate defines a predicate used to filter which materials should be affected
  83725. */
  83726. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  83727. /**
  83728. * Hidden
  83729. */
  83730. static _TextureLoaders: IInternalTextureLoader[];
  83731. /** Defines that alpha blending is disabled */
  83732. static readonly ALPHA_DISABLE: number;
  83733. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  83734. static readonly ALPHA_ADD: number;
  83735. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  83736. static readonly ALPHA_COMBINE: number;
  83737. /** Defines that alpha blending to DEST - SRC * DEST */
  83738. static readonly ALPHA_SUBTRACT: number;
  83739. /** Defines that alpha blending to SRC * DEST */
  83740. static readonly ALPHA_MULTIPLY: number;
  83741. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  83742. static readonly ALPHA_MAXIMIZED: number;
  83743. /** Defines that alpha blending to SRC + DEST */
  83744. static readonly ALPHA_ONEONE: number;
  83745. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  83746. static readonly ALPHA_PREMULTIPLIED: number;
  83747. /**
  83748. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  83749. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  83750. */
  83751. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  83752. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  83753. static readonly ALPHA_INTERPOLATE: number;
  83754. /**
  83755. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  83756. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  83757. */
  83758. static readonly ALPHA_SCREENMODE: number;
  83759. /** Defines that the ressource is not delayed*/
  83760. static readonly DELAYLOADSTATE_NONE: number;
  83761. /** Defines that the ressource was successfully delay loaded */
  83762. static readonly DELAYLOADSTATE_LOADED: number;
  83763. /** Defines that the ressource is currently delay loading */
  83764. static readonly DELAYLOADSTATE_LOADING: number;
  83765. /** Defines that the ressource is delayed and has not started loading */
  83766. static readonly DELAYLOADSTATE_NOTLOADED: number;
  83767. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  83768. static readonly NEVER: number;
  83769. /** 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 */
  83770. static readonly ALWAYS: number;
  83771. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  83772. static readonly LESS: number;
  83773. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  83774. static readonly EQUAL: number;
  83775. /** 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 */
  83776. static readonly LEQUAL: number;
  83777. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  83778. static readonly GREATER: number;
  83779. /** 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 */
  83780. static readonly GEQUAL: number;
  83781. /** 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 */
  83782. static readonly NOTEQUAL: number;
  83783. /** Passed to stencilOperation to specify that stencil value must be kept */
  83784. static readonly KEEP: number;
  83785. /** Passed to stencilOperation to specify that stencil value must be replaced */
  83786. static readonly REPLACE: number;
  83787. /** Passed to stencilOperation to specify that stencil value must be incremented */
  83788. static readonly INCR: number;
  83789. /** Passed to stencilOperation to specify that stencil value must be decremented */
  83790. static readonly DECR: number;
  83791. /** Passed to stencilOperation to specify that stencil value must be inverted */
  83792. static readonly INVERT: number;
  83793. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  83794. static readonly INCR_WRAP: number;
  83795. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  83796. static readonly DECR_WRAP: number;
  83797. /** Texture is not repeating outside of 0..1 UVs */
  83798. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  83799. /** Texture is repeating outside of 0..1 UVs */
  83800. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  83801. /** Texture is repeating and mirrored */
  83802. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  83803. /** ALPHA */
  83804. static readonly TEXTUREFORMAT_ALPHA: number;
  83805. /** LUMINANCE */
  83806. static readonly TEXTUREFORMAT_LUMINANCE: number;
  83807. /** LUMINANCE_ALPHA */
  83808. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  83809. /** RGB */
  83810. static readonly TEXTUREFORMAT_RGB: number;
  83811. /** RGBA */
  83812. static readonly TEXTUREFORMAT_RGBA: number;
  83813. /** RED */
  83814. static readonly TEXTUREFORMAT_RED: number;
  83815. /** RED (2nd reference) */
  83816. static readonly TEXTUREFORMAT_R: number;
  83817. /** RG */
  83818. static readonly TEXTUREFORMAT_RG: number;
  83819. /** RED_INTEGER */
  83820. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  83821. /** RED_INTEGER (2nd reference) */
  83822. static readonly TEXTUREFORMAT_R_INTEGER: number;
  83823. /** RG_INTEGER */
  83824. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  83825. /** RGB_INTEGER */
  83826. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  83827. /** RGBA_INTEGER */
  83828. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  83829. /** UNSIGNED_BYTE */
  83830. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  83831. /** UNSIGNED_BYTE (2nd reference) */
  83832. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  83833. /** FLOAT */
  83834. static readonly TEXTURETYPE_FLOAT: number;
  83835. /** HALF_FLOAT */
  83836. static readonly TEXTURETYPE_HALF_FLOAT: number;
  83837. /** BYTE */
  83838. static readonly TEXTURETYPE_BYTE: number;
  83839. /** SHORT */
  83840. static readonly TEXTURETYPE_SHORT: number;
  83841. /** UNSIGNED_SHORT */
  83842. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  83843. /** INT */
  83844. static readonly TEXTURETYPE_INT: number;
  83845. /** UNSIGNED_INT */
  83846. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  83847. /** UNSIGNED_SHORT_4_4_4_4 */
  83848. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  83849. /** UNSIGNED_SHORT_5_5_5_1 */
  83850. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  83851. /** UNSIGNED_SHORT_5_6_5 */
  83852. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  83853. /** UNSIGNED_INT_2_10_10_10_REV */
  83854. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  83855. /** UNSIGNED_INT_24_8 */
  83856. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  83857. /** UNSIGNED_INT_10F_11F_11F_REV */
  83858. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  83859. /** UNSIGNED_INT_5_9_9_9_REV */
  83860. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  83861. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  83862. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  83863. /** nearest is mag = nearest and min = nearest and mip = linear */
  83864. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  83865. /** Bilinear is mag = linear and min = linear and mip = nearest */
  83866. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  83867. /** Trilinear is mag = linear and min = linear and mip = linear */
  83868. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  83869. /** nearest is mag = nearest and min = nearest and mip = linear */
  83870. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  83871. /** Bilinear is mag = linear and min = linear and mip = nearest */
  83872. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  83873. /** Trilinear is mag = linear and min = linear and mip = linear */
  83874. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  83875. /** mag = nearest and min = nearest and mip = nearest */
  83876. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  83877. /** mag = nearest and min = linear and mip = nearest */
  83878. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  83879. /** mag = nearest and min = linear and mip = linear */
  83880. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  83881. /** mag = nearest and min = linear and mip = none */
  83882. static readonly TEXTURE_NEAREST_LINEAR: number;
  83883. /** mag = nearest and min = nearest and mip = none */
  83884. static readonly TEXTURE_NEAREST_NEAREST: number;
  83885. /** mag = linear and min = nearest and mip = nearest */
  83886. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  83887. /** mag = linear and min = nearest and mip = linear */
  83888. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  83889. /** mag = linear and min = linear and mip = none */
  83890. static readonly TEXTURE_LINEAR_LINEAR: number;
  83891. /** mag = linear and min = nearest and mip = none */
  83892. static readonly TEXTURE_LINEAR_NEAREST: number;
  83893. /** Explicit coordinates mode */
  83894. static readonly TEXTURE_EXPLICIT_MODE: number;
  83895. /** Spherical coordinates mode */
  83896. static readonly TEXTURE_SPHERICAL_MODE: number;
  83897. /** Planar coordinates mode */
  83898. static readonly TEXTURE_PLANAR_MODE: number;
  83899. /** Cubic coordinates mode */
  83900. static readonly TEXTURE_CUBIC_MODE: number;
  83901. /** Projection coordinates mode */
  83902. static readonly TEXTURE_PROJECTION_MODE: number;
  83903. /** Skybox coordinates mode */
  83904. static readonly TEXTURE_SKYBOX_MODE: number;
  83905. /** Inverse Cubic coordinates mode */
  83906. static readonly TEXTURE_INVCUBIC_MODE: number;
  83907. /** Equirectangular coordinates mode */
  83908. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  83909. /** Equirectangular Fixed coordinates mode */
  83910. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  83911. /** Equirectangular Fixed Mirrored coordinates mode */
  83912. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  83913. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  83914. static readonly SCALEMODE_FLOOR: number;
  83915. /** Defines that texture rescaling will look for the nearest power of 2 size */
  83916. static readonly SCALEMODE_NEAREST: number;
  83917. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  83918. static readonly SCALEMODE_CEILING: number;
  83919. /**
  83920. * Returns the current version of the framework
  83921. */
  83922. static readonly Version: string;
  83923. /**
  83924. * Returns a string describing the current engine
  83925. */
  83926. readonly description: string;
  83927. /**
  83928. * Gets or sets the epsilon value used by collision engine
  83929. */
  83930. static CollisionsEpsilon: number;
  83931. /**
  83932. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  83933. */
  83934. static ShadersRepository: string;
  83935. /**
  83936. * Method called to create the default loading screen.
  83937. * This can be overriden in your own app.
  83938. * @param canvas The rendering canvas element
  83939. * @returns The loading screen
  83940. */
  83941. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  83942. /**
  83943. * Method called to create the default rescale post process on each engine.
  83944. */
  83945. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  83946. /**
  83947. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  83948. */
  83949. forcePOTTextures: boolean;
  83950. /**
  83951. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  83952. */
  83953. isFullscreen: boolean;
  83954. /**
  83955. * Gets a boolean indicating if the pointer is currently locked
  83956. */
  83957. isPointerLock: boolean;
  83958. /**
  83959. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  83960. */
  83961. cullBackFaces: boolean;
  83962. /**
  83963. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  83964. */
  83965. renderEvenInBackground: boolean;
  83966. /**
  83967. * Gets or sets a boolean indicating that cache can be kept between frames
  83968. */
  83969. preventCacheWipeBetweenFrames: boolean;
  83970. /**
  83971. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  83972. **/
  83973. enableOfflineSupport: boolean;
  83974. /**
  83975. * 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)
  83976. **/
  83977. disableManifestCheck: boolean;
  83978. /**
  83979. * Gets the list of created scenes
  83980. */
  83981. scenes: Scene[];
  83982. /**
  83983. * Event raised when a new scene is created
  83984. */
  83985. onNewSceneAddedObservable: Observable<Scene>;
  83986. /**
  83987. * Gets the list of created postprocesses
  83988. */
  83989. postProcesses: PostProcess[];
  83990. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  83991. validateShaderPrograms: boolean;
  83992. /**
  83993. * Observable event triggered each time the rendering canvas is resized
  83994. */
  83995. onResizeObservable: Observable<Engine>;
  83996. /**
  83997. * Observable event triggered each time the canvas loses focus
  83998. */
  83999. onCanvasBlurObservable: Observable<Engine>;
  84000. /**
  84001. * Observable event triggered each time the canvas gains focus
  84002. */
  84003. onCanvasFocusObservable: Observable<Engine>;
  84004. /**
  84005. * Observable event triggered each time the canvas receives pointerout event
  84006. */
  84007. onCanvasPointerOutObservable: Observable<PointerEvent>;
  84008. /**
  84009. * Observable event triggered before each texture is initialized
  84010. */
  84011. onBeforeTextureInitObservable: Observable<Texture>;
  84012. private _vrDisplay;
  84013. private _vrSupported;
  84014. private _oldSize;
  84015. private _oldHardwareScaleFactor;
  84016. private _vrExclusivePointerMode;
  84017. private _webVRInitPromise;
  84018. /**
  84019. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  84020. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  84021. */
  84022. readonly isInVRExclusivePointerMode: boolean;
  84023. /**
  84024. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  84025. */
  84026. disableUniformBuffers: boolean;
  84027. /** @hidden */
  84028. _uniformBuffers: UniformBuffer[];
  84029. /**
  84030. * Gets a boolean indicating that the engine supports uniform buffers
  84031. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  84032. */
  84033. readonly supportsUniformBuffers: boolean;
  84034. /**
  84035. * Observable raised when the engine begins a new frame
  84036. */
  84037. onBeginFrameObservable: Observable<Engine>;
  84038. /**
  84039. * If set, will be used to request the next animation frame for the render loop
  84040. */
  84041. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  84042. /**
  84043. * Observable raised when the engine ends the current frame
  84044. */
  84045. onEndFrameObservable: Observable<Engine>;
  84046. /**
  84047. * Observable raised when the engine is about to compile a shader
  84048. */
  84049. onBeforeShaderCompilationObservable: Observable<Engine>;
  84050. /**
  84051. * Observable raised when the engine has jsut compiled a shader
  84052. */
  84053. onAfterShaderCompilationObservable: Observable<Engine>;
  84054. /** @hidden */
  84055. _gl: WebGLRenderingContext;
  84056. private _renderingCanvas;
  84057. private _windowIsBackground;
  84058. private _webGLVersion;
  84059. /**
  84060. * Gets a boolean indicating that only power of 2 textures are supported
  84061. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  84062. */
  84063. readonly needPOTTextures: boolean;
  84064. /** @hidden */
  84065. _badOS: boolean;
  84066. /** @hidden */
  84067. _badDesktopOS: boolean;
  84068. /**
  84069. * Gets or sets a value indicating if we want to disable texture binding optimization.
  84070. * This could be required on some buggy drivers which wants to have textures bound in a progressive order.
  84071. * By default Babylon.js will try to let textures bound where they are and only update the samplers to point where the texture is
  84072. */
  84073. disableTextureBindingOptimization: boolean;
  84074. /**
  84075. * Gets the audio engine
  84076. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  84077. * @ignorenaming
  84078. */
  84079. static audioEngine: IAudioEngine;
  84080. /**
  84081. * Default AudioEngine factory responsible of creating the Audio Engine.
  84082. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  84083. */
  84084. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  84085. /**
  84086. * Default offline support factory responsible of creating a tool used to store data locally.
  84087. * By default, this will create a Database object if the workload has been embedded.
  84088. */
  84089. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  84090. private _onFocus;
  84091. private _onBlur;
  84092. private _onCanvasPointerOut;
  84093. private _onCanvasBlur;
  84094. private _onCanvasFocus;
  84095. private _onFullscreenChange;
  84096. private _onPointerLockChange;
  84097. private _onVRDisplayPointerRestricted;
  84098. private _onVRDisplayPointerUnrestricted;
  84099. private _onVrDisplayConnect;
  84100. private _onVrDisplayDisconnect;
  84101. private _onVrDisplayPresentChange;
  84102. /**
  84103. * Observable signaled when VR display mode changes
  84104. */
  84105. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  84106. /**
  84107. * Observable signaled when VR request present is complete
  84108. */
  84109. onVRRequestPresentComplete: Observable<boolean>;
  84110. /**
  84111. * Observable signaled when VR request present starts
  84112. */
  84113. onVRRequestPresentStart: Observable<Engine>;
  84114. private _hardwareScalingLevel;
  84115. /** @hidden */
  84116. protected _caps: EngineCapabilities;
  84117. private _pointerLockRequested;
  84118. private _isStencilEnable;
  84119. private _colorWrite;
  84120. private _loadingScreen;
  84121. /** @hidden */
  84122. _drawCalls: PerfCounter;
  84123. /** @hidden */
  84124. _textureCollisions: PerfCounter;
  84125. private _glVersion;
  84126. private _glRenderer;
  84127. private _glVendor;
  84128. private _videoTextureSupported;
  84129. private _renderingQueueLaunched;
  84130. private _activeRenderLoops;
  84131. private _deterministicLockstep;
  84132. private _lockstepMaxSteps;
  84133. /**
  84134. * Observable signaled when a context lost event is raised
  84135. */
  84136. onContextLostObservable: Observable<Engine>;
  84137. /**
  84138. * Observable signaled when a context restored event is raised
  84139. */
  84140. onContextRestoredObservable: Observable<Engine>;
  84141. private _onContextLost;
  84142. private _onContextRestored;
  84143. private _contextWasLost;
  84144. private _doNotHandleContextLost;
  84145. /**
  84146. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  84147. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  84148. */
  84149. doNotHandleContextLost: boolean;
  84150. private _performanceMonitor;
  84151. private _fps;
  84152. private _deltaTime;
  84153. /**
  84154. * Turn this value on if you want to pause FPS computation when in background
  84155. */
  84156. disablePerformanceMonitorInBackground: boolean;
  84157. /**
  84158. * Gets the performance monitor attached to this engine
  84159. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  84160. */
  84161. readonly performanceMonitor: PerformanceMonitor;
  84162. /** @hidden */
  84163. protected _depthCullingState: _DepthCullingState;
  84164. /** @hidden */
  84165. protected _stencilState: _StencilState;
  84166. /** @hidden */
  84167. protected _alphaState: _AlphaState;
  84168. /** @hidden */
  84169. protected _alphaMode: number;
  84170. protected _internalTexturesCache: InternalTexture[];
  84171. /** @hidden */
  84172. protected _activeChannel: number;
  84173. private _currentTextureChannel;
  84174. /** @hidden */
  84175. protected _boundTexturesCache: {
  84176. [key: string]: Nullable<InternalTexture>;
  84177. };
  84178. /** @hidden */
  84179. protected _currentEffect: Nullable<Effect>;
  84180. /** @hidden */
  84181. protected _currentProgram: Nullable<WebGLProgram>;
  84182. private _compiledEffects;
  84183. private _vertexAttribArraysEnabled;
  84184. /** @hidden */
  84185. protected _cachedViewport: Nullable<Viewport>;
  84186. private _cachedVertexArrayObject;
  84187. /** @hidden */
  84188. protected _cachedVertexBuffers: any;
  84189. /** @hidden */
  84190. protected _cachedIndexBuffer: Nullable<WebGLBuffer>;
  84191. /** @hidden */
  84192. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  84193. /** @hidden */
  84194. protected _currentRenderTarget: Nullable<InternalTexture>;
  84195. private _uintIndicesCurrentlySet;
  84196. private _currentBoundBuffer;
  84197. /** @hidden */
  84198. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  84199. private _currentBufferPointers;
  84200. private _currentInstanceLocations;
  84201. private _currentInstanceBuffers;
  84202. private _textureUnits;
  84203. private _firstBoundInternalTextureTracker;
  84204. private _lastBoundInternalTextureTracker;
  84205. private _workingCanvas;
  84206. private _workingContext;
  84207. private _rescalePostProcess;
  84208. private _dummyFramebuffer;
  84209. private _externalData;
  84210. private _bindedRenderFunction;
  84211. private _vaoRecordInProgress;
  84212. private _mustWipeVertexAttributes;
  84213. private _emptyTexture;
  84214. private _emptyCubeTexture;
  84215. private _emptyTexture3D;
  84216. /** @hidden */
  84217. _frameHandler: number;
  84218. private _nextFreeTextureSlots;
  84219. private _maxSimultaneousTextures;
  84220. private _activeRequests;
  84221. private _texturesSupported;
  84222. private _textureFormatInUse;
  84223. /**
  84224. * Gets the list of texture formats supported
  84225. */
  84226. readonly texturesSupported: Array<string>;
  84227. /**
  84228. * Gets the list of texture formats in use
  84229. */
  84230. readonly textureFormatInUse: Nullable<string>;
  84231. /**
  84232. * Gets the current viewport
  84233. */
  84234. readonly currentViewport: Nullable<Viewport>;
  84235. /**
  84236. * Gets the default empty texture
  84237. */
  84238. readonly emptyTexture: InternalTexture;
  84239. /**
  84240. * Gets the default empty 3D texture
  84241. */
  84242. readonly emptyTexture3D: InternalTexture;
  84243. /**
  84244. * Gets the default empty cube texture
  84245. */
  84246. readonly emptyCubeTexture: InternalTexture;
  84247. /**
  84248. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  84249. */
  84250. readonly premultipliedAlpha: boolean;
  84251. /**
  84252. * Creates a new engine
  84253. * @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
  84254. * @param antialias defines enable antialiasing (default: false)
  84255. * @param options defines further options to be sent to the getContext() function
  84256. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  84257. */
  84258. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  84259. private _disableTouchAction;
  84260. private _rebuildInternalTextures;
  84261. private _rebuildEffects;
  84262. /**
  84263. * Gets a boolean indicating if all created effects are ready
  84264. * @returns true if all effects are ready
  84265. */
  84266. areAllEffectsReady(): boolean;
  84267. private _rebuildBuffers;
  84268. private _initGLContext;
  84269. /**
  84270. * Gets version of the current webGL context
  84271. */
  84272. readonly webGLVersion: number;
  84273. /**
  84274. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  84275. */
  84276. readonly isStencilEnable: boolean;
  84277. private _prepareWorkingCanvas;
  84278. /**
  84279. * Reset the texture cache to empty state
  84280. */
  84281. resetTextureCache(): void;
  84282. /**
  84283. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  84284. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  84285. * @returns true if engine is in deterministic lock step mode
  84286. */
  84287. isDeterministicLockStep(): boolean;
  84288. /**
  84289. * Gets the max steps when engine is running in deterministic lock step
  84290. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  84291. * @returns the max steps
  84292. */
  84293. getLockstepMaxSteps(): number;
  84294. /**
  84295. * Gets an object containing information about the current webGL context
  84296. * @returns an object containing the vender, the renderer and the version of the current webGL context
  84297. */
  84298. getGlInfo(): {
  84299. vendor: string;
  84300. renderer: string;
  84301. version: string;
  84302. };
  84303. /**
  84304. * Gets current aspect ratio
  84305. * @param camera defines the camera to use to get the aspect ratio
  84306. * @param useScreen defines if screen size must be used (or the current render target if any)
  84307. * @returns a number defining the aspect ratio
  84308. */
  84309. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  84310. /**
  84311. * Gets current screen aspect ratio
  84312. * @returns a number defining the aspect ratio
  84313. */
  84314. getScreenAspectRatio(): number;
  84315. /**
  84316. * Gets the current render width
  84317. * @param useScreen defines if screen size must be used (or the current render target if any)
  84318. * @returns a number defining the current render width
  84319. */
  84320. getRenderWidth(useScreen?: boolean): number;
  84321. /**
  84322. * Gets the current render height
  84323. * @param useScreen defines if screen size must be used (or the current render target if any)
  84324. * @returns a number defining the current render height
  84325. */
  84326. getRenderHeight(useScreen?: boolean): number;
  84327. /**
  84328. * Gets the HTML canvas attached with the current webGL context
  84329. * @returns a HTML canvas
  84330. */
  84331. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  84332. /**
  84333. * Gets the client rect of the HTML canvas attached with the current webGL context
  84334. * @returns a client rectanglee
  84335. */
  84336. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  84337. /**
  84338. * Defines the hardware scaling level.
  84339. * By default the hardware scaling level is computed from the window device ratio.
  84340. * 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.
  84341. * @param level defines the level to use
  84342. */
  84343. setHardwareScalingLevel(level: number): void;
  84344. /**
  84345. * Gets the current hardware scaling level.
  84346. * By default the hardware scaling level is computed from the window device ratio.
  84347. * 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.
  84348. * @returns a number indicating the current hardware scaling level
  84349. */
  84350. getHardwareScalingLevel(): number;
  84351. /**
  84352. * Gets the list of loaded textures
  84353. * @returns an array containing all loaded textures
  84354. */
  84355. getLoadedTexturesCache(): InternalTexture[];
  84356. /**
  84357. * Gets the object containing all engine capabilities
  84358. * @returns the EngineCapabilities object
  84359. */
  84360. getCaps(): EngineCapabilities;
  84361. /**
  84362. * Gets the current depth function
  84363. * @returns a number defining the depth function
  84364. */
  84365. getDepthFunction(): Nullable<number>;
  84366. /**
  84367. * Sets the current depth function
  84368. * @param depthFunc defines the function to use
  84369. */
  84370. setDepthFunction(depthFunc: number): void;
  84371. /**
  84372. * Sets the current depth function to GREATER
  84373. */
  84374. setDepthFunctionToGreater(): void;
  84375. /**
  84376. * Sets the current depth function to GEQUAL
  84377. */
  84378. setDepthFunctionToGreaterOrEqual(): void;
  84379. /**
  84380. * Sets the current depth function to LESS
  84381. */
  84382. setDepthFunctionToLess(): void;
  84383. /**
  84384. * Sets the current depth function to LEQUAL
  84385. */
  84386. setDepthFunctionToLessOrEqual(): void;
  84387. /**
  84388. * Gets a boolean indicating if stencil buffer is enabled
  84389. * @returns the current stencil buffer state
  84390. */
  84391. getStencilBuffer(): boolean;
  84392. /**
  84393. * Enable or disable the stencil buffer
  84394. * @param enable defines if the stencil buffer must be enabled or disabled
  84395. */
  84396. setStencilBuffer(enable: boolean): void;
  84397. /**
  84398. * Gets the current stencil mask
  84399. * @returns a number defining the new stencil mask to use
  84400. */
  84401. getStencilMask(): number;
  84402. /**
  84403. * Sets the current stencil mask
  84404. * @param mask defines the new stencil mask to use
  84405. */
  84406. setStencilMask(mask: number): void;
  84407. /**
  84408. * Gets the current stencil function
  84409. * @returns a number defining the stencil function to use
  84410. */
  84411. getStencilFunction(): number;
  84412. /**
  84413. * Gets the current stencil reference value
  84414. * @returns a number defining the stencil reference value to use
  84415. */
  84416. getStencilFunctionReference(): number;
  84417. /**
  84418. * Gets the current stencil mask
  84419. * @returns a number defining the stencil mask to use
  84420. */
  84421. getStencilFunctionMask(): number;
  84422. /**
  84423. * Sets the current stencil function
  84424. * @param stencilFunc defines the new stencil function to use
  84425. */
  84426. setStencilFunction(stencilFunc: number): void;
  84427. /**
  84428. * Sets the current stencil reference
  84429. * @param reference defines the new stencil reference to use
  84430. */
  84431. setStencilFunctionReference(reference: number): void;
  84432. /**
  84433. * Sets the current stencil mask
  84434. * @param mask defines the new stencil mask to use
  84435. */
  84436. setStencilFunctionMask(mask: number): void;
  84437. /**
  84438. * Gets the current stencil operation when stencil fails
  84439. * @returns a number defining stencil operation to use when stencil fails
  84440. */
  84441. getStencilOperationFail(): number;
  84442. /**
  84443. * Gets the current stencil operation when depth fails
  84444. * @returns a number defining stencil operation to use when depth fails
  84445. */
  84446. getStencilOperationDepthFail(): number;
  84447. /**
  84448. * Gets the current stencil operation when stencil passes
  84449. * @returns a number defining stencil operation to use when stencil passes
  84450. */
  84451. getStencilOperationPass(): number;
  84452. /**
  84453. * Sets the stencil operation to use when stencil fails
  84454. * @param operation defines the stencil operation to use when stencil fails
  84455. */
  84456. setStencilOperationFail(operation: number): void;
  84457. /**
  84458. * Sets the stencil operation to use when depth fails
  84459. * @param operation defines the stencil operation to use when depth fails
  84460. */
  84461. setStencilOperationDepthFail(operation: number): void;
  84462. /**
  84463. * Sets the stencil operation to use when stencil passes
  84464. * @param operation defines the stencil operation to use when stencil passes
  84465. */
  84466. setStencilOperationPass(operation: number): void;
  84467. /**
  84468. * Sets a boolean indicating if the dithering state is enabled or disabled
  84469. * @param value defines the dithering state
  84470. */
  84471. setDitheringState(value: boolean): void;
  84472. /**
  84473. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  84474. * @param value defines the rasterizer state
  84475. */
  84476. setRasterizerState(value: boolean): void;
  84477. /**
  84478. * stop executing a render loop function and remove it from the execution array
  84479. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  84480. */
  84481. stopRenderLoop(renderFunction?: () => void): void;
  84482. /** @hidden */
  84483. _renderLoop(): void;
  84484. /**
  84485. * Register and execute a render loop. The engine can have more than one render function
  84486. * @param renderFunction defines the function to continuously execute
  84487. */
  84488. runRenderLoop(renderFunction: () => void): void;
  84489. /**
  84490. * Toggle full screen mode
  84491. * @param requestPointerLock defines if a pointer lock should be requested from the user
  84492. */
  84493. switchFullscreen(requestPointerLock: boolean): void;
  84494. /**
  84495. * Enters full screen mode
  84496. * @param requestPointerLock defines if a pointer lock should be requested from the user
  84497. */
  84498. enterFullscreen(requestPointerLock: boolean): void;
  84499. /**
  84500. * Exits full screen mode
  84501. */
  84502. exitFullscreen(): void;
  84503. /**
  84504. * Clear the current render buffer or the current render target (if any is set up)
  84505. * @param color defines the color to use
  84506. * @param backBuffer defines if the back buffer must be cleared
  84507. * @param depth defines if the depth buffer must be cleared
  84508. * @param stencil defines if the stencil buffer must be cleared
  84509. */
  84510. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  84511. /**
  84512. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  84513. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  84514. * @param y defines the y-coordinate of the corner of the clear rectangle
  84515. * @param width defines the width of the clear rectangle
  84516. * @param height defines the height of the clear rectangle
  84517. * @param clearColor defines the clear color
  84518. */
  84519. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  84520. /**
  84521. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  84522. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  84523. * @param y defines the y-coordinate of the corner of the clear rectangle
  84524. * @param width defines the width of the clear rectangle
  84525. * @param height defines the height of the clear rectangle
  84526. */
  84527. enableScissor(x: number, y: number, width: number, height: number): void;
  84528. /**
  84529. * Disable previously set scissor test rectangle
  84530. */
  84531. disableScissor(): void;
  84532. private _viewportCached;
  84533. /** @hidden */
  84534. _viewport(x: number, y: number, width: number, height: number): void;
  84535. /**
  84536. * Set the WebGL's viewport
  84537. * @param viewport defines the viewport element to be used
  84538. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  84539. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  84540. */
  84541. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  84542. /**
  84543. * Directly set the WebGL Viewport
  84544. * @param x defines the x coordinate of the viewport (in screen space)
  84545. * @param y defines the y coordinate of the viewport (in screen space)
  84546. * @param width defines the width of the viewport (in screen space)
  84547. * @param height defines the height of the viewport (in screen space)
  84548. * @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
  84549. */
  84550. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  84551. /**
  84552. * Begin a new frame
  84553. */
  84554. beginFrame(): void;
  84555. /**
  84556. * Enf the current frame
  84557. */
  84558. endFrame(): void;
  84559. /**
  84560. * Resize the view according to the canvas' size
  84561. */
  84562. resize(): void;
  84563. /**
  84564. * Force a specific size of the canvas
  84565. * @param width defines the new canvas' width
  84566. * @param height defines the new canvas' height
  84567. */
  84568. setSize(width: number, height: number): void;
  84569. /**
  84570. * Gets a boolean indicating if a webVR device was detected
  84571. * @returns true if a webVR device was detected
  84572. */
  84573. isVRDevicePresent(): boolean;
  84574. /**
  84575. * Gets the current webVR device
  84576. * @returns the current webVR device (or null)
  84577. */
  84578. getVRDevice(): any;
  84579. /**
  84580. * Initializes a webVR display and starts listening to display change events
  84581. * The onVRDisplayChangedObservable will be notified upon these changes
  84582. * @returns The onVRDisplayChangedObservable
  84583. */
  84584. initWebVR(): Observable<IDisplayChangedEventArgs>;
  84585. /**
  84586. * Initializes a webVR display and starts listening to display change events
  84587. * The onVRDisplayChangedObservable will be notified upon these changes
  84588. * @returns A promise containing a VRDisplay and if vr is supported
  84589. */
  84590. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  84591. /**
  84592. * Call this function to switch to webVR mode
  84593. * Will do nothing if webVR is not supported or if there is no webVR device
  84594. * @see http://doc.babylonjs.com/how_to/webvr_camera
  84595. */
  84596. enableVR(): void;
  84597. /**
  84598. * Call this function to leave webVR mode
  84599. * Will do nothing if webVR is not supported or if there is no webVR device
  84600. * @see http://doc.babylonjs.com/how_to/webvr_camera
  84601. */
  84602. disableVR(): void;
  84603. private _onVRFullScreenTriggered;
  84604. private _getVRDisplaysAsync;
  84605. /**
  84606. * Binds the frame buffer to the specified texture.
  84607. * @param texture The texture to render to or null for the default canvas
  84608. * @param faceIndex The face of the texture to render to in case of cube texture
  84609. * @param requiredWidth The width of the target to render to
  84610. * @param requiredHeight The height of the target to render to
  84611. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  84612. * @param depthStencilTexture The depth stencil texture to use to render
  84613. * @param lodLevel defines le lod level to bind to the frame buffer
  84614. */
  84615. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  84616. private bindUnboundFramebuffer;
  84617. /**
  84618. * Unbind the current render target texture from the webGL context
  84619. * @param texture defines the render target texture to unbind
  84620. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  84621. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  84622. */
  84623. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  84624. /**
  84625. * Unbind a list of render target textures from the webGL context
  84626. * This is used only when drawBuffer extension or webGL2 are active
  84627. * @param textures defines the render target textures to unbind
  84628. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  84629. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  84630. */
  84631. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  84632. /**
  84633. * Force the mipmap generation for the given render target texture
  84634. * @param texture defines the render target texture to use
  84635. */
  84636. generateMipMapsForCubemap(texture: InternalTexture): void;
  84637. /**
  84638. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  84639. */
  84640. flushFramebuffer(): void;
  84641. /**
  84642. * Unbind the current render target and bind the default framebuffer
  84643. */
  84644. restoreDefaultFramebuffer(): void;
  84645. /**
  84646. * Create an uniform buffer
  84647. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  84648. * @param elements defines the content of the uniform buffer
  84649. * @returns the webGL uniform buffer
  84650. */
  84651. createUniformBuffer(elements: FloatArray): WebGLBuffer;
  84652. /**
  84653. * Create a dynamic uniform buffer
  84654. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  84655. * @param elements defines the content of the uniform buffer
  84656. * @returns the webGL uniform buffer
  84657. */
  84658. createDynamicUniformBuffer(elements: FloatArray): WebGLBuffer;
  84659. /**
  84660. * Update an existing uniform buffer
  84661. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  84662. * @param uniformBuffer defines the target uniform buffer
  84663. * @param elements defines the content to update
  84664. * @param offset defines the offset in the uniform buffer where update should start
  84665. * @param count defines the size of the data to update
  84666. */
  84667. updateUniformBuffer(uniformBuffer: WebGLBuffer, elements: FloatArray, offset?: number, count?: number): void;
  84668. private _resetVertexBufferBinding;
  84669. /**
  84670. * Creates a vertex buffer
  84671. * @param data the data for the vertex buffer
  84672. * @returns the new WebGL static buffer
  84673. */
  84674. createVertexBuffer(data: DataArray): WebGLBuffer;
  84675. /**
  84676. * Creates a dynamic vertex buffer
  84677. * @param data the data for the dynamic vertex buffer
  84678. * @returns the new WebGL dynamic buffer
  84679. */
  84680. createDynamicVertexBuffer(data: DataArray): WebGLBuffer;
  84681. /**
  84682. * Update a dynamic index buffer
  84683. * @param indexBuffer defines the target index buffer
  84684. * @param indices defines the data to update
  84685. * @param offset defines the offset in the target index buffer where update should start
  84686. */
  84687. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  84688. /**
  84689. * Updates a dynamic vertex buffer.
  84690. * @param vertexBuffer the vertex buffer to update
  84691. * @param data the data used to update the vertex buffer
  84692. * @param byteOffset the byte offset of the data
  84693. * @param byteLength the byte length of the data
  84694. */
  84695. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  84696. private _resetIndexBufferBinding;
  84697. /**
  84698. * Creates a new index buffer
  84699. * @param indices defines the content of the index buffer
  84700. * @param updatable defines if the index buffer must be updatable
  84701. * @returns a new webGL buffer
  84702. */
  84703. createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer;
  84704. /**
  84705. * Bind a webGL buffer to the webGL context
  84706. * @param buffer defines the buffer to bind
  84707. */
  84708. bindArrayBuffer(buffer: Nullable<WebGLBuffer>): void;
  84709. /**
  84710. * Bind an uniform buffer to the current webGL context
  84711. * @param buffer defines the buffer to bind
  84712. */
  84713. bindUniformBuffer(buffer: Nullable<WebGLBuffer>): void;
  84714. /**
  84715. * Bind a buffer to the current webGL context at a given location
  84716. * @param buffer defines the buffer to bind
  84717. * @param location defines the index where to bind the buffer
  84718. */
  84719. bindUniformBufferBase(buffer: WebGLBuffer, location: number): void;
  84720. /**
  84721. * Bind a specific block at a given index in a specific shader program
  84722. * @param shaderProgram defines the shader program
  84723. * @param blockName defines the block name
  84724. * @param index defines the index where to bind the block
  84725. */
  84726. bindUniformBlock(shaderProgram: WebGLProgram, blockName: string, index: number): void;
  84727. private bindIndexBuffer;
  84728. private bindBuffer;
  84729. /**
  84730. * update the bound buffer with the given data
  84731. * @param data defines the data to update
  84732. */
  84733. updateArrayBuffer(data: Float32Array): void;
  84734. private _vertexAttribPointer;
  84735. private _bindIndexBufferWithCache;
  84736. private _bindVertexBuffersAttributes;
  84737. /**
  84738. * Records a vertex array object
  84739. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  84740. * @param vertexBuffers defines the list of vertex buffers to store
  84741. * @param indexBuffer defines the index buffer to store
  84742. * @param effect defines the effect to store
  84743. * @returns the new vertex array object
  84744. */
  84745. recordVertexArrayObject(vertexBuffers: {
  84746. [key: string]: VertexBuffer;
  84747. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): WebGLVertexArrayObject;
  84748. /**
  84749. * Bind a specific vertex array object
  84750. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  84751. * @param vertexArrayObject defines the vertex array object to bind
  84752. * @param indexBuffer defines the index buffer to bind
  84753. */
  84754. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<WebGLBuffer>): void;
  84755. /**
  84756. * Bind webGl buffers directly to the webGL context
  84757. * @param vertexBuffer defines the vertex buffer to bind
  84758. * @param indexBuffer defines the index buffer to bind
  84759. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  84760. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  84761. * @param effect defines the effect associated with the vertex buffer
  84762. */
  84763. bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  84764. private _unbindVertexArrayObject;
  84765. /**
  84766. * Bind a list of vertex buffers to the webGL context
  84767. * @param vertexBuffers defines the list of vertex buffers to bind
  84768. * @param indexBuffer defines the index buffer to bind
  84769. * @param effect defines the effect associated with the vertex buffers
  84770. */
  84771. bindBuffers(vertexBuffers: {
  84772. [key: string]: Nullable<VertexBuffer>;
  84773. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): void;
  84774. /**
  84775. * Unbind all instance attributes
  84776. */
  84777. unbindInstanceAttributes(): void;
  84778. /**
  84779. * Release and free the memory of a vertex array object
  84780. * @param vao defines the vertex array object to delete
  84781. */
  84782. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  84783. /** @hidden */
  84784. _releaseBuffer(buffer: WebGLBuffer): boolean;
  84785. /**
  84786. * Creates a webGL buffer to use with instanciation
  84787. * @param capacity defines the size of the buffer
  84788. * @returns the webGL buffer
  84789. */
  84790. createInstancesBuffer(capacity: number): WebGLBuffer;
  84791. /**
  84792. * Delete a webGL buffer used with instanciation
  84793. * @param buffer defines the webGL buffer to delete
  84794. */
  84795. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  84796. /**
  84797. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  84798. * @param instancesBuffer defines the webGL buffer to update and bind
  84799. * @param data defines the data to store in the buffer
  84800. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  84801. */
  84802. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  84803. /**
  84804. * Apply all cached states (depth, culling, stencil and alpha)
  84805. */
  84806. applyStates(): void;
  84807. /**
  84808. * Send a draw order
  84809. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  84810. * @param indexStart defines the starting index
  84811. * @param indexCount defines the number of index to draw
  84812. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  84813. */
  84814. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  84815. /**
  84816. * Draw a list of points
  84817. * @param verticesStart defines the index of first vertex to draw
  84818. * @param verticesCount defines the count of vertices to draw
  84819. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  84820. */
  84821. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  84822. /**
  84823. * Draw a list of unindexed primitives
  84824. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  84825. * @param verticesStart defines the index of first vertex to draw
  84826. * @param verticesCount defines the count of vertices to draw
  84827. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  84828. */
  84829. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  84830. /**
  84831. * Draw a list of indexed primitives
  84832. * @param fillMode defines the primitive to use
  84833. * @param indexStart defines the starting index
  84834. * @param indexCount defines the number of index to draw
  84835. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  84836. */
  84837. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  84838. /**
  84839. * Draw a list of unindexed primitives
  84840. * @param fillMode defines the primitive to use
  84841. * @param verticesStart defines the index of first vertex to draw
  84842. * @param verticesCount defines the count of vertices to draw
  84843. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  84844. */
  84845. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  84846. private _drawMode;
  84847. /** @hidden */
  84848. _releaseEffect(effect: Effect): void;
  84849. /** @hidden */
  84850. _deleteProgram(program: WebGLProgram): void;
  84851. /**
  84852. * Create a new effect (used to store vertex/fragment shaders)
  84853. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  84854. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  84855. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  84856. * @param samplers defines an array of string used to represent textures
  84857. * @param defines defines the string containing the defines to use to compile the shaders
  84858. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  84859. * @param onCompiled defines a function to call when the effect creation is successful
  84860. * @param onError defines a function to call when the effect creation has failed
  84861. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  84862. * @returns the new Effect
  84863. */
  84864. 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;
  84865. private _compileShader;
  84866. private _compileRawShader;
  84867. /**
  84868. * Directly creates a webGL program
  84869. * @param vertexCode defines the vertex shader code to use
  84870. * @param fragmentCode defines the fragment shader code to use
  84871. * @param context defines the webGL context to use (if not set, the current one will be used)
  84872. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  84873. * @returns the new webGL program
  84874. */
  84875. createRawShaderProgram(vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  84876. /**
  84877. * Creates a webGL program
  84878. * @param vertexCode defines the vertex shader code to use
  84879. * @param fragmentCode defines the fragment shader code to use
  84880. * @param defines defines the string containing the defines to use to compile the shaders
  84881. * @param context defines the webGL context to use (if not set, the current one will be used)
  84882. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  84883. * @returns the new webGL program
  84884. */
  84885. createShaderProgram(vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  84886. private _createShaderProgram;
  84887. private _finalizeProgram;
  84888. /** @hidden */
  84889. _isProgramCompiled(shaderProgram: WebGLProgram): boolean;
  84890. /** @hidden */
  84891. _executeWhenProgramIsCompiled(shaderProgram: WebGLProgram, action: () => void): void;
  84892. /**
  84893. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  84894. * @param shaderProgram defines the webGL program to use
  84895. * @param uniformsNames defines the list of uniform names
  84896. * @returns an array of webGL uniform locations
  84897. */
  84898. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  84899. /**
  84900. * Gets the lsit of active attributes for a given webGL program
  84901. * @param shaderProgram defines the webGL program to use
  84902. * @param attributesNames defines the list of attribute names to get
  84903. * @returns an array of indices indicating the offset of each attribute
  84904. */
  84905. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  84906. /**
  84907. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  84908. * @param effect defines the effect to activate
  84909. */
  84910. enableEffect(effect: Nullable<Effect>): void;
  84911. /**
  84912. * Set the value of an uniform to an array of int32
  84913. * @param uniform defines the webGL uniform location where to store the value
  84914. * @param array defines the array of int32 to store
  84915. */
  84916. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  84917. /**
  84918. * Set the value of an uniform to an array of int32 (stored as vec2)
  84919. * @param uniform defines the webGL uniform location where to store the value
  84920. * @param array defines the array of int32 to store
  84921. */
  84922. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  84923. /**
  84924. * Set the value of an uniform to an array of int32 (stored as vec3)
  84925. * @param uniform defines the webGL uniform location where to store the value
  84926. * @param array defines the array of int32 to store
  84927. */
  84928. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  84929. /**
  84930. * Set the value of an uniform to an array of int32 (stored as vec4)
  84931. * @param uniform defines the webGL uniform location where to store the value
  84932. * @param array defines the array of int32 to store
  84933. */
  84934. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  84935. /**
  84936. * Set the value of an uniform to an array of float32
  84937. * @param uniform defines the webGL uniform location where to store the value
  84938. * @param array defines the array of float32 to store
  84939. */
  84940. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  84941. /**
  84942. * Set the value of an uniform to an array of float32 (stored as vec2)
  84943. * @param uniform defines the webGL uniform location where to store the value
  84944. * @param array defines the array of float32 to store
  84945. */
  84946. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  84947. /**
  84948. * Set the value of an uniform to an array of float32 (stored as vec3)
  84949. * @param uniform defines the webGL uniform location where to store the value
  84950. * @param array defines the array of float32 to store
  84951. */
  84952. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  84953. /**
  84954. * Set the value of an uniform to an array of float32 (stored as vec4)
  84955. * @param uniform defines the webGL uniform location where to store the value
  84956. * @param array defines the array of float32 to store
  84957. */
  84958. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  84959. /**
  84960. * Set the value of an uniform to an array of number
  84961. * @param uniform defines the webGL uniform location where to store the value
  84962. * @param array defines the array of number to store
  84963. */
  84964. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  84965. /**
  84966. * Set the value of an uniform to an array of number (stored as vec2)
  84967. * @param uniform defines the webGL uniform location where to store the value
  84968. * @param array defines the array of number to store
  84969. */
  84970. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  84971. /**
  84972. * Set the value of an uniform to an array of number (stored as vec3)
  84973. * @param uniform defines the webGL uniform location where to store the value
  84974. * @param array defines the array of number to store
  84975. */
  84976. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  84977. /**
  84978. * Set the value of an uniform to an array of number (stored as vec4)
  84979. * @param uniform defines the webGL uniform location where to store the value
  84980. * @param array defines the array of number to store
  84981. */
  84982. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  84983. /**
  84984. * Set the value of an uniform to an array of float32 (stored as matrices)
  84985. * @param uniform defines the webGL uniform location where to store the value
  84986. * @param matrices defines the array of float32 to store
  84987. */
  84988. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  84989. /**
  84990. * Set the value of an uniform to a matrix
  84991. * @param uniform defines the webGL uniform location where to store the value
  84992. * @param matrix defines the matrix to store
  84993. */
  84994. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  84995. /**
  84996. * Set the value of an uniform to a matrix (3x3)
  84997. * @param uniform defines the webGL uniform location where to store the value
  84998. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  84999. */
  85000. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  85001. /**
  85002. * Set the value of an uniform to a matrix (2x2)
  85003. * @param uniform defines the webGL uniform location where to store the value
  85004. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  85005. */
  85006. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  85007. /**
  85008. * Set the value of an uniform to a number (int)
  85009. * @param uniform defines the webGL uniform location where to store the value
  85010. * @param value defines the int number to store
  85011. */
  85012. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  85013. /**
  85014. * Set the value of an uniform to a number (float)
  85015. * @param uniform defines the webGL uniform location where to store the value
  85016. * @param value defines the float number to store
  85017. */
  85018. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  85019. /**
  85020. * Set the value of an uniform to a vec2
  85021. * @param uniform defines the webGL uniform location where to store the value
  85022. * @param x defines the 1st component of the value
  85023. * @param y defines the 2nd component of the value
  85024. */
  85025. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  85026. /**
  85027. * Set the value of an uniform to a vec3
  85028. * @param uniform defines the webGL uniform location where to store the value
  85029. * @param x defines the 1st component of the value
  85030. * @param y defines the 2nd component of the value
  85031. * @param z defines the 3rd component of the value
  85032. */
  85033. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  85034. /**
  85035. * Set the value of an uniform to a boolean
  85036. * @param uniform defines the webGL uniform location where to store the value
  85037. * @param bool defines the boolean to store
  85038. */
  85039. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  85040. /**
  85041. * Set the value of an uniform to a vec4
  85042. * @param uniform defines the webGL uniform location where to store the value
  85043. * @param x defines the 1st component of the value
  85044. * @param y defines the 2nd component of the value
  85045. * @param z defines the 3rd component of the value
  85046. * @param w defines the 4th component of the value
  85047. */
  85048. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  85049. /**
  85050. * Set the value of an uniform to a Color3
  85051. * @param uniform defines the webGL uniform location where to store the value
  85052. * @param color3 defines the color to store
  85053. */
  85054. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  85055. /**
  85056. * Set the value of an uniform to a Color3 and an alpha value
  85057. * @param uniform defines the webGL uniform location where to store the value
  85058. * @param color3 defines the color to store
  85059. * @param alpha defines the alpha component to store
  85060. */
  85061. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  85062. /**
  85063. * Sets a Color4 on a uniform variable
  85064. * @param uniform defines the uniform location
  85065. * @param color4 defines the value to be set
  85066. */
  85067. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  85068. /**
  85069. * Set various states to the webGL context
  85070. * @param culling defines backface culling state
  85071. * @param zOffset defines the value to apply to zOffset (0 by default)
  85072. * @param force defines if states must be applied even if cache is up to date
  85073. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  85074. */
  85075. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  85076. /**
  85077. * Set the z offset to apply to current rendering
  85078. * @param value defines the offset to apply
  85079. */
  85080. setZOffset(value: number): void;
  85081. /**
  85082. * Gets the current value of the zOffset
  85083. * @returns the current zOffset state
  85084. */
  85085. getZOffset(): number;
  85086. /**
  85087. * Enable or disable depth buffering
  85088. * @param enable defines the state to set
  85089. */
  85090. setDepthBuffer(enable: boolean): void;
  85091. /**
  85092. * Gets a boolean indicating if depth writing is enabled
  85093. * @returns the current depth writing state
  85094. */
  85095. getDepthWrite(): boolean;
  85096. /**
  85097. * Enable or disable depth writing
  85098. * @param enable defines the state to set
  85099. */
  85100. setDepthWrite(enable: boolean): void;
  85101. /**
  85102. * Enable or disable color writing
  85103. * @param enable defines the state to set
  85104. */
  85105. setColorWrite(enable: boolean): void;
  85106. /**
  85107. * Gets a boolean indicating if color writing is enabled
  85108. * @returns the current color writing state
  85109. */
  85110. getColorWrite(): boolean;
  85111. /**
  85112. * Sets alpha constants used by some alpha blending modes
  85113. * @param r defines the red component
  85114. * @param g defines the green component
  85115. * @param b defines the blue component
  85116. * @param a defines the alpha component
  85117. */
  85118. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  85119. /**
  85120. * Sets the current alpha mode
  85121. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  85122. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  85123. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  85124. */
  85125. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  85126. /**
  85127. * Gets the current alpha mode
  85128. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  85129. * @returns the current alpha mode
  85130. */
  85131. getAlphaMode(): number;
  85132. /**
  85133. * Clears the list of texture accessible through engine.
  85134. * This can help preventing texture load conflict due to name collision.
  85135. */
  85136. clearInternalTexturesCache(): void;
  85137. /**
  85138. * Force the entire cache to be cleared
  85139. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  85140. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  85141. */
  85142. wipeCaches(bruteForce?: boolean): void;
  85143. /**
  85144. * Set the compressed texture format to use, based on the formats you have, and the formats
  85145. * supported by the hardware / browser.
  85146. *
  85147. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  85148. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  85149. * to API arguments needed to compressed textures. This puts the burden on the container
  85150. * generator to house the arcane code for determining these for current & future formats.
  85151. *
  85152. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  85153. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  85154. *
  85155. * Note: The result of this call is not taken into account when a texture is base64.
  85156. *
  85157. * @param formatsAvailable defines the list of those format families you have created
  85158. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  85159. *
  85160. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  85161. * @returns The extension selected.
  85162. */
  85163. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  85164. private _getSamplingParameters;
  85165. private _partialLoadImg;
  85166. private _cascadeLoadImgs;
  85167. /** @hidden */
  85168. _createTexture(): WebGLTexture;
  85169. /**
  85170. * Usually called from Texture.ts.
  85171. * Passed information to create a WebGLTexture
  85172. * @param urlArg defines a value which contains one of the following:
  85173. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  85174. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  85175. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  85176. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  85177. * @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)
  85178. * @param scene needed for loading to the correct scene
  85179. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  85180. * @param onLoad optional callback to be called upon successful completion
  85181. * @param onError optional callback to be called upon failure
  85182. * @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
  85183. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  85184. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  85185. * @param forcedExtension defines the extension to use to pick the right loader
  85186. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  85187. * @returns a InternalTexture for assignment back into BABYLON.Texture
  85188. */
  85189. 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;
  85190. private _rescaleTexture;
  85191. /**
  85192. * Update a raw texture
  85193. * @param texture defines the texture to update
  85194. * @param data defines the data to store in the texture
  85195. * @param format defines the format of the data
  85196. * @param invertY defines if data must be stored with Y axis inverted
  85197. * @param compression defines the compression used (null by default)
  85198. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  85199. */
  85200. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  85201. /**
  85202. * Creates a raw texture
  85203. * @param data defines the data to store in the texture
  85204. * @param width defines the width of the texture
  85205. * @param height defines the height of the texture
  85206. * @param format defines the format of the data
  85207. * @param generateMipMaps defines if the engine should generate the mip levels
  85208. * @param invertY defines if data must be stored with Y axis inverted
  85209. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  85210. * @param compression defines the compression used (null by default)
  85211. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  85212. * @returns the raw texture inside an InternalTexture
  85213. */
  85214. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  85215. private _unpackFlipYCached;
  85216. /**
  85217. * In case you are sharing the context with other applications, it might
  85218. * be interested to not cache the unpack flip y state to ensure a consistent
  85219. * value would be set.
  85220. */
  85221. enableUnpackFlipYCached: boolean;
  85222. /** @hidden */
  85223. _unpackFlipY(value: boolean): void;
  85224. /** @hidden */
  85225. _getUnpackAlignement(): number;
  85226. /**
  85227. * Creates a dynamic texture
  85228. * @param width defines the width of the texture
  85229. * @param height defines the height of the texture
  85230. * @param generateMipMaps defines if the engine should generate the mip levels
  85231. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  85232. * @returns the dynamic texture inside an InternalTexture
  85233. */
  85234. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  85235. /**
  85236. * Update the sampling mode of a given texture
  85237. * @param samplingMode defines the required sampling mode
  85238. * @param texture defines the texture to update
  85239. */
  85240. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  85241. /**
  85242. * Update the content of a dynamic texture
  85243. * @param texture defines the texture to update
  85244. * @param canvas defines the canvas containing the source
  85245. * @param invertY defines if data must be stored with Y axis inverted
  85246. * @param premulAlpha defines if alpha is stored as premultiplied
  85247. * @param format defines the format of the data
  85248. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  85249. */
  85250. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  85251. /**
  85252. * Update a video texture
  85253. * @param texture defines the texture to update
  85254. * @param video defines the video element to use
  85255. * @param invertY defines if data must be stored with Y axis inverted
  85256. */
  85257. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  85258. /**
  85259. * Updates a depth texture Comparison Mode and Function.
  85260. * If the comparison Function is equal to 0, the mode will be set to none.
  85261. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  85262. * @param texture The texture to set the comparison function for
  85263. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  85264. */
  85265. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  85266. private _setupDepthStencilTexture;
  85267. /**
  85268. * Creates a depth stencil texture.
  85269. * This is only available in WebGL 2 or with the depth texture extension available.
  85270. * @param size The size of face edge in the texture.
  85271. * @param options The options defining the texture.
  85272. * @returns The texture
  85273. */
  85274. createDepthStencilTexture(size: number | {
  85275. width: number;
  85276. height: number;
  85277. }, options: DepthTextureCreationOptions): InternalTexture;
  85278. /**
  85279. * Creates a depth stencil texture.
  85280. * This is only available in WebGL 2 or with the depth texture extension available.
  85281. * @param size The size of face edge in the texture.
  85282. * @param options The options defining the texture.
  85283. * @returns The texture
  85284. */
  85285. private _createDepthStencilTexture;
  85286. /**
  85287. * Creates a depth stencil cube texture.
  85288. * This is only available in WebGL 2.
  85289. * @param size The size of face edge in the cube texture.
  85290. * @param options The options defining the cube texture.
  85291. * @returns The cube texture
  85292. */
  85293. private _createDepthStencilCubeTexture;
  85294. /**
  85295. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  85296. * @param renderTarget The render target to set the frame buffer for
  85297. */
  85298. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  85299. /**
  85300. * Creates a new render target texture
  85301. * @param size defines the size of the texture
  85302. * @param options defines the options used to create the texture
  85303. * @returns a new render target texture stored in an InternalTexture
  85304. */
  85305. createRenderTargetTexture(size: number | {
  85306. width: number;
  85307. height: number;
  85308. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  85309. /**
  85310. * Create a multi render target texture
  85311. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  85312. * @param size defines the size of the texture
  85313. * @param options defines the creation options
  85314. * @returns the cube texture as an InternalTexture
  85315. */
  85316. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  85317. private _setupFramebufferDepthAttachments;
  85318. /**
  85319. * Updates the sample count of a render target texture
  85320. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  85321. * @param texture defines the texture to update
  85322. * @param samples defines the sample count to set
  85323. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  85324. */
  85325. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  85326. /**
  85327. * Update the sample count for a given multiple render target texture
  85328. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  85329. * @param textures defines the textures to update
  85330. * @param samples defines the sample count to set
  85331. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  85332. */
  85333. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  85334. /** @hidden */
  85335. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  85336. /** @hidden */
  85337. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  85338. /** @hidden */
  85339. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  85340. /** @hidden */
  85341. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  85342. /**
  85343. * Creates a new render target cube texture
  85344. * @param size defines the size of the texture
  85345. * @param options defines the options used to create the texture
  85346. * @returns a new render target cube texture stored in an InternalTexture
  85347. */
  85348. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  85349. /**
  85350. * Creates a cube texture
  85351. * @param rootUrl defines the url where the files to load is located
  85352. * @param scene defines the current scene
  85353. * @param files defines the list of files to load (1 per face)
  85354. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  85355. * @param onLoad defines an optional callback raised when the texture is loaded
  85356. * @param onError defines an optional callback raised if there is an issue to load the texture
  85357. * @param format defines the format of the data
  85358. * @param forcedExtension defines the extension to use to pick the right loader
  85359. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  85360. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  85361. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  85362. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  85363. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  85364. * @returns the cube texture as an InternalTexture
  85365. */
  85366. 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;
  85367. /**
  85368. * @hidden
  85369. */
  85370. _setCubeMapTextureParams(loadMipmap: boolean): void;
  85371. /**
  85372. * Update a raw cube texture
  85373. * @param texture defines the texture to udpdate
  85374. * @param data defines the data to store
  85375. * @param format defines the data format
  85376. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  85377. * @param invertY defines if data must be stored with Y axis inverted
  85378. * @param compression defines the compression used (null by default)
  85379. * @param level defines which level of the texture to update
  85380. */
  85381. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  85382. /**
  85383. * Creates a new raw cube texture
  85384. * @param data defines the array of data to use to create each face
  85385. * @param size defines the size of the textures
  85386. * @param format defines the format of the data
  85387. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  85388. * @param generateMipMaps defines if the engine should generate the mip levels
  85389. * @param invertY defines if data must be stored with Y axis inverted
  85390. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  85391. * @param compression defines the compression used (null by default)
  85392. * @returns the cube texture as an InternalTexture
  85393. */
  85394. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  85395. /**
  85396. * Creates a new raw cube texture from a specified url
  85397. * @param url defines the url where the data is located
  85398. * @param scene defines the current scene
  85399. * @param size defines the size of the textures
  85400. * @param format defines the format of the data
  85401. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  85402. * @param noMipmap defines if the engine should avoid generating the mip levels
  85403. * @param callback defines a callback used to extract texture data from loaded data
  85404. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  85405. * @param onLoad defines a callback called when texture is loaded
  85406. * @param onError defines a callback called if there is an error
  85407. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  85408. * @param invertY defines if data must be stored with Y axis inverted
  85409. * @returns the cube texture as an InternalTexture
  85410. */
  85411. 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;
  85412. /**
  85413. * Update a raw 3D texture
  85414. * @param texture defines the texture to update
  85415. * @param data defines the data to store
  85416. * @param format defines the data format
  85417. * @param invertY defines if data must be stored with Y axis inverted
  85418. * @param compression defines the used compression (can be null)
  85419. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  85420. */
  85421. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  85422. /**
  85423. * Creates a new raw 3D texture
  85424. * @param data defines the data used to create the texture
  85425. * @param width defines the width of the texture
  85426. * @param height defines the height of the texture
  85427. * @param depth defines the depth of the texture
  85428. * @param format defines the format of the texture
  85429. * @param generateMipMaps defines if the engine must generate mip levels
  85430. * @param invertY defines if data must be stored with Y axis inverted
  85431. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  85432. * @param compression defines the compressed used (can be null)
  85433. * @param textureType defines the compressed used (can be null)
  85434. * @returns a new raw 3D texture (stored in an InternalTexture)
  85435. */
  85436. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  85437. private _prepareWebGLTextureContinuation;
  85438. private _prepareWebGLTexture;
  85439. private _convertRGBtoRGBATextureData;
  85440. /** @hidden */
  85441. _releaseFramebufferObjects(texture: InternalTexture): void;
  85442. /** @hidden */
  85443. _releaseTexture(texture: InternalTexture): void;
  85444. private setProgram;
  85445. private _boundUniforms;
  85446. /**
  85447. * Binds an effect to the webGL context
  85448. * @param effect defines the effect to bind
  85449. */
  85450. bindSamplers(effect: Effect): void;
  85451. private _moveBoundTextureOnTop;
  85452. private _getCorrectTextureChannel;
  85453. private _linkTrackers;
  85454. private _removeDesignatedSlot;
  85455. private _activateCurrentTexture;
  85456. /** @hidden */
  85457. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  85458. /** @hidden */
  85459. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  85460. /**
  85461. * Sets a texture to the webGL context from a postprocess
  85462. * @param channel defines the channel to use
  85463. * @param postProcess defines the source postprocess
  85464. */
  85465. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  85466. /**
  85467. * Binds the output of the passed in post process to the texture channel specified
  85468. * @param channel The channel the texture should be bound to
  85469. * @param postProcess The post process which's output should be bound
  85470. */
  85471. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  85472. /**
  85473. * Unbind all textures from the webGL context
  85474. */
  85475. unbindAllTextures(): void;
  85476. /**
  85477. * Sets a texture to the according uniform.
  85478. * @param channel The texture channel
  85479. * @param uniform The uniform to set
  85480. * @param texture The texture to apply
  85481. */
  85482. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  85483. /**
  85484. * Sets a depth stencil texture from a render target to the according uniform.
  85485. * @param channel The texture channel
  85486. * @param uniform The uniform to set
  85487. * @param texture The render target texture containing the depth stencil texture to apply
  85488. */
  85489. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  85490. private _bindSamplerUniformToChannel;
  85491. private _getTextureWrapMode;
  85492. private _setTexture;
  85493. /**
  85494. * Sets an array of texture to the webGL context
  85495. * @param channel defines the channel where the texture array must be set
  85496. * @param uniform defines the associated uniform location
  85497. * @param textures defines the array of textures to bind
  85498. */
  85499. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  85500. /** @hidden */
  85501. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  85502. private _setTextureParameterFloat;
  85503. private _setTextureParameterInteger;
  85504. /**
  85505. * Reads pixels from the current frame buffer. Please note that this function can be slow
  85506. * @param x defines the x coordinate of the rectangle where pixels must be read
  85507. * @param y defines the y coordinate of the rectangle where pixels must be read
  85508. * @param width defines the width of the rectangle where pixels must be read
  85509. * @param height defines the height of the rectangle where pixels must be read
  85510. * @returns a Uint8Array containing RGBA colors
  85511. */
  85512. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  85513. /**
  85514. * Add an externaly attached data from its key.
  85515. * This method call will fail and return false, if such key already exists.
  85516. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  85517. * @param key the unique key that identifies the data
  85518. * @param data the data object to associate to the key for this Engine instance
  85519. * @return true if no such key were already present and the data was added successfully, false otherwise
  85520. */
  85521. addExternalData<T>(key: string, data: T): boolean;
  85522. /**
  85523. * Get an externaly attached data from its key
  85524. * @param key the unique key that identifies the data
  85525. * @return the associated data, if present (can be null), or undefined if not present
  85526. */
  85527. getExternalData<T>(key: string): T;
  85528. /**
  85529. * Get an externaly attached data from its key, create it using a factory if it's not already present
  85530. * @param key the unique key that identifies the data
  85531. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  85532. * @return the associated data, can be null if the factory returned null.
  85533. */
  85534. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  85535. /**
  85536. * Remove an externaly attached data from the Engine instance
  85537. * @param key the unique key that identifies the data
  85538. * @return true if the data was successfully removed, false if it doesn't exist
  85539. */
  85540. removeExternalData(key: string): boolean;
  85541. /**
  85542. * Unbind all vertex attributes from the webGL context
  85543. */
  85544. unbindAllAttributes(): void;
  85545. /**
  85546. * 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
  85547. */
  85548. releaseEffects(): void;
  85549. /**
  85550. * Dispose and release all associated resources
  85551. */
  85552. dispose(): void;
  85553. /**
  85554. * Display the loading screen
  85555. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  85556. */
  85557. displayLoadingUI(): void;
  85558. /**
  85559. * Hide the loading screen
  85560. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  85561. */
  85562. hideLoadingUI(): void;
  85563. /**
  85564. * Gets the current loading screen object
  85565. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  85566. */
  85567. /**
  85568. * Sets the current loading screen object
  85569. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  85570. */
  85571. loadingScreen: ILoadingScreen;
  85572. /**
  85573. * Sets the current loading screen text
  85574. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  85575. */
  85576. loadingUIText: string;
  85577. /**
  85578. * Sets the current loading screen background color
  85579. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  85580. */
  85581. loadingUIBackgroundColor: string;
  85582. /**
  85583. * Attach a new callback raised when context lost event is fired
  85584. * @param callback defines the callback to call
  85585. */
  85586. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  85587. /**
  85588. * Attach a new callback raised when context restored event is fired
  85589. * @param callback defines the callback to call
  85590. */
  85591. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  85592. /**
  85593. * Gets the source code of the vertex shader associated with a specific webGL program
  85594. * @param program defines the program to use
  85595. * @returns a string containing the source code of the vertex shader associated with the program
  85596. */
  85597. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  85598. /**
  85599. * Gets the source code of the fragment shader associated with a specific webGL program
  85600. * @param program defines the program to use
  85601. * @returns a string containing the source code of the fragment shader associated with the program
  85602. */
  85603. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  85604. /**
  85605. * Get the current error code of the webGL context
  85606. * @returns the error code
  85607. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  85608. */
  85609. getError(): number;
  85610. /**
  85611. * Gets the current framerate
  85612. * @returns a number representing the framerate
  85613. */
  85614. getFps(): number;
  85615. /**
  85616. * Gets the time spent between current and previous frame
  85617. * @returns a number representing the delta time in ms
  85618. */
  85619. getDeltaTime(): number;
  85620. private _measureFps;
  85621. /** @hidden */
  85622. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  85623. private _canRenderToFloatFramebuffer;
  85624. private _canRenderToHalfFloatFramebuffer;
  85625. private _canRenderToFramebuffer;
  85626. /** @hidden */
  85627. _getWebGLTextureType(type: number): number;
  85628. private _getInternalFormat;
  85629. /** @hidden */
  85630. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  85631. /** @hidden */
  85632. _getRGBAMultiSampleBufferFormat(type: number): number;
  85633. /** @hidden */
  85634. _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;
  85635. /** @hidden */
  85636. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  85637. private _partialLoadFile;
  85638. private _cascadeLoadFiles;
  85639. /**
  85640. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  85641. * @returns true if the engine can be created
  85642. * @ignorenaming
  85643. */
  85644. static isSupported(): boolean;
  85645. }
  85646. }
  85647. declare module BABYLON {
  85648. /**
  85649. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  85650. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  85651. */
  85652. export class EffectFallbacks {
  85653. private _defines;
  85654. private _currentRank;
  85655. private _maxRank;
  85656. private _mesh;
  85657. /**
  85658. * Removes the fallback from the bound mesh.
  85659. */
  85660. unBindMesh(): void;
  85661. /**
  85662. * Adds a fallback on the specified property.
  85663. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  85664. * @param define The name of the define in the shader
  85665. */
  85666. addFallback(rank: number, define: string): void;
  85667. /**
  85668. * Sets the mesh to use CPU skinning when needing to fallback.
  85669. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  85670. * @param mesh The mesh to use the fallbacks.
  85671. */
  85672. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  85673. /**
  85674. * Checks to see if more fallbacks are still availible.
  85675. */
  85676. readonly isMoreFallbacks: boolean;
  85677. /**
  85678. * Removes the defines that shoould be removed when falling back.
  85679. * @param currentDefines defines the current define statements for the shader.
  85680. * @param effect defines the current effect we try to compile
  85681. * @returns The resulting defines with defines of the current rank removed.
  85682. */
  85683. reduce(currentDefines: string, effect: Effect): string;
  85684. }
  85685. /**
  85686. * Options to be used when creating an effect.
  85687. */
  85688. export class EffectCreationOptions {
  85689. /**
  85690. * Atrributes that will be used in the shader.
  85691. */
  85692. attributes: string[];
  85693. /**
  85694. * Uniform varible names that will be set in the shader.
  85695. */
  85696. uniformsNames: string[];
  85697. /**
  85698. * Uniform buffer varible names that will be set in the shader.
  85699. */
  85700. uniformBuffersNames: string[];
  85701. /**
  85702. * Sampler texture variable names that will be set in the shader.
  85703. */
  85704. samplers: string[];
  85705. /**
  85706. * Define statements that will be set in the shader.
  85707. */
  85708. defines: any;
  85709. /**
  85710. * Possible fallbacks for this effect to improve performance when needed.
  85711. */
  85712. fallbacks: Nullable<EffectFallbacks>;
  85713. /**
  85714. * Callback that will be called when the shader is compiled.
  85715. */
  85716. onCompiled: Nullable<(effect: Effect) => void>;
  85717. /**
  85718. * Callback that will be called if an error occurs during shader compilation.
  85719. */
  85720. onError: Nullable<(effect: Effect, errors: string) => void>;
  85721. /**
  85722. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  85723. */
  85724. indexParameters: any;
  85725. /**
  85726. * Max number of lights that can be used in the shader.
  85727. */
  85728. maxSimultaneousLights: number;
  85729. /**
  85730. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  85731. */
  85732. transformFeedbackVaryings: Nullable<string[]>;
  85733. }
  85734. /**
  85735. * Effect containing vertex and fragment shader that can be executed on an object.
  85736. */
  85737. export class Effect {
  85738. /**
  85739. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  85740. */
  85741. static ShadersRepository: string;
  85742. /**
  85743. * Name of the effect.
  85744. */
  85745. name: any;
  85746. /**
  85747. * String container all the define statements that should be set on the shader.
  85748. */
  85749. defines: string;
  85750. /**
  85751. * Callback that will be called when the shader is compiled.
  85752. */
  85753. onCompiled: Nullable<(effect: Effect) => void>;
  85754. /**
  85755. * Callback that will be called if an error occurs during shader compilation.
  85756. */
  85757. onError: Nullable<(effect: Effect, errors: string) => void>;
  85758. /**
  85759. * Callback that will be called when effect is bound.
  85760. */
  85761. onBind: Nullable<(effect: Effect) => void>;
  85762. /**
  85763. * Unique ID of the effect.
  85764. */
  85765. uniqueId: number;
  85766. /**
  85767. * Observable that will be called when the shader is compiled.
  85768. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  85769. */
  85770. onCompileObservable: Observable<Effect>;
  85771. /**
  85772. * Observable that will be called if an error occurs during shader compilation.
  85773. */
  85774. onErrorObservable: Observable<Effect>;
  85775. /** @hidden */
  85776. _onBindObservable: Nullable<Observable<Effect>>;
  85777. /**
  85778. * Observable that will be called when effect is bound.
  85779. */
  85780. readonly onBindObservable: Observable<Effect>;
  85781. /** @hidden */
  85782. _bonesComputationForcedToCPU: boolean;
  85783. private static _uniqueIdSeed;
  85784. private _engine;
  85785. private _uniformBuffersNames;
  85786. private _uniformsNames;
  85787. private _samplers;
  85788. private _isReady;
  85789. private _compilationError;
  85790. private _attributesNames;
  85791. private _attributes;
  85792. private _uniforms;
  85793. /**
  85794. * Key for the effect.
  85795. * @hidden
  85796. */
  85797. _key: string;
  85798. private _indexParameters;
  85799. private _fallbacks;
  85800. private _vertexSourceCode;
  85801. private _fragmentSourceCode;
  85802. private _vertexSourceCodeOverride;
  85803. private _fragmentSourceCodeOverride;
  85804. private _transformFeedbackVaryings;
  85805. /**
  85806. * Compiled shader to webGL program.
  85807. * @hidden
  85808. */
  85809. _program: WebGLProgram;
  85810. private _valueCache;
  85811. private static _baseCache;
  85812. /**
  85813. * Instantiates an effect.
  85814. * An effect can be used to create/manage/execute vertex and fragment shaders.
  85815. * @param baseName Name of the effect.
  85816. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  85817. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  85818. * @param samplers List of sampler variables that will be passed to the shader.
  85819. * @param engine Engine to be used to render the effect
  85820. * @param defines Define statements to be added to the shader.
  85821. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  85822. * @param onCompiled Callback that will be called when the shader is compiled.
  85823. * @param onError Callback that will be called if an error occurs during shader compilation.
  85824. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  85825. */
  85826. 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);
  85827. /**
  85828. * Unique key for this effect
  85829. */
  85830. readonly key: string;
  85831. /**
  85832. * If the effect has been compiled and prepared.
  85833. * @returns if the effect is compiled and prepared.
  85834. */
  85835. isReady(): boolean;
  85836. /**
  85837. * The engine the effect was initialized with.
  85838. * @returns the engine.
  85839. */
  85840. getEngine(): Engine;
  85841. /**
  85842. * The compiled webGL program for the effect
  85843. * @returns the webGL program.
  85844. */
  85845. getProgram(): WebGLProgram;
  85846. /**
  85847. * The set of names of attribute variables for the shader.
  85848. * @returns An array of attribute names.
  85849. */
  85850. getAttributesNames(): string[];
  85851. /**
  85852. * Returns the attribute at the given index.
  85853. * @param index The index of the attribute.
  85854. * @returns The location of the attribute.
  85855. */
  85856. getAttributeLocation(index: number): number;
  85857. /**
  85858. * Returns the attribute based on the name of the variable.
  85859. * @param name of the attribute to look up.
  85860. * @returns the attribute location.
  85861. */
  85862. getAttributeLocationByName(name: string): number;
  85863. /**
  85864. * The number of attributes.
  85865. * @returns the numnber of attributes.
  85866. */
  85867. getAttributesCount(): number;
  85868. /**
  85869. * Gets the index of a uniform variable.
  85870. * @param uniformName of the uniform to look up.
  85871. * @returns the index.
  85872. */
  85873. getUniformIndex(uniformName: string): number;
  85874. /**
  85875. * Returns the attribute based on the name of the variable.
  85876. * @param uniformName of the uniform to look up.
  85877. * @returns the location of the uniform.
  85878. */
  85879. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  85880. /**
  85881. * Returns an array of sampler variable names
  85882. * @returns The array of sampler variable neames.
  85883. */
  85884. getSamplers(): string[];
  85885. /**
  85886. * The error from the last compilation.
  85887. * @returns the error string.
  85888. */
  85889. getCompilationError(): string;
  85890. /**
  85891. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  85892. * @param func The callback to be used.
  85893. */
  85894. executeWhenCompiled(func: (effect: Effect) => void): void;
  85895. private _checkIsReady;
  85896. /** @hidden */
  85897. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  85898. /** @hidden */
  85899. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  85900. /** @hidden */
  85901. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  85902. private _processShaderConversion;
  85903. private _processIncludes;
  85904. private _processPrecision;
  85905. /**
  85906. * Recompiles the webGL program
  85907. * @param vertexSourceCode The source code for the vertex shader.
  85908. * @param fragmentSourceCode The source code for the fragment shader.
  85909. * @param onCompiled Callback called when completed.
  85910. * @param onError Callback called on error.
  85911. * @hidden
  85912. */
  85913. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void): void;
  85914. /**
  85915. * Gets the uniform locations of the the specified variable names
  85916. * @param names THe names of the variables to lookup.
  85917. * @returns Array of locations in the same order as variable names.
  85918. */
  85919. getSpecificUniformLocations(names: string[]): Nullable<WebGLUniformLocation>[];
  85920. /**
  85921. * Prepares the effect
  85922. * @hidden
  85923. */
  85924. _prepareEffect(): void;
  85925. /**
  85926. * Checks if the effect is supported. (Must be called after compilation)
  85927. */
  85928. readonly isSupported: boolean;
  85929. /**
  85930. * Binds a texture to the engine to be used as output of the shader.
  85931. * @param channel Name of the output variable.
  85932. * @param texture Texture to bind.
  85933. * @hidden
  85934. */
  85935. _bindTexture(channel: string, texture: InternalTexture): void;
  85936. /**
  85937. * Sets a texture on the engine to be used in the shader.
  85938. * @param channel Name of the sampler variable.
  85939. * @param texture Texture to set.
  85940. */
  85941. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  85942. /**
  85943. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  85944. * @param channel Name of the sampler variable.
  85945. * @param texture Texture to set.
  85946. */
  85947. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  85948. /**
  85949. * Sets an array of textures on the engine to be used in the shader.
  85950. * @param channel Name of the variable.
  85951. * @param textures Textures to set.
  85952. */
  85953. setTextureArray(channel: string, textures: BaseTexture[]): void;
  85954. /**
  85955. * 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)
  85956. * @param channel Name of the sampler variable.
  85957. * @param postProcess Post process to get the input texture from.
  85958. */
  85959. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  85960. /**
  85961. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  85962. * 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)
  85963. * @param channel Name of the sampler variable.
  85964. * @param postProcess Post process to get the output texture from.
  85965. */
  85966. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  85967. /** @hidden */
  85968. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  85969. /** @hidden */
  85970. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  85971. /** @hidden */
  85972. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  85973. /** @hidden */
  85974. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  85975. /**
  85976. * Binds a buffer to a uniform.
  85977. * @param buffer Buffer to bind.
  85978. * @param name Name of the uniform variable to bind to.
  85979. */
  85980. bindUniformBuffer(buffer: WebGLBuffer, name: string): void;
  85981. /**
  85982. * Binds block to a uniform.
  85983. * @param blockName Name of the block to bind.
  85984. * @param index Index to bind.
  85985. */
  85986. bindUniformBlock(blockName: string, index: number): void;
  85987. /**
  85988. * Sets an interger value on a uniform variable.
  85989. * @param uniformName Name of the variable.
  85990. * @param value Value to be set.
  85991. * @returns this effect.
  85992. */
  85993. setInt(uniformName: string, value: number): Effect;
  85994. /**
  85995. * Sets an int array on a uniform variable.
  85996. * @param uniformName Name of the variable.
  85997. * @param array array to be set.
  85998. * @returns this effect.
  85999. */
  86000. setIntArray(uniformName: string, array: Int32Array): Effect;
  86001. /**
  86002. * 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)
  86003. * @param uniformName Name of the variable.
  86004. * @param array array to be set.
  86005. * @returns this effect.
  86006. */
  86007. setIntArray2(uniformName: string, array: Int32Array): Effect;
  86008. /**
  86009. * 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)
  86010. * @param uniformName Name of the variable.
  86011. * @param array array to be set.
  86012. * @returns this effect.
  86013. */
  86014. setIntArray3(uniformName: string, array: Int32Array): Effect;
  86015. /**
  86016. * 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)
  86017. * @param uniformName Name of the variable.
  86018. * @param array array to be set.
  86019. * @returns this effect.
  86020. */
  86021. setIntArray4(uniformName: string, array: Int32Array): Effect;
  86022. /**
  86023. * Sets an float array on a uniform variable.
  86024. * @param uniformName Name of the variable.
  86025. * @param array array to be set.
  86026. * @returns this effect.
  86027. */
  86028. setFloatArray(uniformName: string, array: Float32Array): Effect;
  86029. /**
  86030. * 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)
  86031. * @param uniformName Name of the variable.
  86032. * @param array array to be set.
  86033. * @returns this effect.
  86034. */
  86035. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  86036. /**
  86037. * 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)
  86038. * @param uniformName Name of the variable.
  86039. * @param array array to be set.
  86040. * @returns this effect.
  86041. */
  86042. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  86043. /**
  86044. * 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)
  86045. * @param uniformName Name of the variable.
  86046. * @param array array to be set.
  86047. * @returns this effect.
  86048. */
  86049. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  86050. /**
  86051. * Sets an array on a uniform variable.
  86052. * @param uniformName Name of the variable.
  86053. * @param array array to be set.
  86054. * @returns this effect.
  86055. */
  86056. setArray(uniformName: string, array: number[]): Effect;
  86057. /**
  86058. * 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)
  86059. * @param uniformName Name of the variable.
  86060. * @param array array to be set.
  86061. * @returns this effect.
  86062. */
  86063. setArray2(uniformName: string, array: number[]): Effect;
  86064. /**
  86065. * 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)
  86066. * @param uniformName Name of the variable.
  86067. * @param array array to be set.
  86068. * @returns this effect.
  86069. */
  86070. setArray3(uniformName: string, array: number[]): Effect;
  86071. /**
  86072. * 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)
  86073. * @param uniformName Name of the variable.
  86074. * @param array array to be set.
  86075. * @returns this effect.
  86076. */
  86077. setArray4(uniformName: string, array: number[]): Effect;
  86078. /**
  86079. * Sets matrices on a uniform variable.
  86080. * @param uniformName Name of the variable.
  86081. * @param matrices matrices to be set.
  86082. * @returns this effect.
  86083. */
  86084. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  86085. /**
  86086. * Sets matrix on a uniform variable.
  86087. * @param uniformName Name of the variable.
  86088. * @param matrix matrix to be set.
  86089. * @returns this effect.
  86090. */
  86091. setMatrix(uniformName: string, matrix: Matrix): Effect;
  86092. /**
  86093. * 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)
  86094. * @param uniformName Name of the variable.
  86095. * @param matrix matrix to be set.
  86096. * @returns this effect.
  86097. */
  86098. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  86099. /**
  86100. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  86101. * @param uniformName Name of the variable.
  86102. * @param matrix matrix to be set.
  86103. * @returns this effect.
  86104. */
  86105. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  86106. /**
  86107. * Sets a float on a uniform variable.
  86108. * @param uniformName Name of the variable.
  86109. * @param value value to be set.
  86110. * @returns this effect.
  86111. */
  86112. setFloat(uniformName: string, value: number): Effect;
  86113. /**
  86114. * Sets a boolean on a uniform variable.
  86115. * @param uniformName Name of the variable.
  86116. * @param bool value to be set.
  86117. * @returns this effect.
  86118. */
  86119. setBool(uniformName: string, bool: boolean): Effect;
  86120. /**
  86121. * Sets a Vector2 on a uniform variable.
  86122. * @param uniformName Name of the variable.
  86123. * @param vector2 vector2 to be set.
  86124. * @returns this effect.
  86125. */
  86126. setVector2(uniformName: string, vector2: Vector2): Effect;
  86127. /**
  86128. * Sets a float2 on a uniform variable.
  86129. * @param uniformName Name of the variable.
  86130. * @param x First float in float2.
  86131. * @param y Second float in float2.
  86132. * @returns this effect.
  86133. */
  86134. setFloat2(uniformName: string, x: number, y: number): Effect;
  86135. /**
  86136. * Sets a Vector3 on a uniform variable.
  86137. * @param uniformName Name of the variable.
  86138. * @param vector3 Value to be set.
  86139. * @returns this effect.
  86140. */
  86141. setVector3(uniformName: string, vector3: Vector3): Effect;
  86142. /**
  86143. * Sets a float3 on a uniform variable.
  86144. * @param uniformName Name of the variable.
  86145. * @param x First float in float3.
  86146. * @param y Second float in float3.
  86147. * @param z Third float in float3.
  86148. * @returns this effect.
  86149. */
  86150. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  86151. /**
  86152. * Sets a Vector4 on a uniform variable.
  86153. * @param uniformName Name of the variable.
  86154. * @param vector4 Value to be set.
  86155. * @returns this effect.
  86156. */
  86157. setVector4(uniformName: string, vector4: Vector4): Effect;
  86158. /**
  86159. * Sets a float4 on a uniform variable.
  86160. * @param uniformName Name of the variable.
  86161. * @param x First float in float4.
  86162. * @param y Second float in float4.
  86163. * @param z Third float in float4.
  86164. * @param w Fourth float in float4.
  86165. * @returns this effect.
  86166. */
  86167. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  86168. /**
  86169. * Sets a Color3 on a uniform variable.
  86170. * @param uniformName Name of the variable.
  86171. * @param color3 Value to be set.
  86172. * @returns this effect.
  86173. */
  86174. setColor3(uniformName: string, color3: Color3): Effect;
  86175. /**
  86176. * Sets a Color4 on a uniform variable.
  86177. * @param uniformName Name of the variable.
  86178. * @param color3 Value to be set.
  86179. * @param alpha Alpha value to be set.
  86180. * @returns this effect.
  86181. */
  86182. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  86183. /**
  86184. * Sets a Color4 on a uniform variable
  86185. * @param uniformName defines the name of the variable
  86186. * @param color4 defines the value to be set
  86187. * @returns this effect.
  86188. */
  86189. setDirectColor4(uniformName: string, color4: Color4): Effect;
  86190. /**
  86191. * This function will add a new shader to the shader store
  86192. * @param name the name of the shader
  86193. * @param pixelShader optional pixel shader content
  86194. * @param vertexShader optional vertex shader content
  86195. */
  86196. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  86197. /**
  86198. * Store of each shader (The can be looked up using effect.key)
  86199. */
  86200. static ShadersStore: {
  86201. [key: string]: string;
  86202. };
  86203. /**
  86204. * Store of each included file for a shader (The can be looked up using effect.key)
  86205. */
  86206. static IncludesShadersStore: {
  86207. [key: string]: string;
  86208. };
  86209. /**
  86210. * Resets the cache of effects.
  86211. */
  86212. static ResetCache(): void;
  86213. }
  86214. }
  86215. declare module BABYLON {
  86216. /**
  86217. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  86218. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  86219. * 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;
  86220. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  86221. */
  86222. export class ColorCurves {
  86223. private _dirty;
  86224. private _tempColor;
  86225. private _globalCurve;
  86226. private _highlightsCurve;
  86227. private _midtonesCurve;
  86228. private _shadowsCurve;
  86229. private _positiveCurve;
  86230. private _negativeCurve;
  86231. private _globalHue;
  86232. private _globalDensity;
  86233. private _globalSaturation;
  86234. private _globalExposure;
  86235. /**
  86236. * Gets the global Hue value.
  86237. * 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).
  86238. */
  86239. /**
  86240. * Sets the global Hue value.
  86241. * 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).
  86242. */
  86243. globalHue: number;
  86244. /**
  86245. * Gets the global Density value.
  86246. * 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.
  86247. * Values less than zero provide a filter of opposite hue.
  86248. */
  86249. /**
  86250. * Sets the global Density value.
  86251. * 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.
  86252. * Values less than zero provide a filter of opposite hue.
  86253. */
  86254. globalDensity: number;
  86255. /**
  86256. * Gets the global Saturation value.
  86257. * 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.
  86258. */
  86259. /**
  86260. * Sets the global Saturation value.
  86261. * 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.
  86262. */
  86263. globalSaturation: number;
  86264. /**
  86265. * Gets the global Exposure value.
  86266. * 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.
  86267. */
  86268. /**
  86269. * Sets the global Exposure value.
  86270. * 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.
  86271. */
  86272. globalExposure: number;
  86273. private _highlightsHue;
  86274. private _highlightsDensity;
  86275. private _highlightsSaturation;
  86276. private _highlightsExposure;
  86277. /**
  86278. * Gets the highlights Hue value.
  86279. * 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).
  86280. */
  86281. /**
  86282. * Sets the highlights Hue value.
  86283. * 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).
  86284. */
  86285. highlightsHue: number;
  86286. /**
  86287. * Gets the highlights Density value.
  86288. * 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.
  86289. * Values less than zero provide a filter of opposite hue.
  86290. */
  86291. /**
  86292. * Sets the highlights Density value.
  86293. * 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.
  86294. * Values less than zero provide a filter of opposite hue.
  86295. */
  86296. highlightsDensity: number;
  86297. /**
  86298. * Gets the highlights Saturation value.
  86299. * 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.
  86300. */
  86301. /**
  86302. * Sets the highlights Saturation value.
  86303. * 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.
  86304. */
  86305. highlightsSaturation: number;
  86306. /**
  86307. * Gets the highlights Exposure value.
  86308. * 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.
  86309. */
  86310. /**
  86311. * Sets the highlights Exposure value.
  86312. * 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.
  86313. */
  86314. highlightsExposure: number;
  86315. private _midtonesHue;
  86316. private _midtonesDensity;
  86317. private _midtonesSaturation;
  86318. private _midtonesExposure;
  86319. /**
  86320. * Gets the midtones Hue value.
  86321. * 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).
  86322. */
  86323. /**
  86324. * Sets the midtones Hue value.
  86325. * 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).
  86326. */
  86327. midtonesHue: number;
  86328. /**
  86329. * Gets the midtones Density value.
  86330. * 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.
  86331. * Values less than zero provide a filter of opposite hue.
  86332. */
  86333. /**
  86334. * Sets the midtones Density value.
  86335. * 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.
  86336. * Values less than zero provide a filter of opposite hue.
  86337. */
  86338. midtonesDensity: number;
  86339. /**
  86340. * Gets the midtones Saturation value.
  86341. * 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.
  86342. */
  86343. /**
  86344. * Sets the midtones Saturation value.
  86345. * 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.
  86346. */
  86347. midtonesSaturation: number;
  86348. /**
  86349. * Gets the midtones Exposure value.
  86350. * 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.
  86351. */
  86352. /**
  86353. * Sets the midtones Exposure value.
  86354. * 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.
  86355. */
  86356. midtonesExposure: number;
  86357. private _shadowsHue;
  86358. private _shadowsDensity;
  86359. private _shadowsSaturation;
  86360. private _shadowsExposure;
  86361. /**
  86362. * Gets the shadows Hue value.
  86363. * 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).
  86364. */
  86365. /**
  86366. * Sets the shadows Hue value.
  86367. * 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).
  86368. */
  86369. shadowsHue: number;
  86370. /**
  86371. * Gets the shadows Density value.
  86372. * 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.
  86373. * Values less than zero provide a filter of opposite hue.
  86374. */
  86375. /**
  86376. * Sets the shadows Density value.
  86377. * 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.
  86378. * Values less than zero provide a filter of opposite hue.
  86379. */
  86380. shadowsDensity: number;
  86381. /**
  86382. * Gets the shadows Saturation value.
  86383. * 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.
  86384. */
  86385. /**
  86386. * Sets the shadows Saturation value.
  86387. * 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.
  86388. */
  86389. shadowsSaturation: number;
  86390. /**
  86391. * Gets the shadows Exposure value.
  86392. * 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.
  86393. */
  86394. /**
  86395. * Sets the shadows Exposure value.
  86396. * 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.
  86397. */
  86398. shadowsExposure: number;
  86399. /**
  86400. * Returns the class name
  86401. * @returns The class name
  86402. */
  86403. getClassName(): string;
  86404. /**
  86405. * Binds the color curves to the shader.
  86406. * @param colorCurves The color curve to bind
  86407. * @param effect The effect to bind to
  86408. * @param positiveUniform The positive uniform shader parameter
  86409. * @param neutralUniform The neutral uniform shader parameter
  86410. * @param negativeUniform The negative uniform shader parameter
  86411. */
  86412. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  86413. /**
  86414. * Prepare the list of uniforms associated with the ColorCurves effects.
  86415. * @param uniformsList The list of uniforms used in the effect
  86416. */
  86417. static PrepareUniforms(uniformsList: string[]): void;
  86418. /**
  86419. * Returns color grading data based on a hue, density, saturation and exposure value.
  86420. * @param filterHue The hue of the color filter.
  86421. * @param filterDensity The density of the color filter.
  86422. * @param saturation The saturation.
  86423. * @param exposure The exposure.
  86424. * @param result The result data container.
  86425. */
  86426. private getColorGradingDataToRef;
  86427. /**
  86428. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  86429. * @param value The input slider value in range [-100,100].
  86430. * @returns Adjusted value.
  86431. */
  86432. private static applyColorGradingSliderNonlinear;
  86433. /**
  86434. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  86435. * @param hue The hue (H) input.
  86436. * @param saturation The saturation (S) input.
  86437. * @param brightness The brightness (B) input.
  86438. * @result An RGBA color represented as Vector4.
  86439. */
  86440. private static fromHSBToRef;
  86441. /**
  86442. * Returns a value clamped between min and max
  86443. * @param value The value to clamp
  86444. * @param min The minimum of value
  86445. * @param max The maximum of value
  86446. * @returns The clamped value.
  86447. */
  86448. private static clamp;
  86449. /**
  86450. * Clones the current color curve instance.
  86451. * @return The cloned curves
  86452. */
  86453. clone(): ColorCurves;
  86454. /**
  86455. * Serializes the current color curve instance to a json representation.
  86456. * @return a JSON representation
  86457. */
  86458. serialize(): any;
  86459. /**
  86460. * Parses the color curve from a json representation.
  86461. * @param source the JSON source to parse
  86462. * @return The parsed curves
  86463. */
  86464. static Parse(source: any): ColorCurves;
  86465. }
  86466. }
  86467. declare module BABYLON {
  86468. /**
  86469. * Interface to follow in your material defines to integrate easily the
  86470. * Image proccessing functions.
  86471. * @hidden
  86472. */
  86473. export interface IImageProcessingConfigurationDefines {
  86474. IMAGEPROCESSING: boolean;
  86475. VIGNETTE: boolean;
  86476. VIGNETTEBLENDMODEMULTIPLY: boolean;
  86477. VIGNETTEBLENDMODEOPAQUE: boolean;
  86478. TONEMAPPING: boolean;
  86479. TONEMAPPING_ACES: boolean;
  86480. CONTRAST: boolean;
  86481. EXPOSURE: boolean;
  86482. COLORCURVES: boolean;
  86483. COLORGRADING: boolean;
  86484. COLORGRADING3D: boolean;
  86485. SAMPLER3DGREENDEPTH: boolean;
  86486. SAMPLER3DBGRMAP: boolean;
  86487. IMAGEPROCESSINGPOSTPROCESS: boolean;
  86488. }
  86489. /**
  86490. * @hidden
  86491. */
  86492. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  86493. IMAGEPROCESSING: boolean;
  86494. VIGNETTE: boolean;
  86495. VIGNETTEBLENDMODEMULTIPLY: boolean;
  86496. VIGNETTEBLENDMODEOPAQUE: boolean;
  86497. TONEMAPPING: boolean;
  86498. TONEMAPPING_ACES: boolean;
  86499. CONTRAST: boolean;
  86500. COLORCURVES: boolean;
  86501. COLORGRADING: boolean;
  86502. COLORGRADING3D: boolean;
  86503. SAMPLER3DGREENDEPTH: boolean;
  86504. SAMPLER3DBGRMAP: boolean;
  86505. IMAGEPROCESSINGPOSTPROCESS: boolean;
  86506. EXPOSURE: boolean;
  86507. constructor();
  86508. }
  86509. /**
  86510. * This groups together the common properties used for image processing either in direct forward pass
  86511. * or through post processing effect depending on the use of the image processing pipeline in your scene
  86512. * or not.
  86513. */
  86514. export class ImageProcessingConfiguration {
  86515. /**
  86516. * Default tone mapping applied in BabylonJS.
  86517. */
  86518. static readonly TONEMAPPING_STANDARD: number;
  86519. /**
  86520. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  86521. * to other engines rendering to increase portability.
  86522. */
  86523. static readonly TONEMAPPING_ACES: number;
  86524. /**
  86525. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  86526. */
  86527. colorCurves: Nullable<ColorCurves>;
  86528. private _colorCurvesEnabled;
  86529. /**
  86530. * Gets wether the color curves effect is enabled.
  86531. */
  86532. /**
  86533. * Sets wether the color curves effect is enabled.
  86534. */
  86535. colorCurvesEnabled: boolean;
  86536. private _colorGradingTexture;
  86537. /**
  86538. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  86539. */
  86540. /**
  86541. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  86542. */
  86543. colorGradingTexture: Nullable<BaseTexture>;
  86544. private _colorGradingEnabled;
  86545. /**
  86546. * Gets wether the color grading effect is enabled.
  86547. */
  86548. /**
  86549. * Sets wether the color grading effect is enabled.
  86550. */
  86551. colorGradingEnabled: boolean;
  86552. private _colorGradingWithGreenDepth;
  86553. /**
  86554. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  86555. */
  86556. /**
  86557. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  86558. */
  86559. colorGradingWithGreenDepth: boolean;
  86560. private _colorGradingBGR;
  86561. /**
  86562. * Gets wether the color grading texture contains BGR values.
  86563. */
  86564. /**
  86565. * Sets wether the color grading texture contains BGR values.
  86566. */
  86567. colorGradingBGR: boolean;
  86568. /** @hidden */
  86569. _exposure: number;
  86570. /**
  86571. * Gets the Exposure used in the effect.
  86572. */
  86573. /**
  86574. * Sets the Exposure used in the effect.
  86575. */
  86576. exposure: number;
  86577. private _toneMappingEnabled;
  86578. /**
  86579. * Gets wether the tone mapping effect is enabled.
  86580. */
  86581. /**
  86582. * Sets wether the tone mapping effect is enabled.
  86583. */
  86584. toneMappingEnabled: boolean;
  86585. private _toneMappingType;
  86586. /**
  86587. * Gets the type of tone mapping effect.
  86588. */
  86589. /**
  86590. * Sets the type of tone mapping effect used in BabylonJS.
  86591. */
  86592. toneMappingType: number;
  86593. protected _contrast: number;
  86594. /**
  86595. * Gets the contrast used in the effect.
  86596. */
  86597. /**
  86598. * Sets the contrast used in the effect.
  86599. */
  86600. contrast: number;
  86601. /**
  86602. * Vignette stretch size.
  86603. */
  86604. vignetteStretch: number;
  86605. /**
  86606. * Vignette centre X Offset.
  86607. */
  86608. vignetteCentreX: number;
  86609. /**
  86610. * Vignette centre Y Offset.
  86611. */
  86612. vignetteCentreY: number;
  86613. /**
  86614. * Vignette weight or intensity of the vignette effect.
  86615. */
  86616. vignetteWeight: number;
  86617. /**
  86618. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  86619. * if vignetteEnabled is set to true.
  86620. */
  86621. vignetteColor: Color4;
  86622. /**
  86623. * Camera field of view used by the Vignette effect.
  86624. */
  86625. vignetteCameraFov: number;
  86626. private _vignetteBlendMode;
  86627. /**
  86628. * Gets the vignette blend mode allowing different kind of effect.
  86629. */
  86630. /**
  86631. * Sets the vignette blend mode allowing different kind of effect.
  86632. */
  86633. vignetteBlendMode: number;
  86634. private _vignetteEnabled;
  86635. /**
  86636. * Gets wether the vignette effect is enabled.
  86637. */
  86638. /**
  86639. * Sets wether the vignette effect is enabled.
  86640. */
  86641. vignetteEnabled: boolean;
  86642. private _applyByPostProcess;
  86643. /**
  86644. * Gets wether the image processing is applied through a post process or not.
  86645. */
  86646. /**
  86647. * Sets wether the image processing is applied through a post process or not.
  86648. */
  86649. applyByPostProcess: boolean;
  86650. private _isEnabled;
  86651. /**
  86652. * Gets wether the image processing is enabled or not.
  86653. */
  86654. /**
  86655. * Sets wether the image processing is enabled or not.
  86656. */
  86657. isEnabled: boolean;
  86658. /**
  86659. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  86660. */
  86661. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  86662. /**
  86663. * Method called each time the image processing information changes requires to recompile the effect.
  86664. */
  86665. protected _updateParameters(): void;
  86666. /**
  86667. * Gets the current class name.
  86668. * @return "ImageProcessingConfiguration"
  86669. */
  86670. getClassName(): string;
  86671. /**
  86672. * Prepare the list of uniforms associated with the Image Processing effects.
  86673. * @param uniforms The list of uniforms used in the effect
  86674. * @param defines the list of defines currently in use
  86675. */
  86676. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  86677. /**
  86678. * Prepare the list of samplers associated with the Image Processing effects.
  86679. * @param samplersList The list of uniforms used in the effect
  86680. * @param defines the list of defines currently in use
  86681. */
  86682. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  86683. /**
  86684. * Prepare the list of defines associated to the shader.
  86685. * @param defines the list of defines to complete
  86686. * @param forPostProcess Define if we are currently in post process mode or not
  86687. */
  86688. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  86689. /**
  86690. * Returns true if all the image processing information are ready.
  86691. * @returns True if ready, otherwise, false
  86692. */
  86693. isReady(): boolean;
  86694. /**
  86695. * Binds the image processing to the shader.
  86696. * @param effect The effect to bind to
  86697. * @param aspectRatio Define the current aspect ratio of the effect
  86698. */
  86699. bind(effect: Effect, aspectRatio?: number): void;
  86700. /**
  86701. * Clones the current image processing instance.
  86702. * @return The cloned image processing
  86703. */
  86704. clone(): ImageProcessingConfiguration;
  86705. /**
  86706. * Serializes the current image processing instance to a json representation.
  86707. * @return a JSON representation
  86708. */
  86709. serialize(): any;
  86710. /**
  86711. * Parses the image processing from a json representation.
  86712. * @param source the JSON source to parse
  86713. * @return The parsed image processing
  86714. */
  86715. static Parse(source: any): ImageProcessingConfiguration;
  86716. private static _VIGNETTEMODE_MULTIPLY;
  86717. private static _VIGNETTEMODE_OPAQUE;
  86718. /**
  86719. * Used to apply the vignette as a mix with the pixel color.
  86720. */
  86721. static readonly VIGNETTEMODE_MULTIPLY: number;
  86722. /**
  86723. * Used to apply the vignette as a replacement of the pixel color.
  86724. */
  86725. static readonly VIGNETTEMODE_OPAQUE: number;
  86726. }
  86727. }
  86728. declare module BABYLON {
  86729. /**
  86730. * This represents all the required information to add a fresnel effect on a material:
  86731. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  86732. */
  86733. export class FresnelParameters {
  86734. private _isEnabled;
  86735. /**
  86736. * Define if the fresnel effect is enable or not.
  86737. */
  86738. isEnabled: boolean;
  86739. /**
  86740. * Define the color used on edges (grazing angle)
  86741. */
  86742. leftColor: Color3;
  86743. /**
  86744. * Define the color used on center
  86745. */
  86746. rightColor: Color3;
  86747. /**
  86748. * Define bias applied to computed fresnel term
  86749. */
  86750. bias: number;
  86751. /**
  86752. * Defined the power exponent applied to fresnel term
  86753. */
  86754. power: number;
  86755. /**
  86756. * Clones the current fresnel and its valuues
  86757. * @returns a clone fresnel configuration
  86758. */
  86759. clone(): FresnelParameters;
  86760. /**
  86761. * Serializes the current fresnel parameters to a JSON representation.
  86762. * @return the JSON serialization
  86763. */
  86764. serialize(): any;
  86765. /**
  86766. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  86767. * @param parsedFresnelParameters Define the JSON representation
  86768. * @returns the parsed parameters
  86769. */
  86770. static Parse(parsedFresnelParameters: any): FresnelParameters;
  86771. }
  86772. }
  86773. declare module BABYLON {
  86774. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  86775. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  86776. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  86777. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  86778. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  86779. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  86780. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  86781. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  86782. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  86783. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  86784. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  86785. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  86786. /**
  86787. * Decorator used to define property that can be serialized as reference to a camera
  86788. * @param sourceName defines the name of the property to decorate
  86789. */
  86790. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  86791. /**
  86792. * Class used to help serialization objects
  86793. */
  86794. export class SerializationHelper {
  86795. /** hidden */
  86796. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  86797. /** hidden */
  86798. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  86799. /** hidden */
  86800. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  86801. /** hidden */
  86802. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  86803. /**
  86804. * Appends the serialized animations from the source animations
  86805. * @param source Source containing the animations
  86806. * @param destination Target to store the animations
  86807. */
  86808. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  86809. /**
  86810. * Static function used to serialized a specific entity
  86811. * @param entity defines the entity to serialize
  86812. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  86813. * @returns a JSON compatible object representing the serialization of the entity
  86814. */
  86815. static Serialize<T>(entity: T, serializationObject?: any): any;
  86816. /**
  86817. * Creates a new entity from a serialization data object
  86818. * @param creationFunction defines a function used to instanciated the new entity
  86819. * @param source defines the source serialization data
  86820. * @param scene defines the hosting scene
  86821. * @param rootUrl defines the root url for resources
  86822. * @returns a new entity
  86823. */
  86824. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  86825. /**
  86826. * Clones an object
  86827. * @param creationFunction defines the function used to instanciate the new object
  86828. * @param source defines the source object
  86829. * @returns the cloned object
  86830. */
  86831. static Clone<T>(creationFunction: () => T, source: T): T;
  86832. /**
  86833. * Instanciates a new object based on a source one (some data will be shared between both object)
  86834. * @param creationFunction defines the function used to instanciate the new object
  86835. * @param source defines the source object
  86836. * @returns the new object
  86837. */
  86838. static Instanciate<T>(creationFunction: () => T, source: T): T;
  86839. }
  86840. }
  86841. declare module BABYLON {
  86842. /**
  86843. * This is the base class of all the camera used in the application.
  86844. * @see http://doc.babylonjs.com/features/cameras
  86845. */
  86846. export class Camera extends Node {
  86847. /** @hidden */
  86848. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  86849. /**
  86850. * This is the default projection mode used by the cameras.
  86851. * It helps recreating a feeling of perspective and better appreciate depth.
  86852. * This is the best way to simulate real life cameras.
  86853. */
  86854. static readonly PERSPECTIVE_CAMERA: number;
  86855. /**
  86856. * This helps creating camera with an orthographic mode.
  86857. * 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.
  86858. */
  86859. static readonly ORTHOGRAPHIC_CAMERA: number;
  86860. /**
  86861. * This is the default FOV mode for perspective cameras.
  86862. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  86863. */
  86864. static readonly FOVMODE_VERTICAL_FIXED: number;
  86865. /**
  86866. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  86867. */
  86868. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  86869. /**
  86870. * This specifies ther is no need for a camera rig.
  86871. * Basically only one eye is rendered corresponding to the camera.
  86872. */
  86873. static readonly RIG_MODE_NONE: number;
  86874. /**
  86875. * Simulates a camera Rig with one blue eye and one red eye.
  86876. * This can be use with 3d blue and red glasses.
  86877. */
  86878. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  86879. /**
  86880. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  86881. */
  86882. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  86883. /**
  86884. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  86885. */
  86886. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  86887. /**
  86888. * Defines that both eyes of the camera will be rendered over under each other.
  86889. */
  86890. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  86891. /**
  86892. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  86893. */
  86894. static readonly RIG_MODE_VR: number;
  86895. /**
  86896. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  86897. */
  86898. static readonly RIG_MODE_WEBVR: number;
  86899. /**
  86900. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  86901. */
  86902. static readonly RIG_MODE_CUSTOM: number;
  86903. /**
  86904. * Defines if by default attaching controls should prevent the default javascript event to continue.
  86905. */
  86906. static ForceAttachControlToAlwaysPreventDefault: boolean;
  86907. /**
  86908. * @hidden
  86909. * Might be removed once multiview will be a thing
  86910. */
  86911. static UseAlternateWebVRRendering: boolean;
  86912. /**
  86913. * Define the input manager associated with the camera.
  86914. */
  86915. inputs: CameraInputsManager<Camera>;
  86916. /** @hidden */
  86917. _position: Vector3;
  86918. /**
  86919. * Define the current local position of the camera in the scene
  86920. */
  86921. position: Vector3;
  86922. /**
  86923. * The vector the camera should consider as up.
  86924. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  86925. */
  86926. upVector: Vector3;
  86927. /**
  86928. * Define the current limit on the left side for an orthographic camera
  86929. * In scene unit
  86930. */
  86931. orthoLeft: Nullable<number>;
  86932. /**
  86933. * Define the current limit on the right side for an orthographic camera
  86934. * In scene unit
  86935. */
  86936. orthoRight: Nullable<number>;
  86937. /**
  86938. * Define the current limit on the bottom side for an orthographic camera
  86939. * In scene unit
  86940. */
  86941. orthoBottom: Nullable<number>;
  86942. /**
  86943. * Define the current limit on the top side for an orthographic camera
  86944. * In scene unit
  86945. */
  86946. orthoTop: Nullable<number>;
  86947. /**
  86948. * Field Of View is set in Radians. (default is 0.8)
  86949. */
  86950. fov: number;
  86951. /**
  86952. * Define the minimum distance the camera can see from.
  86953. * This is important to note that the depth buffer are not infinite and the closer it starts
  86954. * the more your scene might encounter depth fighting issue.
  86955. */
  86956. minZ: number;
  86957. /**
  86958. * Define the maximum distance the camera can see to.
  86959. * This is important to note that the depth buffer are not infinite and the further it end
  86960. * the more your scene might encounter depth fighting issue.
  86961. */
  86962. maxZ: number;
  86963. /**
  86964. * Define the default inertia of the camera.
  86965. * This helps giving a smooth feeling to the camera movement.
  86966. */
  86967. inertia: number;
  86968. /**
  86969. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  86970. */
  86971. mode: number;
  86972. /**
  86973. * Define wether the camera is intermediate.
  86974. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  86975. */
  86976. isIntermediate: boolean;
  86977. /**
  86978. * Define the viewport of the camera.
  86979. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  86980. */
  86981. viewport: Viewport;
  86982. /**
  86983. * Restricts the camera to viewing objects with the same layerMask.
  86984. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  86985. */
  86986. layerMask: number;
  86987. /**
  86988. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  86989. */
  86990. fovMode: number;
  86991. /**
  86992. * Rig mode of the camera.
  86993. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  86994. * This is normally controlled byt the camera themselves as internal use.
  86995. */
  86996. cameraRigMode: number;
  86997. /**
  86998. * Defines the distance between both "eyes" in case of a RIG
  86999. */
  87000. interaxialDistance: number;
  87001. /**
  87002. * Defines if stereoscopic rendering is done side by side or over under.
  87003. */
  87004. isStereoscopicSideBySide: boolean;
  87005. /**
  87006. * 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
  87007. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  87008. * else in the scene.
  87009. */
  87010. customRenderTargets: RenderTargetTexture[];
  87011. /**
  87012. * When set, the camera will render to this render target instead of the default canvas
  87013. */
  87014. outputRenderTarget: Nullable<RenderTargetTexture>;
  87015. /**
  87016. * Observable triggered when the camera view matrix has changed.
  87017. */
  87018. onViewMatrixChangedObservable: Observable<Camera>;
  87019. /**
  87020. * Observable triggered when the camera Projection matrix has changed.
  87021. */
  87022. onProjectionMatrixChangedObservable: Observable<Camera>;
  87023. /**
  87024. * Observable triggered when the inputs have been processed.
  87025. */
  87026. onAfterCheckInputsObservable: Observable<Camera>;
  87027. /**
  87028. * Observable triggered when reset has been called and applied to the camera.
  87029. */
  87030. onRestoreStateObservable: Observable<Camera>;
  87031. /** @hidden */
  87032. _cameraRigParams: any;
  87033. /** @hidden */
  87034. _rigCameras: Camera[];
  87035. /** @hidden */
  87036. _rigPostProcess: Nullable<PostProcess>;
  87037. protected _webvrViewMatrix: Matrix;
  87038. /** @hidden */
  87039. _skipRendering: boolean;
  87040. /** @hidden */
  87041. _alternateCamera: Camera;
  87042. /** @hidden */
  87043. _projectionMatrix: Matrix;
  87044. /** @hidden */
  87045. _postProcesses: Nullable<PostProcess>[];
  87046. /** @hidden */
  87047. _activeMeshes: SmartArray<AbstractMesh>;
  87048. protected _globalPosition: Vector3;
  87049. /** hidden */
  87050. _computedViewMatrix: Matrix;
  87051. private _doNotComputeProjectionMatrix;
  87052. private _transformMatrix;
  87053. private _frustumPlanes;
  87054. private _refreshFrustumPlanes;
  87055. private _storedFov;
  87056. private _stateStored;
  87057. /**
  87058. * Instantiates a new camera object.
  87059. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  87060. * @see http://doc.babylonjs.com/features/cameras
  87061. * @param name Defines the name of the camera in the scene
  87062. * @param position Defines the position of the camera
  87063. * @param scene Defines the scene the camera belongs too
  87064. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  87065. */
  87066. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  87067. /**
  87068. * Store current camera state (fov, position, etc..)
  87069. * @returns the camera
  87070. */
  87071. storeState(): Camera;
  87072. /**
  87073. * Restores the camera state values if it has been stored. You must call storeState() first
  87074. */
  87075. protected _restoreStateValues(): boolean;
  87076. /**
  87077. * Restored camera state. You must call storeState() first.
  87078. * @returns true if restored and false otherwise
  87079. */
  87080. restoreState(): boolean;
  87081. /**
  87082. * Gets the class name of the camera.
  87083. * @returns the class name
  87084. */
  87085. getClassName(): string;
  87086. /** @hidden */
  87087. readonly _isCamera: boolean;
  87088. /**
  87089. * Gets a string representation of the camera useful for debug purpose.
  87090. * @param fullDetails Defines that a more verboe level of logging is required
  87091. * @returns the string representation
  87092. */
  87093. toString(fullDetails?: boolean): string;
  87094. /**
  87095. * Gets the current world space position of the camera.
  87096. */
  87097. readonly globalPosition: Vector3;
  87098. /**
  87099. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  87100. * @returns the active meshe list
  87101. */
  87102. getActiveMeshes(): SmartArray<AbstractMesh>;
  87103. /**
  87104. * Check wether a mesh is part of the current active mesh list of the camera
  87105. * @param mesh Defines the mesh to check
  87106. * @returns true if active, false otherwise
  87107. */
  87108. isActiveMesh(mesh: Mesh): boolean;
  87109. /**
  87110. * Is this camera ready to be used/rendered
  87111. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  87112. * @return true if the camera is ready
  87113. */
  87114. isReady(completeCheck?: boolean): boolean;
  87115. /** @hidden */
  87116. _initCache(): void;
  87117. /** @hidden */
  87118. _updateCache(ignoreParentClass?: boolean): void;
  87119. /** @hidden */
  87120. _isSynchronized(): boolean;
  87121. /** @hidden */
  87122. _isSynchronizedViewMatrix(): boolean;
  87123. /** @hidden */
  87124. _isSynchronizedProjectionMatrix(): boolean;
  87125. /**
  87126. * Attach the input controls to a specific dom element to get the input from.
  87127. * @param element Defines the element the controls should be listened from
  87128. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  87129. */
  87130. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  87131. /**
  87132. * Detach the current controls from the specified dom element.
  87133. * @param element Defines the element to stop listening the inputs from
  87134. */
  87135. detachControl(element: HTMLElement): void;
  87136. /**
  87137. * Update the camera state according to the different inputs gathered during the frame.
  87138. */
  87139. update(): void;
  87140. /** @hidden */
  87141. _checkInputs(): void;
  87142. /** @hidden */
  87143. readonly rigCameras: Camera[];
  87144. /**
  87145. * Gets the post process used by the rig cameras
  87146. */
  87147. readonly rigPostProcess: Nullable<PostProcess>;
  87148. /**
  87149. * Internal, gets the first post proces.
  87150. * @returns the first post process to be run on this camera.
  87151. */
  87152. _getFirstPostProcess(): Nullable<PostProcess>;
  87153. private _cascadePostProcessesToRigCams;
  87154. /**
  87155. * Attach a post process to the camera.
  87156. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  87157. * @param postProcess The post process to attach to the camera
  87158. * @param insertAt The position of the post process in case several of them are in use in the scene
  87159. * @returns the position the post process has been inserted at
  87160. */
  87161. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  87162. /**
  87163. * Detach a post process to the camera.
  87164. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  87165. * @param postProcess The post process to detach from the camera
  87166. */
  87167. detachPostProcess(postProcess: PostProcess): void;
  87168. /**
  87169. * Gets the current world matrix of the camera
  87170. */
  87171. getWorldMatrix(): Matrix;
  87172. /** @hidden */
  87173. _getViewMatrix(): Matrix;
  87174. /**
  87175. * Gets the current view matrix of the camera.
  87176. * @param force forces the camera to recompute the matrix without looking at the cached state
  87177. * @returns the view matrix
  87178. */
  87179. getViewMatrix(force?: boolean): Matrix;
  87180. /**
  87181. * Freeze the projection matrix.
  87182. * It will prevent the cache check of the camera projection compute and can speed up perf
  87183. * if no parameter of the camera are meant to change
  87184. * @param projection Defines manually a projection if necessary
  87185. */
  87186. freezeProjectionMatrix(projection?: Matrix): void;
  87187. /**
  87188. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  87189. */
  87190. unfreezeProjectionMatrix(): void;
  87191. /**
  87192. * Gets the current projection matrix of the camera.
  87193. * @param force forces the camera to recompute the matrix without looking at the cached state
  87194. * @returns the projection matrix
  87195. */
  87196. getProjectionMatrix(force?: boolean): Matrix;
  87197. /**
  87198. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  87199. * @returns a Matrix
  87200. */
  87201. getTransformationMatrix(): Matrix;
  87202. private _updateFrustumPlanes;
  87203. /**
  87204. * Checks if a cullable object (mesh...) is in the camera frustum
  87205. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  87206. * @param target The object to check
  87207. * @returns true if the object is in frustum otherwise false
  87208. */
  87209. isInFrustum(target: ICullable): boolean;
  87210. /**
  87211. * Checks if a cullable object (mesh...) is in the camera frustum
  87212. * Unlike isInFrustum this cheks the full bounding box
  87213. * @param target The object to check
  87214. * @returns true if the object is in frustum otherwise false
  87215. */
  87216. isCompletelyInFrustum(target: ICullable): boolean;
  87217. /**
  87218. * Gets a ray in the forward direction from the camera.
  87219. * @param length Defines the length of the ray to create
  87220. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  87221. * @param origin Defines the start point of the ray which defaults to the camera position
  87222. * @returns the forward ray
  87223. */
  87224. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  87225. /**
  87226. * Releases resources associated with this node.
  87227. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  87228. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  87229. */
  87230. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  87231. /** @hidden */
  87232. _isLeftCamera: boolean;
  87233. /**
  87234. * Gets the left camera of a rig setup in case of Rigged Camera
  87235. */
  87236. readonly isLeftCamera: boolean;
  87237. /** @hidden */
  87238. _isRightCamera: boolean;
  87239. /**
  87240. * Gets the right camera of a rig setup in case of Rigged Camera
  87241. */
  87242. readonly isRightCamera: boolean;
  87243. /**
  87244. * Gets the left camera of a rig setup in case of Rigged Camera
  87245. */
  87246. readonly leftCamera: Nullable<FreeCamera>;
  87247. /**
  87248. * Gets the right camera of a rig setup in case of Rigged Camera
  87249. */
  87250. readonly rightCamera: Nullable<FreeCamera>;
  87251. /**
  87252. * Gets the left camera target of a rig setup in case of Rigged Camera
  87253. * @returns the target position
  87254. */
  87255. getLeftTarget(): Nullable<Vector3>;
  87256. /**
  87257. * Gets the right camera target of a rig setup in case of Rigged Camera
  87258. * @returns the target position
  87259. */
  87260. getRightTarget(): Nullable<Vector3>;
  87261. /**
  87262. * @hidden
  87263. */
  87264. setCameraRigMode(mode: number, rigParams: any): void;
  87265. /** @hidden */
  87266. static _setStereoscopicRigMode(camera: Camera): void;
  87267. /** @hidden */
  87268. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  87269. /** @hidden */
  87270. static _setVRRigMode(camera: Camera, rigParams: any): void;
  87271. /** @hidden */
  87272. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  87273. /** @hidden */
  87274. _getVRProjectionMatrix(): Matrix;
  87275. protected _updateCameraRotationMatrix(): void;
  87276. protected _updateWebVRCameraRotationMatrix(): void;
  87277. /**
  87278. * This function MUST be overwritten by the different WebVR cameras available.
  87279. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  87280. * @hidden
  87281. */
  87282. _getWebVRProjectionMatrix(): Matrix;
  87283. /**
  87284. * This function MUST be overwritten by the different WebVR cameras available.
  87285. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  87286. * @hidden
  87287. */
  87288. _getWebVRViewMatrix(): Matrix;
  87289. /** @hidden */
  87290. setCameraRigParameter(name: string, value: any): void;
  87291. /**
  87292. * needs to be overridden by children so sub has required properties to be copied
  87293. * @hidden
  87294. */
  87295. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  87296. /**
  87297. * May need to be overridden by children
  87298. * @hidden
  87299. */
  87300. _updateRigCameras(): void;
  87301. /** @hidden */
  87302. _setupInputs(): void;
  87303. /**
  87304. * Serialiaze the camera setup to a json represention
  87305. * @returns the JSON representation
  87306. */
  87307. serialize(): any;
  87308. /**
  87309. * Clones the current camera.
  87310. * @param name The cloned camera name
  87311. * @returns the cloned camera
  87312. */
  87313. clone(name: string): Camera;
  87314. /**
  87315. * Gets the direction of the camera relative to a given local axis.
  87316. * @param localAxis Defines the reference axis to provide a relative direction.
  87317. * @return the direction
  87318. */
  87319. getDirection(localAxis: Vector3): Vector3;
  87320. /**
  87321. * Gets the direction of the camera relative to a given local axis into a passed vector.
  87322. * @param localAxis Defines the reference axis to provide a relative direction.
  87323. * @param result Defines the vector to store the result in
  87324. */
  87325. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  87326. /**
  87327. * Gets a camera constructor for a given camera type
  87328. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  87329. * @param name The name of the camera the result will be able to instantiate
  87330. * @param scene The scene the result will construct the camera in
  87331. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  87332. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  87333. * @returns a factory method to construc the camera
  87334. */
  87335. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  87336. /**
  87337. * Compute the world matrix of the camera.
  87338. * @returns the camera workd matrix
  87339. */
  87340. computeWorldMatrix(): Matrix;
  87341. /**
  87342. * Parse a JSON and creates the camera from the parsed information
  87343. * @param parsedCamera The JSON to parse
  87344. * @param scene The scene to instantiate the camera in
  87345. * @returns the newly constructed camera
  87346. */
  87347. static Parse(parsedCamera: any, scene: Scene): Camera;
  87348. }
  87349. }
  87350. declare module BABYLON {
  87351. /**
  87352. * Interface for any object that can request an animation frame
  87353. */
  87354. export interface ICustomAnimationFrameRequester {
  87355. /**
  87356. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  87357. */
  87358. renderFunction?: Function;
  87359. /**
  87360. * Called to request the next frame to render to
  87361. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  87362. */
  87363. requestAnimationFrame: Function;
  87364. /**
  87365. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  87366. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  87367. */
  87368. requestID?: number;
  87369. }
  87370. /**
  87371. * Interface containing an array of animations
  87372. */
  87373. export interface IAnimatable {
  87374. /**
  87375. * Array of animations
  87376. */
  87377. animations: Array<Animation>;
  87378. }
  87379. /** Interface used by value gradients (color, factor, ...) */
  87380. export interface IValueGradient {
  87381. /**
  87382. * Gets or sets the gradient value (between 0 and 1)
  87383. */
  87384. gradient: number;
  87385. }
  87386. /** Class used to store color4 gradient */
  87387. export class ColorGradient implements IValueGradient {
  87388. /**
  87389. * Gets or sets the gradient value (between 0 and 1)
  87390. */
  87391. gradient: number;
  87392. /**
  87393. * Gets or sets first associated color
  87394. */
  87395. color1: Color4;
  87396. /**
  87397. * Gets or sets second associated color
  87398. */
  87399. color2?: Color4;
  87400. /**
  87401. * Will get a color picked randomly between color1 and color2.
  87402. * If color2 is undefined then color1 will be used
  87403. * @param result defines the target Color4 to store the result in
  87404. */
  87405. getColorToRef(result: Color4): void;
  87406. }
  87407. /** Class used to store color 3 gradient */
  87408. export class Color3Gradient implements IValueGradient {
  87409. /**
  87410. * Gets or sets the gradient value (between 0 and 1)
  87411. */
  87412. gradient: number;
  87413. /**
  87414. * Gets or sets the associated color
  87415. */
  87416. color: Color3;
  87417. }
  87418. /** Class used to store factor gradient */
  87419. export class FactorGradient implements IValueGradient {
  87420. /**
  87421. * Gets or sets the gradient value (between 0 and 1)
  87422. */
  87423. gradient: number;
  87424. /**
  87425. * Gets or sets first associated factor
  87426. */
  87427. factor1: number;
  87428. /**
  87429. * Gets or sets second associated factor
  87430. */
  87431. factor2?: number;
  87432. /**
  87433. * Will get a number picked randomly between factor1 and factor2.
  87434. * If factor2 is undefined then factor1 will be used
  87435. * @returns the picked number
  87436. */
  87437. getFactor(): number;
  87438. }
  87439. /**
  87440. * @ignore
  87441. * Application error to support additional information when loading a file
  87442. */
  87443. export class LoadFileError extends Error {
  87444. /** defines the optional XHR request */
  87445. request?: XMLHttpRequest | undefined;
  87446. private static _setPrototypeOf;
  87447. /**
  87448. * Creates a new LoadFileError
  87449. * @param message defines the message of the error
  87450. * @param request defines the optional XHR request
  87451. */
  87452. constructor(message: string,
  87453. /** defines the optional XHR request */
  87454. request?: XMLHttpRequest | undefined);
  87455. }
  87456. /**
  87457. * Class used to define a retry strategy when error happens while loading assets
  87458. */
  87459. export class RetryStrategy {
  87460. /**
  87461. * Function used to defines an exponential back off strategy
  87462. * @param maxRetries defines the maximum number of retries (3 by default)
  87463. * @param baseInterval defines the interval between retries
  87464. * @returns the strategy function to use
  87465. */
  87466. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  87467. }
  87468. /**
  87469. * File request interface
  87470. */
  87471. export interface IFileRequest {
  87472. /**
  87473. * Raised when the request is complete (success or error).
  87474. */
  87475. onCompleteObservable: Observable<IFileRequest>;
  87476. /**
  87477. * Aborts the request for a file.
  87478. */
  87479. abort: () => void;
  87480. }
  87481. /**
  87482. * Class containing a set of static utilities functions
  87483. */
  87484. export class Tools {
  87485. /**
  87486. * Gets or sets the base URL to use to load assets
  87487. */
  87488. static BaseUrl: string;
  87489. /**
  87490. * Enable/Disable Custom HTTP Request Headers globally.
  87491. * default = false
  87492. * @see CustomRequestHeaders
  87493. */
  87494. static UseCustomRequestHeaders: boolean;
  87495. /**
  87496. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  87497. * i.e. when loading files, where the server/service expects an Authorization header.
  87498. * @see InjectCustomRequestHeaders injects them to an XMLHttpRequest
  87499. */
  87500. static CustomRequestHeaders: {
  87501. [key: string]: string;
  87502. };
  87503. /**
  87504. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  87505. */
  87506. static DefaultRetryStrategy: (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  87507. /**
  87508. * Default behaviour for cors in the application.
  87509. * It can be a string if the expected behavior is identical in the entire app.
  87510. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  87511. */
  87512. static CorsBehavior: string | ((url: string | string[]) => string);
  87513. /**
  87514. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  87515. * @ignorenaming
  87516. */
  87517. static UseFallbackTexture: boolean;
  87518. /**
  87519. * Use this object to register external classes like custom textures or material
  87520. * to allow the laoders to instantiate them
  87521. */
  87522. static RegisteredExternalClasses: {
  87523. [key: string]: Object;
  87524. };
  87525. /**
  87526. * Texture content used if a texture cannot loaded
  87527. * @ignorenaming
  87528. */
  87529. static fallbackTexture: string;
  87530. /**
  87531. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  87532. * @param u defines the coordinate on X axis
  87533. * @param v defines the coordinate on Y axis
  87534. * @param width defines the width of the source data
  87535. * @param height defines the height of the source data
  87536. * @param pixels defines the source byte array
  87537. * @param color defines the output color
  87538. */
  87539. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  87540. /**
  87541. * Interpolates between a and b via alpha
  87542. * @param a The lower value (returned when alpha = 0)
  87543. * @param b The upper value (returned when alpha = 1)
  87544. * @param alpha The interpolation-factor
  87545. * @return The mixed value
  87546. */
  87547. static Mix(a: number, b: number, alpha: number): number;
  87548. /**
  87549. * Tries to instantiate a new object from a given class name
  87550. * @param className defines the class name to instantiate
  87551. * @returns the new object or null if the system was not able to do the instantiation
  87552. */
  87553. static Instantiate(className: string): any;
  87554. /**
  87555. * Provides a slice function that will work even on IE
  87556. * @param data defines the array to slice
  87557. * @param start defines the start of the data (optional)
  87558. * @param end defines the end of the data (optional)
  87559. * @returns the new sliced array
  87560. */
  87561. static Slice<T>(data: T, start?: number, end?: number): T;
  87562. /**
  87563. * Polyfill for setImmediate
  87564. * @param action defines the action to execute after the current execution block
  87565. */
  87566. static SetImmediate(action: () => void): void;
  87567. /**
  87568. * Function indicating if a number is an exponent of 2
  87569. * @param value defines the value to test
  87570. * @returns true if the value is an exponent of 2
  87571. */
  87572. static IsExponentOfTwo(value: number): boolean;
  87573. private static _tmpFloatArray;
  87574. /**
  87575. * Returns the nearest 32-bit single precision float representation of a Number
  87576. * @param value A Number. If the parameter is of a different type, it will get converted
  87577. * to a number or to NaN if it cannot be converted
  87578. * @returns number
  87579. */
  87580. static FloatRound(value: number): number;
  87581. /**
  87582. * Find the next highest power of two.
  87583. * @param x Number to start search from.
  87584. * @return Next highest power of two.
  87585. */
  87586. static CeilingPOT(x: number): number;
  87587. /**
  87588. * Find the next lowest power of two.
  87589. * @param x Number to start search from.
  87590. * @return Next lowest power of two.
  87591. */
  87592. static FloorPOT(x: number): number;
  87593. /**
  87594. * Find the nearest power of two.
  87595. * @param x Number to start search from.
  87596. * @return Next nearest power of two.
  87597. */
  87598. static NearestPOT(x: number): number;
  87599. /**
  87600. * Get the closest exponent of two
  87601. * @param value defines the value to approximate
  87602. * @param max defines the maximum value to return
  87603. * @param mode defines how to define the closest value
  87604. * @returns closest exponent of two of the given value
  87605. */
  87606. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  87607. /**
  87608. * Extracts the filename from a path
  87609. * @param path defines the path to use
  87610. * @returns the filename
  87611. */
  87612. static GetFilename(path: string): string;
  87613. /**
  87614. * Extracts the "folder" part of a path (everything before the filename).
  87615. * @param uri The URI to extract the info from
  87616. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  87617. * @returns The "folder" part of the path
  87618. */
  87619. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  87620. /**
  87621. * Extracts text content from a DOM element hierarchy
  87622. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  87623. */
  87624. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  87625. /**
  87626. * Convert an angle in radians to degrees
  87627. * @param angle defines the angle to convert
  87628. * @returns the angle in degrees
  87629. */
  87630. static ToDegrees(angle: number): number;
  87631. /**
  87632. * Convert an angle in degrees to radians
  87633. * @param angle defines the angle to convert
  87634. * @returns the angle in radians
  87635. */
  87636. static ToRadians(angle: number): number;
  87637. /**
  87638. * Encode a buffer to a base64 string
  87639. * @param buffer defines the buffer to encode
  87640. * @returns the encoded string
  87641. */
  87642. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  87643. /**
  87644. * Extracts minimum and maximum values from a list of indexed positions
  87645. * @param positions defines the positions to use
  87646. * @param indices defines the indices to the positions
  87647. * @param indexStart defines the start index
  87648. * @param indexCount defines the end index
  87649. * @param bias defines bias value to add to the result
  87650. * @return minimum and maximum values
  87651. */
  87652. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  87653. minimum: Vector3;
  87654. maximum: Vector3;
  87655. };
  87656. /**
  87657. * Extracts minimum and maximum values from a list of positions
  87658. * @param positions defines the positions to use
  87659. * @param start defines the start index in the positions array
  87660. * @param count defines the number of positions to handle
  87661. * @param bias defines bias value to add to the result
  87662. * @param stride defines the stride size to use (distance between two positions in the positions array)
  87663. * @return minimum and maximum values
  87664. */
  87665. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  87666. minimum: Vector3;
  87667. maximum: Vector3;
  87668. };
  87669. /**
  87670. * Returns an array if obj is not an array
  87671. * @param obj defines the object to evaluate as an array
  87672. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  87673. * @returns either obj directly if obj is an array or a new array containing obj
  87674. */
  87675. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  87676. /**
  87677. * Gets the pointer prefix to use
  87678. * @returns "pointer" if touch is enabled. Else returns "mouse"
  87679. */
  87680. static GetPointerPrefix(): string;
  87681. /**
  87682. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  87683. * @param func - the function to be called
  87684. * @param requester - the object that will request the next frame. Falls back to window.
  87685. * @returns frame number
  87686. */
  87687. static QueueNewFrame(func: () => void, requester?: any): number;
  87688. /**
  87689. * Ask the browser to promote the current element to fullscreen rendering mode
  87690. * @param element defines the DOM element to promote
  87691. */
  87692. static RequestFullscreen(element: HTMLElement): void;
  87693. /**
  87694. * Asks the browser to exit fullscreen mode
  87695. */
  87696. static ExitFullscreen(): void;
  87697. /**
  87698. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  87699. * @param url define the url we are trying
  87700. * @param element define the dom element where to configure the cors policy
  87701. */
  87702. static SetCorsBehavior(url: string | string[], element: {
  87703. crossOrigin: string | null;
  87704. }): void;
  87705. /**
  87706. * Removes unwanted characters from an url
  87707. * @param url defines the url to clean
  87708. * @returns the cleaned url
  87709. */
  87710. static CleanUrl(url: string): string;
  87711. /**
  87712. * Gets or sets a function used to pre-process url before using them to load assets
  87713. */
  87714. static PreprocessUrl: (url: string) => string;
  87715. /**
  87716. * Loads an image as an HTMLImageElement.
  87717. * @param input url string, ArrayBuffer, or Blob to load
  87718. * @param onLoad callback called when the image successfully loads
  87719. * @param onError callback called when the image fails to load
  87720. * @param offlineProvider offline provider for caching
  87721. * @returns the HTMLImageElement of the loaded image
  87722. */
  87723. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  87724. /**
  87725. * Loads a file
  87726. * @param url url string, ArrayBuffer, or Blob to load
  87727. * @param onSuccess callback called when the file successfully loads
  87728. * @param onProgress callback called while file is loading (if the server supports this mode)
  87729. * @param offlineProvider defines the offline provider for caching
  87730. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  87731. * @param onError callback called when the file fails to load
  87732. * @returns a file request object
  87733. */
  87734. 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;
  87735. /**
  87736. * Load a script (identified by an url). When the url returns, the
  87737. * content of this file is added into a new script element, attached to the DOM (body element)
  87738. * @param scriptUrl defines the url of the script to laod
  87739. * @param onSuccess defines the callback called when the script is loaded
  87740. * @param onError defines the callback to call if an error occurs
  87741. */
  87742. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void): void;
  87743. /**
  87744. * Loads a file from a blob
  87745. * @param fileToLoad defines the blob to use
  87746. * @param callback defines the callback to call when data is loaded
  87747. * @param progressCallback defines the callback to call during loading process
  87748. * @returns a file request object
  87749. */
  87750. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  87751. /**
  87752. * Loads a file
  87753. * @param fileToLoad defines the file to load
  87754. * @param callback defines the callback to call when data is loaded
  87755. * @param progressCallBack defines the callback to call during loading process
  87756. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  87757. * @returns a file request object
  87758. */
  87759. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  87760. /**
  87761. * Creates a data url from a given string content
  87762. * @param content defines the content to convert
  87763. * @returns the new data url link
  87764. */
  87765. static FileAsURL(content: string): string;
  87766. /**
  87767. * Format the given number to a specific decimal format
  87768. * @param value defines the number to format
  87769. * @param decimals defines the number of decimals to use
  87770. * @returns the formatted string
  87771. */
  87772. static Format(value: number, decimals?: number): string;
  87773. /**
  87774. * Checks if a given vector is inside a specific range
  87775. * @param v defines the vector to test
  87776. * @param min defines the minimum range
  87777. * @param max defines the maximum range
  87778. */
  87779. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  87780. /**
  87781. * Tries to copy an object by duplicating every property
  87782. * @param source defines the source object
  87783. * @param destination defines the target object
  87784. * @param doNotCopyList defines a list of properties to avoid
  87785. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  87786. */
  87787. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  87788. /**
  87789. * Gets a boolean indicating if the given object has no own property
  87790. * @param obj defines the object to test
  87791. * @returns true if object has no own property
  87792. */
  87793. static IsEmpty(obj: any): boolean;
  87794. /**
  87795. * Function used to register events at window level
  87796. * @param events defines the events to register
  87797. */
  87798. static RegisterTopRootEvents(events: {
  87799. name: string;
  87800. handler: Nullable<(e: FocusEvent) => any>;
  87801. }[]): void;
  87802. /**
  87803. * Function used to unregister events from window level
  87804. * @param events defines the events to unregister
  87805. */
  87806. static UnregisterTopRootEvents(events: {
  87807. name: string;
  87808. handler: Nullable<(e: FocusEvent) => any>;
  87809. }[]): void;
  87810. /**
  87811. * @ignore
  87812. */
  87813. static _ScreenshotCanvas: HTMLCanvasElement;
  87814. /**
  87815. * Dumps the current bound framebuffer
  87816. * @param width defines the rendering width
  87817. * @param height defines the rendering height
  87818. * @param engine defines the hosting engine
  87819. * @param successCallback defines the callback triggered once the data are available
  87820. * @param mimeType defines the mime type of the result
  87821. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  87822. */
  87823. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  87824. /**
  87825. * Converts the canvas data to blob.
  87826. * This acts as a polyfill for browsers not supporting the to blob function.
  87827. * @param canvas Defines the canvas to extract the data from
  87828. * @param successCallback Defines the callback triggered once the data are available
  87829. * @param mimeType Defines the mime type of the result
  87830. */
  87831. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  87832. /**
  87833. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  87834. * @param successCallback defines the callback triggered once the data are available
  87835. * @param mimeType defines the mime type of the result
  87836. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  87837. */
  87838. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  87839. /**
  87840. * Downloads a blob in the browser
  87841. * @param blob defines the blob to download
  87842. * @param fileName defines the name of the downloaded file
  87843. */
  87844. static Download(blob: Blob, fileName: string): void;
  87845. /**
  87846. * Captures a screenshot of the current rendering
  87847. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  87848. * @param engine defines the rendering engine
  87849. * @param camera defines the source camera
  87850. * @param size This parameter can be set to a single number or to an object with the
  87851. * following (optional) properties: precision, width, height. If a single number is passed,
  87852. * it will be used for both width and height. If an object is passed, the screenshot size
  87853. * will be derived from the parameters. The precision property is a multiplier allowing
  87854. * rendering at a higher or lower resolution
  87855. * @param successCallback defines the callback receives a single parameter which contains the
  87856. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  87857. * src parameter of an <img> to display it
  87858. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  87859. * Check your browser for supported MIME types
  87860. */
  87861. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  87862. /**
  87863. * Generates an image screenshot from the specified camera.
  87864. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  87865. * @param engine The engine to use for rendering
  87866. * @param camera The camera to use for rendering
  87867. * @param size This parameter can be set to a single number or to an object with the
  87868. * following (optional) properties: precision, width, height. If a single number is passed,
  87869. * it will be used for both width and height. If an object is passed, the screenshot size
  87870. * will be derived from the parameters. The precision property is a multiplier allowing
  87871. * rendering at a higher or lower resolution
  87872. * @param successCallback The callback receives a single parameter which contains the
  87873. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  87874. * src parameter of an <img> to display it
  87875. * @param mimeType The MIME type of the screenshot image (default: image/png).
  87876. * Check your browser for supported MIME types
  87877. * @param samples Texture samples (default: 1)
  87878. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  87879. * @param fileName A name for for the downloaded file.
  87880. */
  87881. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  87882. /**
  87883. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  87884. * Be aware Math.random() could cause collisions, but:
  87885. * "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"
  87886. * @returns a pseudo random id
  87887. */
  87888. static RandomId(): string;
  87889. /**
  87890. * Test if the given uri is a base64 string
  87891. * @param uri The uri to test
  87892. * @return True if the uri is a base64 string or false otherwise
  87893. */
  87894. static IsBase64(uri: string): boolean;
  87895. /**
  87896. * Decode the given base64 uri.
  87897. * @param uri The uri to decode
  87898. * @return The decoded base64 data.
  87899. */
  87900. static DecodeBase64(uri: string): ArrayBuffer;
  87901. /**
  87902. * No log
  87903. */
  87904. static readonly NoneLogLevel: number;
  87905. /**
  87906. * Only message logs
  87907. */
  87908. static readonly MessageLogLevel: number;
  87909. /**
  87910. * Only warning logs
  87911. */
  87912. static readonly WarningLogLevel: number;
  87913. /**
  87914. * Only error logs
  87915. */
  87916. static readonly ErrorLogLevel: number;
  87917. /**
  87918. * All logs
  87919. */
  87920. static readonly AllLogLevel: number;
  87921. /**
  87922. * Gets a value indicating the number of loading errors
  87923. * @ignorenaming
  87924. */
  87925. static readonly errorsCount: number;
  87926. /**
  87927. * Callback called when a new log is added
  87928. */
  87929. static OnNewCacheEntry: (entry: string) => void;
  87930. /**
  87931. * Log a message to the console
  87932. * @param message defines the message to log
  87933. */
  87934. static Log(message: string): void;
  87935. /**
  87936. * Write a warning message to the console
  87937. * @param message defines the message to log
  87938. */
  87939. static Warn(message: string): void;
  87940. /**
  87941. * Write an error message to the console
  87942. * @param message defines the message to log
  87943. */
  87944. static Error(message: string): void;
  87945. /**
  87946. * Gets current log cache (list of logs)
  87947. */
  87948. static readonly LogCache: string;
  87949. /**
  87950. * Clears the log cache
  87951. */
  87952. static ClearLogCache(): void;
  87953. /**
  87954. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  87955. */
  87956. static LogLevels: number;
  87957. /**
  87958. * Checks if the loaded document was accessed via `file:`-Protocol.
  87959. * @returns boolean
  87960. */
  87961. static IsFileURL(): boolean;
  87962. /**
  87963. * Checks if the window object exists
  87964. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  87965. */
  87966. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  87967. /**
  87968. * No performance log
  87969. */
  87970. static readonly PerformanceNoneLogLevel: number;
  87971. /**
  87972. * Use user marks to log performance
  87973. */
  87974. static readonly PerformanceUserMarkLogLevel: number;
  87975. /**
  87976. * Log performance to the console
  87977. */
  87978. static readonly PerformanceConsoleLogLevel: number;
  87979. private static _performance;
  87980. /**
  87981. * Sets the current performance log level
  87982. */
  87983. static PerformanceLogLevel: number;
  87984. private static _StartPerformanceCounterDisabled;
  87985. private static _EndPerformanceCounterDisabled;
  87986. private static _StartUserMark;
  87987. private static _EndUserMark;
  87988. private static _StartPerformanceConsole;
  87989. private static _EndPerformanceConsole;
  87990. /**
  87991. * Injects the @see CustomRequestHeaders into the given request
  87992. * @param request the request that should be used for injection
  87993. */
  87994. static InjectCustomRequestHeaders(request: XMLHttpRequest): void;
  87995. /**
  87996. * Starts a performance counter
  87997. */
  87998. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  87999. /**
  88000. * Ends a specific performance coutner
  88001. */
  88002. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  88003. /**
  88004. * Gets either window.performance.now() if supported or Date.now() else
  88005. */
  88006. static readonly Now: number;
  88007. /**
  88008. * This method will return the name of the class used to create the instance of the given object.
  88009. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  88010. * @param object the object to get the class name from
  88011. * @param isType defines if the object is actually a type
  88012. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  88013. */
  88014. static GetClassName(object: any, isType?: boolean): string;
  88015. /**
  88016. * Gets the first element of an array satisfying a given predicate
  88017. * @param array defines the array to browse
  88018. * @param predicate defines the predicate to use
  88019. * @returns null if not found or the element
  88020. */
  88021. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  88022. /**
  88023. * This method will return the name of the full name of the class, including its owning module (if any).
  88024. * 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).
  88025. * @param object the object to get the class name from
  88026. * @param isType defines if the object is actually a type
  88027. * @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.
  88028. * @ignorenaming
  88029. */
  88030. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  88031. /**
  88032. * Returns a promise that resolves after the given amount of time.
  88033. * @param delay Number of milliseconds to delay
  88034. * @returns Promise that resolves after the given amount of time
  88035. */
  88036. static DelayAsync(delay: number): Promise<void>;
  88037. /**
  88038. * Gets the current gradient from an array of IValueGradient
  88039. * @param ratio defines the current ratio to get
  88040. * @param gradients defines the array of IValueGradient
  88041. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  88042. */
  88043. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  88044. }
  88045. /**
  88046. * This class is used to track a performance counter which is number based.
  88047. * The user has access to many properties which give statistics of different nature.
  88048. *
  88049. * The implementer can track two kinds of Performance Counter: time and count.
  88050. * 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.
  88051. * 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.
  88052. */
  88053. export class PerfCounter {
  88054. /**
  88055. * Gets or sets a global boolean to turn on and off all the counters
  88056. */
  88057. static Enabled: boolean;
  88058. /**
  88059. * Returns the smallest value ever
  88060. */
  88061. readonly min: number;
  88062. /**
  88063. * Returns the biggest value ever
  88064. */
  88065. readonly max: number;
  88066. /**
  88067. * Returns the average value since the performance counter is running
  88068. */
  88069. readonly average: number;
  88070. /**
  88071. * Returns the average value of the last second the counter was monitored
  88072. */
  88073. readonly lastSecAverage: number;
  88074. /**
  88075. * Returns the current value
  88076. */
  88077. readonly current: number;
  88078. /**
  88079. * Gets the accumulated total
  88080. */
  88081. readonly total: number;
  88082. /**
  88083. * Gets the total value count
  88084. */
  88085. readonly count: number;
  88086. /**
  88087. * Creates a new counter
  88088. */
  88089. constructor();
  88090. /**
  88091. * Call this method to start monitoring a new frame.
  88092. * 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.
  88093. */
  88094. fetchNewFrame(): void;
  88095. /**
  88096. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  88097. * @param newCount the count value to add to the monitored count
  88098. * @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.
  88099. */
  88100. addCount(newCount: number, fetchResult: boolean): void;
  88101. /**
  88102. * Start monitoring this performance counter
  88103. */
  88104. beginMonitoring(): void;
  88105. /**
  88106. * Compute the time lapsed since the previous beginMonitoring() call.
  88107. * @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
  88108. */
  88109. endMonitoring(newFrame?: boolean): void;
  88110. private _fetchResult;
  88111. private _startMonitoringTime;
  88112. private _min;
  88113. private _max;
  88114. private _average;
  88115. private _current;
  88116. private _totalValueCount;
  88117. private _totalAccumulated;
  88118. private _lastSecAverage;
  88119. private _lastSecAccumulated;
  88120. private _lastSecTime;
  88121. private _lastSecValueCount;
  88122. }
  88123. /**
  88124. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  88125. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  88126. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  88127. * @param name The name of the class, case should be preserved
  88128. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  88129. */
  88130. export function className(name: string, module?: string): (target: Object) => void;
  88131. /**
  88132. * An implementation of a loop for asynchronous functions.
  88133. */
  88134. export class AsyncLoop {
  88135. /**
  88136. * Defines the number of iterations for the loop
  88137. */
  88138. iterations: number;
  88139. /**
  88140. * Defines the current index of the loop.
  88141. */
  88142. index: number;
  88143. private _done;
  88144. private _fn;
  88145. private _successCallback;
  88146. /**
  88147. * Constructor.
  88148. * @param iterations the number of iterations.
  88149. * @param func the function to run each iteration
  88150. * @param successCallback the callback that will be called upon succesful execution
  88151. * @param offset starting offset.
  88152. */
  88153. constructor(
  88154. /**
  88155. * Defines the number of iterations for the loop
  88156. */
  88157. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  88158. /**
  88159. * Execute the next iteration. Must be called after the last iteration was finished.
  88160. */
  88161. executeNext(): void;
  88162. /**
  88163. * Break the loop and run the success callback.
  88164. */
  88165. breakLoop(): void;
  88166. /**
  88167. * Create and run an async loop.
  88168. * @param iterations the number of iterations.
  88169. * @param fn the function to run each iteration
  88170. * @param successCallback the callback that will be called upon succesful execution
  88171. * @param offset starting offset.
  88172. * @returns the created async loop object
  88173. */
  88174. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  88175. /**
  88176. * A for-loop that will run a given number of iterations synchronous and the rest async.
  88177. * @param iterations total number of iterations
  88178. * @param syncedIterations number of synchronous iterations in each async iteration.
  88179. * @param fn the function to call each iteration.
  88180. * @param callback a success call back that will be called when iterating stops.
  88181. * @param breakFunction a break condition (optional)
  88182. * @param timeout timeout settings for the setTimeout function. default - 0.
  88183. * @returns the created async loop object
  88184. */
  88185. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  88186. }
  88187. }
  88188. declare module BABYLON {
  88189. /** @hidden */
  88190. export interface ICollisionCoordinator {
  88191. createCollider(): Collider;
  88192. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  88193. init(scene: Scene): void;
  88194. }
  88195. /** @hidden */
  88196. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  88197. private _scene;
  88198. private _scaledPosition;
  88199. private _scaledVelocity;
  88200. private _finalPosition;
  88201. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  88202. createCollider(): Collider;
  88203. init(scene: Scene): void;
  88204. private _collideWithWorld;
  88205. }
  88206. }
  88207. declare module BABYLON {
  88208. /**
  88209. * This class defines the direct association between an animation and a target
  88210. */
  88211. export class TargetedAnimation {
  88212. /**
  88213. * Animation to perform
  88214. */
  88215. animation: Animation;
  88216. /**
  88217. * Target to animate
  88218. */
  88219. target: any;
  88220. }
  88221. /**
  88222. * Use this class to create coordinated animations on multiple targets
  88223. */
  88224. export class AnimationGroup implements IDisposable {
  88225. /** The name of the animation group */
  88226. name: string;
  88227. private _scene;
  88228. private _targetedAnimations;
  88229. private _animatables;
  88230. private _from;
  88231. private _to;
  88232. private _isStarted;
  88233. private _isPaused;
  88234. private _speedRatio;
  88235. /**
  88236. * Gets or sets the unique id of the node
  88237. */
  88238. uniqueId: number;
  88239. /**
  88240. * This observable will notify when one animation have ended
  88241. */
  88242. onAnimationEndObservable: Observable<TargetedAnimation>;
  88243. /**
  88244. * Observer raised when one animation loops
  88245. */
  88246. onAnimationLoopObservable: Observable<TargetedAnimation>;
  88247. /**
  88248. * This observable will notify when all animations have ended.
  88249. */
  88250. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  88251. /**
  88252. * This observable will notify when all animations have paused.
  88253. */
  88254. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  88255. /**
  88256. * This observable will notify when all animations are playing.
  88257. */
  88258. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  88259. /**
  88260. * Gets the first frame
  88261. */
  88262. readonly from: number;
  88263. /**
  88264. * Gets the last frame
  88265. */
  88266. readonly to: number;
  88267. /**
  88268. * Define if the animations are started
  88269. */
  88270. readonly isStarted: boolean;
  88271. /**
  88272. * Gets a value indicating that the current group is playing
  88273. */
  88274. readonly isPlaying: boolean;
  88275. /**
  88276. * Gets or sets the speed ratio to use for all animations
  88277. */
  88278. /**
  88279. * Gets or sets the speed ratio to use for all animations
  88280. */
  88281. speedRatio: number;
  88282. /**
  88283. * Gets the targeted animations for this animation group
  88284. */
  88285. readonly targetedAnimations: Array<TargetedAnimation>;
  88286. /**
  88287. * returning the list of animatables controlled by this animation group.
  88288. */
  88289. readonly animatables: Array<Animatable>;
  88290. /**
  88291. * Instantiates a new Animation Group.
  88292. * This helps managing several animations at once.
  88293. * @see http://doc.babylonjs.com/how_to/group
  88294. * @param name Defines the name of the group
  88295. * @param scene Defines the scene the group belongs to
  88296. */
  88297. constructor(
  88298. /** The name of the animation group */
  88299. name: string, scene?: Nullable<Scene>);
  88300. /**
  88301. * Add an animation (with its target) in the group
  88302. * @param animation defines the animation we want to add
  88303. * @param target defines the target of the animation
  88304. * @returns the TargetedAnimation object
  88305. */
  88306. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  88307. /**
  88308. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  88309. * It can add constant keys at begin or end
  88310. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  88311. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  88312. * @returns the animation group
  88313. */
  88314. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  88315. /**
  88316. * Start all animations on given targets
  88317. * @param loop defines if animations must loop
  88318. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  88319. * @param from defines the from key (optional)
  88320. * @param to defines the to key (optional)
  88321. * @returns the current animation group
  88322. */
  88323. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  88324. /**
  88325. * Pause all animations
  88326. * @returns the animation group
  88327. */
  88328. pause(): AnimationGroup;
  88329. /**
  88330. * Play all animations to initial state
  88331. * This function will start() the animations if they were not started or will restart() them if they were paused
  88332. * @param loop defines if animations must loop
  88333. * @returns the animation group
  88334. */
  88335. play(loop?: boolean): AnimationGroup;
  88336. /**
  88337. * Reset all animations to initial state
  88338. * @returns the animation group
  88339. */
  88340. reset(): AnimationGroup;
  88341. /**
  88342. * Restart animations from key 0
  88343. * @returns the animation group
  88344. */
  88345. restart(): AnimationGroup;
  88346. /**
  88347. * Stop all animations
  88348. * @returns the animation group
  88349. */
  88350. stop(): AnimationGroup;
  88351. /**
  88352. * Set animation weight for all animatables
  88353. * @param weight defines the weight to use
  88354. * @return the animationGroup
  88355. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  88356. */
  88357. setWeightForAllAnimatables(weight: number): AnimationGroup;
  88358. /**
  88359. * Synchronize and normalize all animatables with a source animatable
  88360. * @param root defines the root animatable to synchronize with
  88361. * @return the animationGroup
  88362. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  88363. */
  88364. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  88365. /**
  88366. * Goes to a specific frame in this animation group
  88367. * @param frame the frame number to go to
  88368. * @return the animationGroup
  88369. */
  88370. goToFrame(frame: number): AnimationGroup;
  88371. /**
  88372. * Dispose all associated resources
  88373. */
  88374. dispose(): void;
  88375. private _checkAnimationGroupEnded;
  88376. /**
  88377. * Clone the current animation group and returns a copy
  88378. * @param newName defines the name of the new group
  88379. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  88380. * @returns the new aniamtion group
  88381. */
  88382. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  88383. /**
  88384. * Returns a new AnimationGroup object parsed from the source provided.
  88385. * @param parsedAnimationGroup defines the source
  88386. * @param scene defines the scene that will receive the animationGroup
  88387. * @returns a new AnimationGroup
  88388. */
  88389. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  88390. /**
  88391. * Returns the string "AnimationGroup"
  88392. * @returns "AnimationGroup"
  88393. */
  88394. getClassName(): string;
  88395. /**
  88396. * Creates a detailled string about the object
  88397. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  88398. * @returns a string representing the object
  88399. */
  88400. toString(fullDetails?: boolean): string;
  88401. }
  88402. }
  88403. declare module BABYLON {
  88404. /**
  88405. * Define an interface for all classes that will hold resources
  88406. */
  88407. export interface IDisposable {
  88408. /**
  88409. * Releases all held resources
  88410. */
  88411. dispose(): void;
  88412. }
  88413. /** Interface defining initialization parameters for Scene class */
  88414. export interface SceneOptions {
  88415. /**
  88416. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  88417. * It will improve performance when the number of geometries becomes important.
  88418. */
  88419. useGeometryUniqueIdsMap?: boolean;
  88420. /**
  88421. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  88422. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  88423. */
  88424. useMaterialMeshMap?: boolean;
  88425. /**
  88426. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  88427. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  88428. */
  88429. useClonedMeshhMap?: boolean;
  88430. }
  88431. /**
  88432. * Represents a scene to be rendered by the engine.
  88433. * @see http://doc.babylonjs.com/features/scene
  88434. */
  88435. export class Scene extends AbstractScene implements IAnimatable {
  88436. private static _uniqueIdCounter;
  88437. /** The fog is deactivated */
  88438. static readonly FOGMODE_NONE: number;
  88439. /** The fog density is following an exponential function */
  88440. static readonly FOGMODE_EXP: number;
  88441. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  88442. static readonly FOGMODE_EXP2: number;
  88443. /** The fog density is following a linear function. */
  88444. static readonly FOGMODE_LINEAR: number;
  88445. /**
  88446. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  88447. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  88448. */
  88449. static MinDeltaTime: number;
  88450. /**
  88451. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  88452. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  88453. */
  88454. static MaxDeltaTime: number;
  88455. /**
  88456. * Factory used to create the default material.
  88457. * @param name The name of the material to create
  88458. * @param scene The scene to create the material for
  88459. * @returns The default material
  88460. */
  88461. static DefaultMaterialFactory(scene: Scene): Material;
  88462. /**
  88463. * Factory used to create the a collision coordinator.
  88464. * @returns The collision coordinator
  88465. */
  88466. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  88467. /** @hidden */
  88468. readonly _isScene: boolean;
  88469. /**
  88470. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  88471. */
  88472. autoClear: boolean;
  88473. /**
  88474. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  88475. */
  88476. autoClearDepthAndStencil: boolean;
  88477. /**
  88478. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  88479. */
  88480. clearColor: Color4;
  88481. /**
  88482. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  88483. */
  88484. ambientColor: Color3;
  88485. /** @hidden */
  88486. _environmentBRDFTexture: BaseTexture;
  88487. /** @hidden */
  88488. protected _environmentTexture: Nullable<BaseTexture>;
  88489. /**
  88490. * Texture used in all pbr material as the reflection texture.
  88491. * As in the majority of the scene they are the same (exception for multi room and so on),
  88492. * this is easier to reference from here than from all the materials.
  88493. */
  88494. /**
  88495. * Texture used in all pbr material as the reflection texture.
  88496. * As in the majority of the scene they are the same (exception for multi room and so on),
  88497. * this is easier to set here than in all the materials.
  88498. */
  88499. environmentTexture: Nullable<BaseTexture>;
  88500. /** @hidden */
  88501. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  88502. /**
  88503. * Default image processing configuration used either in the rendering
  88504. * Forward main pass or through the imageProcessingPostProcess if present.
  88505. * As in the majority of the scene they are the same (exception for multi camera),
  88506. * this is easier to reference from here than from all the materials and post process.
  88507. *
  88508. * No setter as we it is a shared configuration, you can set the values instead.
  88509. */
  88510. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  88511. private _forceWireframe;
  88512. /**
  88513. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  88514. */
  88515. forceWireframe: boolean;
  88516. private _forcePointsCloud;
  88517. /**
  88518. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  88519. */
  88520. forcePointsCloud: boolean;
  88521. /**
  88522. * Gets or sets the active clipplane 1
  88523. */
  88524. clipPlane: Nullable<Plane>;
  88525. /**
  88526. * Gets or sets the active clipplane 2
  88527. */
  88528. clipPlane2: Nullable<Plane>;
  88529. /**
  88530. * Gets or sets the active clipplane 3
  88531. */
  88532. clipPlane3: Nullable<Plane>;
  88533. /**
  88534. * Gets or sets the active clipplane 4
  88535. */
  88536. clipPlane4: Nullable<Plane>;
  88537. /**
  88538. * Gets or sets a boolean indicating if animations are enabled
  88539. */
  88540. animationsEnabled: boolean;
  88541. private _animationPropertiesOverride;
  88542. /**
  88543. * Gets or sets the animation properties override
  88544. */
  88545. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  88546. /**
  88547. * Gets or sets a boolean indicating if a constant deltatime has to be used
  88548. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  88549. */
  88550. useConstantAnimationDeltaTime: boolean;
  88551. /**
  88552. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  88553. * Please note that it requires to run a ray cast through the scene on every frame
  88554. */
  88555. constantlyUpdateMeshUnderPointer: boolean;
  88556. /**
  88557. * Defines the HTML cursor to use when hovering over interactive elements
  88558. */
  88559. hoverCursor: string;
  88560. /**
  88561. * Defines the HTML default cursor to use (empty by default)
  88562. */
  88563. defaultCursor: string;
  88564. /**
  88565. * This is used to call preventDefault() on pointer down
  88566. * in order to block unwanted artifacts like system double clicks
  88567. */
  88568. preventDefaultOnPointerDown: boolean;
  88569. /**
  88570. * This is used to call preventDefault() on pointer up
  88571. * in order to block unwanted artifacts like system double clicks
  88572. */
  88573. preventDefaultOnPointerUp: boolean;
  88574. /**
  88575. * Gets or sets user defined metadata
  88576. */
  88577. metadata: any;
  88578. /**
  88579. * For internal use only. Please do not use.
  88580. */
  88581. reservedDataStore: any;
  88582. /**
  88583. * Gets the name of the plugin used to load this scene (null by default)
  88584. */
  88585. loadingPluginName: string;
  88586. /**
  88587. * Use this array to add regular expressions used to disable offline support for specific urls
  88588. */
  88589. disableOfflineSupportExceptionRules: RegExp[];
  88590. /**
  88591. * An event triggered when the scene is disposed.
  88592. */
  88593. onDisposeObservable: Observable<Scene>;
  88594. private _onDisposeObserver;
  88595. /** Sets a function to be executed when this scene is disposed. */
  88596. onDispose: () => void;
  88597. /**
  88598. * An event triggered before rendering the scene (right after animations and physics)
  88599. */
  88600. onBeforeRenderObservable: Observable<Scene>;
  88601. private _onBeforeRenderObserver;
  88602. /** Sets a function to be executed before rendering this scene */
  88603. beforeRender: Nullable<() => void>;
  88604. /**
  88605. * An event triggered after rendering the scene
  88606. */
  88607. onAfterRenderObservable: Observable<Scene>;
  88608. private _onAfterRenderObserver;
  88609. /** Sets a function to be executed after rendering this scene */
  88610. afterRender: Nullable<() => void>;
  88611. /**
  88612. * An event triggered before animating the scene
  88613. */
  88614. onBeforeAnimationsObservable: Observable<Scene>;
  88615. /**
  88616. * An event triggered after animations processing
  88617. */
  88618. onAfterAnimationsObservable: Observable<Scene>;
  88619. /**
  88620. * An event triggered before draw calls are ready to be sent
  88621. */
  88622. onBeforeDrawPhaseObservable: Observable<Scene>;
  88623. /**
  88624. * An event triggered after draw calls have been sent
  88625. */
  88626. onAfterDrawPhaseObservable: Observable<Scene>;
  88627. /**
  88628. * An event triggered when the scene is ready
  88629. */
  88630. onReadyObservable: Observable<Scene>;
  88631. /**
  88632. * An event triggered before rendering a camera
  88633. */
  88634. onBeforeCameraRenderObservable: Observable<Camera>;
  88635. private _onBeforeCameraRenderObserver;
  88636. /** Sets a function to be executed before rendering a camera*/
  88637. beforeCameraRender: () => void;
  88638. /**
  88639. * An event triggered after rendering a camera
  88640. */
  88641. onAfterCameraRenderObservable: Observable<Camera>;
  88642. private _onAfterCameraRenderObserver;
  88643. /** Sets a function to be executed after rendering a camera*/
  88644. afterCameraRender: () => void;
  88645. /**
  88646. * An event triggered when active meshes evaluation is about to start
  88647. */
  88648. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  88649. /**
  88650. * An event triggered when active meshes evaluation is done
  88651. */
  88652. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  88653. /**
  88654. * An event triggered when particles rendering is about to start
  88655. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  88656. */
  88657. onBeforeParticlesRenderingObservable: Observable<Scene>;
  88658. /**
  88659. * An event triggered when particles rendering is done
  88660. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  88661. */
  88662. onAfterParticlesRenderingObservable: Observable<Scene>;
  88663. /**
  88664. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  88665. */
  88666. onDataLoadedObservable: Observable<Scene>;
  88667. /**
  88668. * An event triggered when a camera is created
  88669. */
  88670. onNewCameraAddedObservable: Observable<Camera>;
  88671. /**
  88672. * An event triggered when a camera is removed
  88673. */
  88674. onCameraRemovedObservable: Observable<Camera>;
  88675. /**
  88676. * An event triggered when a light is created
  88677. */
  88678. onNewLightAddedObservable: Observable<Light>;
  88679. /**
  88680. * An event triggered when a light is removed
  88681. */
  88682. onLightRemovedObservable: Observable<Light>;
  88683. /**
  88684. * An event triggered when a geometry is created
  88685. */
  88686. onNewGeometryAddedObservable: Observable<Geometry>;
  88687. /**
  88688. * An event triggered when a geometry is removed
  88689. */
  88690. onGeometryRemovedObservable: Observable<Geometry>;
  88691. /**
  88692. * An event triggered when a transform node is created
  88693. */
  88694. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  88695. /**
  88696. * An event triggered when a transform node is removed
  88697. */
  88698. onTransformNodeRemovedObservable: Observable<TransformNode>;
  88699. /**
  88700. * An event triggered when a mesh is created
  88701. */
  88702. onNewMeshAddedObservable: Observable<AbstractMesh>;
  88703. /**
  88704. * An event triggered when a mesh is removed
  88705. */
  88706. onMeshRemovedObservable: Observable<AbstractMesh>;
  88707. /**
  88708. * An event triggered when a material is created
  88709. */
  88710. onNewMaterialAddedObservable: Observable<Material>;
  88711. /**
  88712. * An event triggered when a material is removed
  88713. */
  88714. onMaterialRemovedObservable: Observable<Material>;
  88715. /**
  88716. * An event triggered when a texture is created
  88717. */
  88718. onNewTextureAddedObservable: Observable<BaseTexture>;
  88719. /**
  88720. * An event triggered when a texture is removed
  88721. */
  88722. onTextureRemovedObservable: Observable<BaseTexture>;
  88723. /**
  88724. * An event triggered when render targets are about to be rendered
  88725. * Can happen multiple times per frame.
  88726. */
  88727. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  88728. /**
  88729. * An event triggered when render targets were rendered.
  88730. * Can happen multiple times per frame.
  88731. */
  88732. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  88733. /**
  88734. * An event triggered before calculating deterministic simulation step
  88735. */
  88736. onBeforeStepObservable: Observable<Scene>;
  88737. /**
  88738. * An event triggered after calculating deterministic simulation step
  88739. */
  88740. onAfterStepObservable: Observable<Scene>;
  88741. /**
  88742. * An event triggered when the activeCamera property is updated
  88743. */
  88744. onActiveCameraChanged: Observable<Scene>;
  88745. /**
  88746. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  88747. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  88748. * 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)
  88749. */
  88750. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  88751. /**
  88752. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  88753. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  88754. * 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)
  88755. */
  88756. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  88757. /**
  88758. * This Observable will when a mesh has been imported into the scene.
  88759. */
  88760. onMeshImportedObservable: Observable<AbstractMesh>;
  88761. /**
  88762. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  88763. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  88764. */
  88765. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  88766. /** @hidden */
  88767. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  88768. /**
  88769. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  88770. */
  88771. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  88772. /**
  88773. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  88774. */
  88775. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  88776. /**
  88777. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  88778. */
  88779. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  88780. private _onPointerMove;
  88781. private _onPointerDown;
  88782. private _onPointerUp;
  88783. /** Callback called when a pointer move is detected */
  88784. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  88785. /** Callback called when a pointer down is detected */
  88786. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  88787. /** Callback called when a pointer up is detected */
  88788. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  88789. /** Callback called when a pointer pick is detected */
  88790. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  88791. /**
  88792. * 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).
  88793. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  88794. */
  88795. onPrePointerObservable: Observable<PointerInfoPre>;
  88796. /**
  88797. * Observable event triggered each time an input event is received from the rendering canvas
  88798. */
  88799. onPointerObservable: Observable<PointerInfo>;
  88800. /**
  88801. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  88802. */
  88803. readonly unTranslatedPointer: Vector2;
  88804. /** The distance in pixel that you have to move to prevent some events */
  88805. static DragMovementThreshold: number;
  88806. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  88807. static LongPressDelay: number;
  88808. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  88809. static DoubleClickDelay: number;
  88810. /** If you need to check double click without raising a single click at first click, enable this flag */
  88811. static ExclusiveDoubleClickMode: boolean;
  88812. private _initClickEvent;
  88813. private _initActionManager;
  88814. private _delayedSimpleClick;
  88815. private _delayedSimpleClickTimeout;
  88816. private _previousDelayedSimpleClickTimeout;
  88817. private _meshPickProceed;
  88818. private _previousButtonPressed;
  88819. private _currentPickResult;
  88820. private _previousPickResult;
  88821. private _totalPointersPressed;
  88822. private _doubleClickOccured;
  88823. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  88824. cameraToUseForPointers: Nullable<Camera>;
  88825. private _pointerX;
  88826. private _pointerY;
  88827. private _unTranslatedPointerX;
  88828. private _unTranslatedPointerY;
  88829. private _startingPointerPosition;
  88830. private _previousStartingPointerPosition;
  88831. private _startingPointerTime;
  88832. private _previousStartingPointerTime;
  88833. private _pointerCaptures;
  88834. private _timeAccumulator;
  88835. private _currentStepId;
  88836. private _currentInternalStep;
  88837. /** @hidden */
  88838. _mirroredCameraPosition: Nullable<Vector3>;
  88839. /**
  88840. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  88841. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  88842. */
  88843. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  88844. /**
  88845. * Observable event triggered each time an keyboard event is received from the hosting window
  88846. */
  88847. onKeyboardObservable: Observable<KeyboardInfo>;
  88848. private _onKeyDown;
  88849. private _onKeyUp;
  88850. private _onCanvasFocusObserver;
  88851. private _onCanvasBlurObserver;
  88852. private _useRightHandedSystem;
  88853. /**
  88854. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  88855. */
  88856. useRightHandedSystem: boolean;
  88857. /**
  88858. * Sets the step Id used by deterministic lock step
  88859. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  88860. * @param newStepId defines the step Id
  88861. */
  88862. setStepId(newStepId: number): void;
  88863. /**
  88864. * Gets the step Id used by deterministic lock step
  88865. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  88866. * @returns the step Id
  88867. */
  88868. getStepId(): number;
  88869. /**
  88870. * Gets the internal step used by deterministic lock step
  88871. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  88872. * @returns the internal step
  88873. */
  88874. getInternalStep(): number;
  88875. private _fogEnabled;
  88876. /**
  88877. * Gets or sets a boolean indicating if fog is enabled on this scene
  88878. * @see http://doc.babylonjs.com/babylon101/environment#fog
  88879. * (Default is true)
  88880. */
  88881. fogEnabled: boolean;
  88882. private _fogMode;
  88883. /**
  88884. * Gets or sets the fog mode to use
  88885. * @see http://doc.babylonjs.com/babylon101/environment#fog
  88886. * | mode | value |
  88887. * | --- | --- |
  88888. * | FOGMODE_NONE | 0 |
  88889. * | FOGMODE_EXP | 1 |
  88890. * | FOGMODE_EXP2 | 2 |
  88891. * | FOGMODE_LINEAR | 3 |
  88892. */
  88893. fogMode: number;
  88894. /**
  88895. * Gets or sets the fog color to use
  88896. * @see http://doc.babylonjs.com/babylon101/environment#fog
  88897. * (Default is Color3(0.2, 0.2, 0.3))
  88898. */
  88899. fogColor: Color3;
  88900. /**
  88901. * Gets or sets the fog density to use
  88902. * @see http://doc.babylonjs.com/babylon101/environment#fog
  88903. * (Default is 0.1)
  88904. */
  88905. fogDensity: number;
  88906. /**
  88907. * Gets or sets the fog start distance to use
  88908. * @see http://doc.babylonjs.com/babylon101/environment#fog
  88909. * (Default is 0)
  88910. */
  88911. fogStart: number;
  88912. /**
  88913. * Gets or sets the fog end distance to use
  88914. * @see http://doc.babylonjs.com/babylon101/environment#fog
  88915. * (Default is 1000)
  88916. */
  88917. fogEnd: number;
  88918. private _shadowsEnabled;
  88919. /**
  88920. * Gets or sets a boolean indicating if shadows are enabled on this scene
  88921. */
  88922. shadowsEnabled: boolean;
  88923. private _lightsEnabled;
  88924. /**
  88925. * Gets or sets a boolean indicating if lights are enabled on this scene
  88926. */
  88927. lightsEnabled: boolean;
  88928. /** All of the active cameras added to this scene. */
  88929. activeCameras: Camera[];
  88930. private _activeCamera;
  88931. /** Gets or sets the current active camera */
  88932. activeCamera: Nullable<Camera>;
  88933. private _defaultMaterial;
  88934. /** The default material used on meshes when no material is affected */
  88935. /** The default material used on meshes when no material is affected */
  88936. defaultMaterial: Material;
  88937. private _texturesEnabled;
  88938. /**
  88939. * Gets or sets a boolean indicating if textures are enabled on this scene
  88940. */
  88941. texturesEnabled: boolean;
  88942. /**
  88943. * Gets or sets a boolean indicating if particles are enabled on this scene
  88944. */
  88945. particlesEnabled: boolean;
  88946. /**
  88947. * Gets or sets a boolean indicating if sprites are enabled on this scene
  88948. */
  88949. spritesEnabled: boolean;
  88950. private _skeletonsEnabled;
  88951. /**
  88952. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  88953. */
  88954. skeletonsEnabled: boolean;
  88955. /**
  88956. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  88957. */
  88958. lensFlaresEnabled: boolean;
  88959. /**
  88960. * Gets or sets a boolean indicating if collisions are enabled on this scene
  88961. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  88962. */
  88963. collisionsEnabled: boolean;
  88964. private _collisionCoordinator;
  88965. /** @hidden */
  88966. readonly collisionCoordinator: ICollisionCoordinator;
  88967. /**
  88968. * Defines the gravity applied to this scene (used only for collisions)
  88969. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  88970. */
  88971. gravity: Vector3;
  88972. /**
  88973. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  88974. */
  88975. postProcessesEnabled: boolean;
  88976. /**
  88977. * The list of postprocesses added to the scene
  88978. */
  88979. postProcesses: PostProcess[];
  88980. /**
  88981. * Gets the current postprocess manager
  88982. */
  88983. postProcessManager: PostProcessManager;
  88984. /**
  88985. * Gets or sets a boolean indicating if render targets are enabled on this scene
  88986. */
  88987. renderTargetsEnabled: boolean;
  88988. /**
  88989. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  88990. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  88991. */
  88992. dumpNextRenderTargets: boolean;
  88993. /**
  88994. * The list of user defined render targets added to the scene
  88995. */
  88996. customRenderTargets: RenderTargetTexture[];
  88997. /**
  88998. * Defines if texture loading must be delayed
  88999. * If true, textures will only be loaded when they need to be rendered
  89000. */
  89001. useDelayedTextureLoading: boolean;
  89002. /**
  89003. * Gets the list of meshes imported to the scene through SceneLoader
  89004. */
  89005. importedMeshesFiles: String[];
  89006. /**
  89007. * Gets or sets a boolean indicating if probes are enabled on this scene
  89008. */
  89009. probesEnabled: boolean;
  89010. /**
  89011. * Gets or sets the current offline provider to use to store scene data
  89012. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  89013. */
  89014. offlineProvider: IOfflineProvider;
  89015. /**
  89016. * Gets or sets the action manager associated with the scene
  89017. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  89018. */
  89019. actionManager: AbstractActionManager;
  89020. private _meshesForIntersections;
  89021. /**
  89022. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  89023. */
  89024. proceduralTexturesEnabled: boolean;
  89025. private _engine;
  89026. private _totalVertices;
  89027. /** @hidden */
  89028. _activeIndices: PerfCounter;
  89029. /** @hidden */
  89030. _activeParticles: PerfCounter;
  89031. /** @hidden */
  89032. _activeBones: PerfCounter;
  89033. private _animationRatio;
  89034. /** @hidden */
  89035. _animationTimeLast: number;
  89036. /** @hidden */
  89037. _animationTime: number;
  89038. /**
  89039. * Gets or sets a general scale for animation speed
  89040. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  89041. */
  89042. animationTimeScale: number;
  89043. /** @hidden */
  89044. _cachedMaterial: Nullable<Material>;
  89045. /** @hidden */
  89046. _cachedEffect: Nullable<Effect>;
  89047. /** @hidden */
  89048. _cachedVisibility: Nullable<number>;
  89049. private _renderId;
  89050. private _frameId;
  89051. private _executeWhenReadyTimeoutId;
  89052. private _intermediateRendering;
  89053. private _viewUpdateFlag;
  89054. private _projectionUpdateFlag;
  89055. private _alternateViewUpdateFlag;
  89056. private _alternateProjectionUpdateFlag;
  89057. /** @hidden */
  89058. _toBeDisposed: Nullable<IDisposable>[];
  89059. private _activeRequests;
  89060. /** @hidden */
  89061. _pendingData: any[];
  89062. private _isDisposed;
  89063. /**
  89064. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  89065. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  89066. */
  89067. dispatchAllSubMeshesOfActiveMeshes: boolean;
  89068. private _activeMeshes;
  89069. private _processedMaterials;
  89070. private _renderTargets;
  89071. /** @hidden */
  89072. _activeParticleSystems: SmartArray<IParticleSystem>;
  89073. private _activeSkeletons;
  89074. private _softwareSkinnedMeshes;
  89075. private _renderingManager;
  89076. /** @hidden */
  89077. _activeAnimatables: Animatable[];
  89078. private _transformMatrix;
  89079. private _sceneUbo;
  89080. private _alternateSceneUbo;
  89081. private _viewMatrix;
  89082. private _projectionMatrix;
  89083. private _alternateViewMatrix;
  89084. private _alternateProjectionMatrix;
  89085. private _alternateTransformMatrix;
  89086. private _useAlternateCameraConfiguration;
  89087. private _alternateRendering;
  89088. private _wheelEventName;
  89089. /** @hidden */
  89090. _forcedViewPosition: Nullable<Vector3>;
  89091. /** @hidden */
  89092. readonly _isAlternateRenderingEnabled: boolean;
  89093. private _frustumPlanes;
  89094. /**
  89095. * Gets the list of frustum planes (built from the active camera)
  89096. */
  89097. readonly frustumPlanes: Plane[];
  89098. /**
  89099. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  89100. * This is useful if there are more lights that the maximum simulteanous authorized
  89101. */
  89102. requireLightSorting: boolean;
  89103. /** @hidden */
  89104. readonly useMaterialMeshMap: boolean;
  89105. /** @hidden */
  89106. readonly useClonedMeshhMap: boolean;
  89107. private _pointerOverMesh;
  89108. private _pickedDownMesh;
  89109. private _pickedUpMesh;
  89110. private _externalData;
  89111. private _uid;
  89112. /**
  89113. * @hidden
  89114. * Backing store of defined scene components.
  89115. */
  89116. _components: ISceneComponent[];
  89117. /**
  89118. * @hidden
  89119. * Backing store of defined scene components.
  89120. */
  89121. _serializableComponents: ISceneSerializableComponent[];
  89122. /**
  89123. * List of components to register on the next registration step.
  89124. */
  89125. private _transientComponents;
  89126. /**
  89127. * Registers the transient components if needed.
  89128. */
  89129. private _registerTransientComponents;
  89130. /**
  89131. * @hidden
  89132. * Add a component to the scene.
  89133. * Note that the ccomponent could be registered on th next frame if this is called after
  89134. * the register component stage.
  89135. * @param component Defines the component to add to the scene
  89136. */
  89137. _addComponent(component: ISceneComponent): void;
  89138. /**
  89139. * @hidden
  89140. * Gets a component from the scene.
  89141. * @param name defines the name of the component to retrieve
  89142. * @returns the component or null if not present
  89143. */
  89144. _getComponent(name: string): Nullable<ISceneComponent>;
  89145. /**
  89146. * @hidden
  89147. * Defines the actions happening before camera updates.
  89148. */
  89149. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  89150. /**
  89151. * @hidden
  89152. * Defines the actions happening before clear the canvas.
  89153. */
  89154. _beforeClearStage: Stage<SimpleStageAction>;
  89155. /**
  89156. * @hidden
  89157. * Defines the actions when collecting render targets for the frame.
  89158. */
  89159. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  89160. /**
  89161. * @hidden
  89162. * Defines the actions happening for one camera in the frame.
  89163. */
  89164. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  89165. /**
  89166. * @hidden
  89167. * Defines the actions happening during the per mesh ready checks.
  89168. */
  89169. _isReadyForMeshStage: Stage<MeshStageAction>;
  89170. /**
  89171. * @hidden
  89172. * Defines the actions happening before evaluate active mesh checks.
  89173. */
  89174. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  89175. /**
  89176. * @hidden
  89177. * Defines the actions happening during the evaluate sub mesh checks.
  89178. */
  89179. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  89180. /**
  89181. * @hidden
  89182. * Defines the actions happening during the active mesh stage.
  89183. */
  89184. _activeMeshStage: Stage<ActiveMeshStageAction>;
  89185. /**
  89186. * @hidden
  89187. * Defines the actions happening during the per camera render target step.
  89188. */
  89189. _cameraDrawRenderTargetStage: Stage<CameraStageAction>;
  89190. /**
  89191. * @hidden
  89192. * Defines the actions happening just before the active camera is drawing.
  89193. */
  89194. _beforeCameraDrawStage: Stage<CameraStageAction>;
  89195. /**
  89196. * @hidden
  89197. * Defines the actions happening just before a render target is drawing.
  89198. */
  89199. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  89200. /**
  89201. * @hidden
  89202. * Defines the actions happening just before a rendering group is drawing.
  89203. */
  89204. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  89205. /**
  89206. * @hidden
  89207. * Defines the actions happening just before a mesh is drawing.
  89208. */
  89209. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  89210. /**
  89211. * @hidden
  89212. * Defines the actions happening just after a mesh has been drawn.
  89213. */
  89214. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  89215. /**
  89216. * @hidden
  89217. * Defines the actions happening just after a rendering group has been drawn.
  89218. */
  89219. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  89220. /**
  89221. * @hidden
  89222. * Defines the actions happening just after the active camera has been drawn.
  89223. */
  89224. _afterCameraDrawStage: Stage<CameraStageAction>;
  89225. /**
  89226. * @hidden
  89227. * Defines the actions happening just after a render target has been drawn.
  89228. */
  89229. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  89230. /**
  89231. * @hidden
  89232. * Defines the actions happening just after rendering all cameras and computing intersections.
  89233. */
  89234. _afterRenderStage: Stage<SimpleStageAction>;
  89235. /**
  89236. * @hidden
  89237. * Defines the actions happening when a pointer move event happens.
  89238. */
  89239. _pointerMoveStage: Stage<PointerMoveStageAction>;
  89240. /**
  89241. * @hidden
  89242. * Defines the actions happening when a pointer down event happens.
  89243. */
  89244. _pointerDownStage: Stage<PointerUpDownStageAction>;
  89245. /**
  89246. * @hidden
  89247. * Defines the actions happening when a pointer up event happens.
  89248. */
  89249. _pointerUpStage: Stage<PointerUpDownStageAction>;
  89250. /**
  89251. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  89252. */
  89253. private geometriesByUniqueId;
  89254. /**
  89255. * Creates a new Scene
  89256. * @param engine defines the engine to use to render this scene
  89257. * @param options defines the scene options
  89258. */
  89259. constructor(engine: Engine, options?: SceneOptions);
  89260. private _defaultMeshCandidates;
  89261. /**
  89262. * @hidden
  89263. */
  89264. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  89265. private _defaultSubMeshCandidates;
  89266. /**
  89267. * @hidden
  89268. */
  89269. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  89270. /**
  89271. * Sets the default candidate providers for the scene.
  89272. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  89273. * and getCollidingSubMeshCandidates to their default function
  89274. */
  89275. setDefaultCandidateProviders(): void;
  89276. /**
  89277. * Gets the mesh that is currently under the pointer
  89278. */
  89279. readonly meshUnderPointer: Nullable<AbstractMesh>;
  89280. /**
  89281. * Gets or sets the current on-screen X position of the pointer
  89282. */
  89283. pointerX: number;
  89284. /**
  89285. * Gets or sets the current on-screen Y position of the pointer
  89286. */
  89287. pointerY: number;
  89288. /**
  89289. * Gets the cached material (ie. the latest rendered one)
  89290. * @returns the cached material
  89291. */
  89292. getCachedMaterial(): Nullable<Material>;
  89293. /**
  89294. * Gets the cached effect (ie. the latest rendered one)
  89295. * @returns the cached effect
  89296. */
  89297. getCachedEffect(): Nullable<Effect>;
  89298. /**
  89299. * Gets the cached visibility state (ie. the latest rendered one)
  89300. * @returns the cached visibility state
  89301. */
  89302. getCachedVisibility(): Nullable<number>;
  89303. /**
  89304. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  89305. * @param material defines the current material
  89306. * @param effect defines the current effect
  89307. * @param visibility defines the current visibility state
  89308. * @returns true if one parameter is not cached
  89309. */
  89310. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  89311. /**
  89312. * Gets the engine associated with the scene
  89313. * @returns an Engine
  89314. */
  89315. getEngine(): Engine;
  89316. /**
  89317. * Gets the total number of vertices rendered per frame
  89318. * @returns the total number of vertices rendered per frame
  89319. */
  89320. getTotalVertices(): number;
  89321. /**
  89322. * Gets the performance counter for total vertices
  89323. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  89324. */
  89325. readonly totalVerticesPerfCounter: PerfCounter;
  89326. /**
  89327. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  89328. * @returns the total number of active indices rendered per frame
  89329. */
  89330. getActiveIndices(): number;
  89331. /**
  89332. * Gets the performance counter for active indices
  89333. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  89334. */
  89335. readonly totalActiveIndicesPerfCounter: PerfCounter;
  89336. /**
  89337. * Gets the total number of active particles rendered per frame
  89338. * @returns the total number of active particles rendered per frame
  89339. */
  89340. getActiveParticles(): number;
  89341. /**
  89342. * Gets the performance counter for active particles
  89343. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  89344. */
  89345. readonly activeParticlesPerfCounter: PerfCounter;
  89346. /**
  89347. * Gets the total number of active bones rendered per frame
  89348. * @returns the total number of active bones rendered per frame
  89349. */
  89350. getActiveBones(): number;
  89351. /**
  89352. * Gets the performance counter for active bones
  89353. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  89354. */
  89355. readonly activeBonesPerfCounter: PerfCounter;
  89356. /**
  89357. * Gets the array of active meshes
  89358. * @returns an array of AbstractMesh
  89359. */
  89360. getActiveMeshes(): SmartArray<AbstractMesh>;
  89361. /**
  89362. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  89363. * @returns a number
  89364. */
  89365. getAnimationRatio(): number;
  89366. /**
  89367. * Gets an unique Id for the current render phase
  89368. * @returns a number
  89369. */
  89370. getRenderId(): number;
  89371. /**
  89372. * Gets an unique Id for the current frame
  89373. * @returns a number
  89374. */
  89375. getFrameId(): number;
  89376. /** Call this function if you want to manually increment the render Id*/
  89377. incrementRenderId(): void;
  89378. private _updatePointerPosition;
  89379. private _createUbo;
  89380. private _createAlternateUbo;
  89381. private _setRayOnPointerInfo;
  89382. /**
  89383. * Use this method to simulate a pointer move on a mesh
  89384. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  89385. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  89386. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  89387. * @returns the current scene
  89388. */
  89389. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  89390. private _processPointerMove;
  89391. private _checkPrePointerObservable;
  89392. /**
  89393. * Use this method to simulate a pointer down on a mesh
  89394. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  89395. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  89396. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  89397. * @returns the current scene
  89398. */
  89399. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  89400. private _processPointerDown;
  89401. /**
  89402. * Use this method to simulate a pointer up on a mesh
  89403. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  89404. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  89405. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  89406. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  89407. * @returns the current scene
  89408. */
  89409. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  89410. private _processPointerUp;
  89411. /**
  89412. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  89413. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  89414. * @returns true if the pointer was captured
  89415. */
  89416. isPointerCaptured(pointerId?: number): boolean;
  89417. /** @hidden */
  89418. _isPointerSwiping(): boolean;
  89419. /**
  89420. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  89421. * @param attachUp defines if you want to attach events to pointerup
  89422. * @param attachDown defines if you want to attach events to pointerdown
  89423. * @param attachMove defines if you want to attach events to pointermove
  89424. */
  89425. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  89426. /** Detaches all event handlers*/
  89427. detachControl(): void;
  89428. /**
  89429. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  89430. * Delay loaded resources are not taking in account
  89431. * @return true if all required resources are ready
  89432. */
  89433. isReady(): boolean;
  89434. /** Resets all cached information relative to material (including effect and visibility) */
  89435. resetCachedMaterial(): void;
  89436. /**
  89437. * Registers a function to be called before every frame render
  89438. * @param func defines the function to register
  89439. */
  89440. registerBeforeRender(func: () => void): void;
  89441. /**
  89442. * Unregisters a function called before every frame render
  89443. * @param func defines the function to unregister
  89444. */
  89445. unregisterBeforeRender(func: () => void): void;
  89446. /**
  89447. * Registers a function to be called after every frame render
  89448. * @param func defines the function to register
  89449. */
  89450. registerAfterRender(func: () => void): void;
  89451. /**
  89452. * Unregisters a function called after every frame render
  89453. * @param func defines the function to unregister
  89454. */
  89455. unregisterAfterRender(func: () => void): void;
  89456. private _executeOnceBeforeRender;
  89457. /**
  89458. * The provided function will run before render once and will be disposed afterwards.
  89459. * A timeout delay can be provided so that the function will be executed in N ms.
  89460. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  89461. * @param func The function to be executed.
  89462. * @param timeout optional delay in ms
  89463. */
  89464. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  89465. /** @hidden */
  89466. _addPendingData(data: any): void;
  89467. /** @hidden */
  89468. _removePendingData(data: any): void;
  89469. /**
  89470. * Returns the number of items waiting to be loaded
  89471. * @returns the number of items waiting to be loaded
  89472. */
  89473. getWaitingItemsCount(): number;
  89474. /**
  89475. * Returns a boolean indicating if the scene is still loading data
  89476. */
  89477. readonly isLoading: boolean;
  89478. /**
  89479. * Registers a function to be executed when the scene is ready
  89480. * @param {Function} func - the function to be executed
  89481. */
  89482. executeWhenReady(func: () => void): void;
  89483. /**
  89484. * Returns a promise that resolves when the scene is ready
  89485. * @returns A promise that resolves when the scene is ready
  89486. */
  89487. whenReadyAsync(): Promise<void>;
  89488. /** @hidden */
  89489. _checkIsReady(): void;
  89490. /**
  89491. * Gets all animatable attached to the scene
  89492. */
  89493. readonly animatables: Animatable[];
  89494. /**
  89495. * Resets the last animation time frame.
  89496. * Useful to override when animations start running when loading a scene for the first time.
  89497. */
  89498. resetLastAnimationTimeFrame(): void;
  89499. /** @hidden */
  89500. _switchToAlternateCameraConfiguration(active: boolean): void;
  89501. /**
  89502. * Gets the current view matrix
  89503. * @returns a Matrix
  89504. */
  89505. getViewMatrix(): Matrix;
  89506. /**
  89507. * Gets the current projection matrix
  89508. * @returns a Matrix
  89509. */
  89510. getProjectionMatrix(): Matrix;
  89511. /**
  89512. * Gets the current transform matrix
  89513. * @returns a Matrix made of View * Projection
  89514. */
  89515. getTransformMatrix(): Matrix;
  89516. /**
  89517. * Sets the current transform matrix
  89518. * @param view defines the View matrix to use
  89519. * @param projection defines the Projection matrix to use
  89520. */
  89521. setTransformMatrix(view: Matrix, projection: Matrix): void;
  89522. /** @hidden */
  89523. _setAlternateTransformMatrix(view: Matrix, projection: Matrix): void;
  89524. /**
  89525. * Gets the uniform buffer used to store scene data
  89526. * @returns a UniformBuffer
  89527. */
  89528. getSceneUniformBuffer(): UniformBuffer;
  89529. /**
  89530. * Gets an unique (relatively to the current scene) Id
  89531. * @returns an unique number for the scene
  89532. */
  89533. getUniqueId(): number;
  89534. /**
  89535. * Add a mesh to the list of scene's meshes
  89536. * @param newMesh defines the mesh to add
  89537. * @param recursive if all child meshes should also be added to the scene
  89538. */
  89539. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  89540. /**
  89541. * Remove a mesh for the list of scene's meshes
  89542. * @param toRemove defines the mesh to remove
  89543. * @param recursive if all child meshes should also be removed from the scene
  89544. * @returns the index where the mesh was in the mesh list
  89545. */
  89546. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  89547. /**
  89548. * Add a transform node to the list of scene's transform nodes
  89549. * @param newTransformNode defines the transform node to add
  89550. */
  89551. addTransformNode(newTransformNode: TransformNode): void;
  89552. /**
  89553. * Remove a transform node for the list of scene's transform nodes
  89554. * @param toRemove defines the transform node to remove
  89555. * @returns the index where the transform node was in the transform node list
  89556. */
  89557. removeTransformNode(toRemove: TransformNode): number;
  89558. /**
  89559. * Remove a skeleton for the list of scene's skeletons
  89560. * @param toRemove defines the skeleton to remove
  89561. * @returns the index where the skeleton was in the skeleton list
  89562. */
  89563. removeSkeleton(toRemove: Skeleton): number;
  89564. /**
  89565. * Remove a morph target for the list of scene's morph targets
  89566. * @param toRemove defines the morph target to remove
  89567. * @returns the index where the morph target was in the morph target list
  89568. */
  89569. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  89570. /**
  89571. * Remove a light for the list of scene's lights
  89572. * @param toRemove defines the light to remove
  89573. * @returns the index where the light was in the light list
  89574. */
  89575. removeLight(toRemove: Light): number;
  89576. /**
  89577. * Remove a camera for the list of scene's cameras
  89578. * @param toRemove defines the camera to remove
  89579. * @returns the index where the camera was in the camera list
  89580. */
  89581. removeCamera(toRemove: Camera): number;
  89582. /**
  89583. * Remove a particle system for the list of scene's particle systems
  89584. * @param toRemove defines the particle system to remove
  89585. * @returns the index where the particle system was in the particle system list
  89586. */
  89587. removeParticleSystem(toRemove: IParticleSystem): number;
  89588. /**
  89589. * Remove a animation for the list of scene's animations
  89590. * @param toRemove defines the animation to remove
  89591. * @returns the index where the animation was in the animation list
  89592. */
  89593. removeAnimation(toRemove: Animation): number;
  89594. /**
  89595. * Removes the given animation group from this scene.
  89596. * @param toRemove The animation group to remove
  89597. * @returns The index of the removed animation group
  89598. */
  89599. removeAnimationGroup(toRemove: AnimationGroup): number;
  89600. /**
  89601. * Removes the given multi-material from this scene.
  89602. * @param toRemove The multi-material to remove
  89603. * @returns The index of the removed multi-material
  89604. */
  89605. removeMultiMaterial(toRemove: MultiMaterial): number;
  89606. /**
  89607. * Removes the given material from this scene.
  89608. * @param toRemove The material to remove
  89609. * @returns The index of the removed material
  89610. */
  89611. removeMaterial(toRemove: Material): number;
  89612. /**
  89613. * Removes the given action manager from this scene.
  89614. * @param toRemove The action manager to remove
  89615. * @returns The index of the removed action manager
  89616. */
  89617. removeActionManager(toRemove: AbstractActionManager): number;
  89618. /**
  89619. * Removes the given texture from this scene.
  89620. * @param toRemove The texture to remove
  89621. * @returns The index of the removed texture
  89622. */
  89623. removeTexture(toRemove: BaseTexture): number;
  89624. /**
  89625. * Adds the given light to this scene
  89626. * @param newLight The light to add
  89627. */
  89628. addLight(newLight: Light): void;
  89629. /**
  89630. * Sorts the list list based on light priorities
  89631. */
  89632. sortLightsByPriority(): void;
  89633. /**
  89634. * Adds the given camera to this scene
  89635. * @param newCamera The camera to add
  89636. */
  89637. addCamera(newCamera: Camera): void;
  89638. /**
  89639. * Adds the given skeleton to this scene
  89640. * @param newSkeleton The skeleton to add
  89641. */
  89642. addSkeleton(newSkeleton: Skeleton): void;
  89643. /**
  89644. * Adds the given particle system to this scene
  89645. * @param newParticleSystem The particle system to add
  89646. */
  89647. addParticleSystem(newParticleSystem: IParticleSystem): void;
  89648. /**
  89649. * Adds the given animation to this scene
  89650. * @param newAnimation The animation to add
  89651. */
  89652. addAnimation(newAnimation: Animation): void;
  89653. /**
  89654. * Adds the given animation group to this scene.
  89655. * @param newAnimationGroup The animation group to add
  89656. */
  89657. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  89658. /**
  89659. * Adds the given multi-material to this scene
  89660. * @param newMultiMaterial The multi-material to add
  89661. */
  89662. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  89663. /**
  89664. * Adds the given material to this scene
  89665. * @param newMaterial The material to add
  89666. */
  89667. addMaterial(newMaterial: Material): void;
  89668. /**
  89669. * Adds the given morph target to this scene
  89670. * @param newMorphTargetManager The morph target to add
  89671. */
  89672. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  89673. /**
  89674. * Adds the given geometry to this scene
  89675. * @param newGeometry The geometry to add
  89676. */
  89677. addGeometry(newGeometry: Geometry): void;
  89678. /**
  89679. * Adds the given action manager to this scene
  89680. * @param newActionManager The action manager to add
  89681. */
  89682. addActionManager(newActionManager: AbstractActionManager): void;
  89683. /**
  89684. * Adds the given texture to this scene.
  89685. * @param newTexture The texture to add
  89686. */
  89687. addTexture(newTexture: BaseTexture): void;
  89688. /**
  89689. * Switch active camera
  89690. * @param newCamera defines the new active camera
  89691. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  89692. */
  89693. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  89694. /**
  89695. * sets the active camera of the scene using its ID
  89696. * @param id defines the camera's ID
  89697. * @return the new active camera or null if none found.
  89698. */
  89699. setActiveCameraByID(id: string): Nullable<Camera>;
  89700. /**
  89701. * sets the active camera of the scene using its name
  89702. * @param name defines the camera's name
  89703. * @returns the new active camera or null if none found.
  89704. */
  89705. setActiveCameraByName(name: string): Nullable<Camera>;
  89706. /**
  89707. * get an animation group using its name
  89708. * @param name defines the material's name
  89709. * @return the animation group or null if none found.
  89710. */
  89711. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  89712. /**
  89713. * get a material using its id
  89714. * @param id defines the material's ID
  89715. * @return the material or null if none found.
  89716. */
  89717. getMaterialByID(id: string): Nullable<Material>;
  89718. /**
  89719. * Gets a material using its name
  89720. * @param name defines the material's name
  89721. * @return the material or null if none found.
  89722. */
  89723. getMaterialByName(name: string): Nullable<Material>;
  89724. /**
  89725. * Gets a camera using its id
  89726. * @param id defines the id to look for
  89727. * @returns the camera or null if not found
  89728. */
  89729. getCameraByID(id: string): Nullable<Camera>;
  89730. /**
  89731. * Gets a camera using its unique id
  89732. * @param uniqueId defines the unique id to look for
  89733. * @returns the camera or null if not found
  89734. */
  89735. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  89736. /**
  89737. * Gets a camera using its name
  89738. * @param name defines the camera's name
  89739. * @return the camera or null if none found.
  89740. */
  89741. getCameraByName(name: string): Nullable<Camera>;
  89742. /**
  89743. * Gets a bone using its id
  89744. * @param id defines the bone's id
  89745. * @return the bone or null if not found
  89746. */
  89747. getBoneByID(id: string): Nullable<Bone>;
  89748. /**
  89749. * Gets a bone using its id
  89750. * @param name defines the bone's name
  89751. * @return the bone or null if not found
  89752. */
  89753. getBoneByName(name: string): Nullable<Bone>;
  89754. /**
  89755. * Gets a light node using its name
  89756. * @param name defines the the light's name
  89757. * @return the light or null if none found.
  89758. */
  89759. getLightByName(name: string): Nullable<Light>;
  89760. /**
  89761. * Gets a light node using its id
  89762. * @param id defines the light's id
  89763. * @return the light or null if none found.
  89764. */
  89765. getLightByID(id: string): Nullable<Light>;
  89766. /**
  89767. * Gets a light node using its scene-generated unique ID
  89768. * @param uniqueId defines the light's unique id
  89769. * @return the light or null if none found.
  89770. */
  89771. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  89772. /**
  89773. * Gets a particle system by id
  89774. * @param id defines the particle system id
  89775. * @return the corresponding system or null if none found
  89776. */
  89777. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  89778. /**
  89779. * Gets a geometry using its ID
  89780. * @param id defines the geometry's id
  89781. * @return the geometry or null if none found.
  89782. */
  89783. getGeometryByID(id: string): Nullable<Geometry>;
  89784. private _getGeometryByUniqueID;
  89785. /**
  89786. * Add a new geometry to this scene
  89787. * @param geometry defines the geometry to be added to the scene.
  89788. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  89789. * @return a boolean defining if the geometry was added or not
  89790. */
  89791. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  89792. /**
  89793. * Removes an existing geometry
  89794. * @param geometry defines the geometry to be removed from the scene
  89795. * @return a boolean defining if the geometry was removed or not
  89796. */
  89797. removeGeometry(geometry: Geometry): boolean;
  89798. /**
  89799. * Gets the list of geometries attached to the scene
  89800. * @returns an array of Geometry
  89801. */
  89802. getGeometries(): Geometry[];
  89803. /**
  89804. * Gets the first added mesh found of a given ID
  89805. * @param id defines the id to search for
  89806. * @return the mesh found or null if not found at all
  89807. */
  89808. getMeshByID(id: string): Nullable<AbstractMesh>;
  89809. /**
  89810. * Gets a list of meshes using their id
  89811. * @param id defines the id to search for
  89812. * @returns a list of meshes
  89813. */
  89814. getMeshesByID(id: string): Array<AbstractMesh>;
  89815. /**
  89816. * Gets the first added transform node found of a given ID
  89817. * @param id defines the id to search for
  89818. * @return the found transform node or null if not found at all.
  89819. */
  89820. getTransformNodeByID(id: string): Nullable<TransformNode>;
  89821. /**
  89822. * Gets a list of transform nodes using their id
  89823. * @param id defines the id to search for
  89824. * @returns a list of transform nodes
  89825. */
  89826. getTransformNodesByID(id: string): Array<TransformNode>;
  89827. /**
  89828. * Gets a mesh with its auto-generated unique id
  89829. * @param uniqueId defines the unique id to search for
  89830. * @return the found mesh or null if not found at all.
  89831. */
  89832. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  89833. /**
  89834. * Gets a the last added mesh using a given id
  89835. * @param id defines the id to search for
  89836. * @return the found mesh or null if not found at all.
  89837. */
  89838. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  89839. /**
  89840. * Gets a the last added node (Mesh, Camera, Light) using a given id
  89841. * @param id defines the id to search for
  89842. * @return the found node or null if not found at all
  89843. */
  89844. getLastEntryByID(id: string): Nullable<Node>;
  89845. /**
  89846. * Gets a node (Mesh, Camera, Light) using a given id
  89847. * @param id defines the id to search for
  89848. * @return the found node or null if not found at all
  89849. */
  89850. getNodeByID(id: string): Nullable<Node>;
  89851. /**
  89852. * Gets a node (Mesh, Camera, Light) using a given name
  89853. * @param name defines the name to search for
  89854. * @return the found node or null if not found at all.
  89855. */
  89856. getNodeByName(name: string): Nullable<Node>;
  89857. /**
  89858. * Gets a mesh using a given name
  89859. * @param name defines the name to search for
  89860. * @return the found mesh or null if not found at all.
  89861. */
  89862. getMeshByName(name: string): Nullable<AbstractMesh>;
  89863. /**
  89864. * Gets a transform node using a given name
  89865. * @param name defines the name to search for
  89866. * @return the found transform node or null if not found at all.
  89867. */
  89868. getTransformNodeByName(name: string): Nullable<TransformNode>;
  89869. /**
  89870. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  89871. * @param id defines the id to search for
  89872. * @return the found skeleton or null if not found at all.
  89873. */
  89874. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  89875. /**
  89876. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  89877. * @param id defines the id to search for
  89878. * @return the found skeleton or null if not found at all.
  89879. */
  89880. getSkeletonById(id: string): Nullable<Skeleton>;
  89881. /**
  89882. * Gets a skeleton using a given name
  89883. * @param name defines the name to search for
  89884. * @return the found skeleton or null if not found at all.
  89885. */
  89886. getSkeletonByName(name: string): Nullable<Skeleton>;
  89887. /**
  89888. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  89889. * @param id defines the id to search for
  89890. * @return the found morph target manager or null if not found at all.
  89891. */
  89892. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  89893. /**
  89894. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  89895. * @param id defines the id to search for
  89896. * @return the found morph target or null if not found at all.
  89897. */
  89898. getMorphTargetById(id: string): Nullable<MorphTarget>;
  89899. /**
  89900. * Gets a boolean indicating if the given mesh is active
  89901. * @param mesh defines the mesh to look for
  89902. * @returns true if the mesh is in the active list
  89903. */
  89904. isActiveMesh(mesh: AbstractMesh): boolean;
  89905. /**
  89906. * Return a unique id as a string which can serve as an identifier for the scene
  89907. */
  89908. readonly uid: string;
  89909. /**
  89910. * Add an externaly attached data from its key.
  89911. * This method call will fail and return false, if such key already exists.
  89912. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  89913. * @param key the unique key that identifies the data
  89914. * @param data the data object to associate to the key for this Engine instance
  89915. * @return true if no such key were already present and the data was added successfully, false otherwise
  89916. */
  89917. addExternalData<T>(key: string, data: T): boolean;
  89918. /**
  89919. * Get an externaly attached data from its key
  89920. * @param key the unique key that identifies the data
  89921. * @return the associated data, if present (can be null), or undefined if not present
  89922. */
  89923. getExternalData<T>(key: string): Nullable<T>;
  89924. /**
  89925. * Get an externaly attached data from its key, create it using a factory if it's not already present
  89926. * @param key the unique key that identifies the data
  89927. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  89928. * @return the associated data, can be null if the factory returned null.
  89929. */
  89930. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  89931. /**
  89932. * Remove an externaly attached data from the Engine instance
  89933. * @param key the unique key that identifies the data
  89934. * @return true if the data was successfully removed, false if it doesn't exist
  89935. */
  89936. removeExternalData(key: string): boolean;
  89937. private _evaluateSubMesh;
  89938. /**
  89939. * Clear the processed materials smart array preventing retention point in material dispose.
  89940. */
  89941. freeProcessedMaterials(): void;
  89942. private _preventFreeActiveMeshesAndRenderingGroups;
  89943. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  89944. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  89945. * when disposing several meshes in a row or a hierarchy of meshes.
  89946. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  89947. */
  89948. blockfreeActiveMeshesAndRenderingGroups: boolean;
  89949. /**
  89950. * Clear the active meshes smart array preventing retention point in mesh dispose.
  89951. */
  89952. freeActiveMeshes(): void;
  89953. /**
  89954. * Clear the info related to rendering groups preventing retention points during dispose.
  89955. */
  89956. freeRenderingGroups(): void;
  89957. /** @hidden */
  89958. _isInIntermediateRendering(): boolean;
  89959. /**
  89960. * Lambda returning the list of potentially active meshes.
  89961. */
  89962. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  89963. /**
  89964. * Lambda returning the list of potentially active sub meshes.
  89965. */
  89966. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  89967. /**
  89968. * Lambda returning the list of potentially intersecting sub meshes.
  89969. */
  89970. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  89971. /**
  89972. * Lambda returning the list of potentially colliding sub meshes.
  89973. */
  89974. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  89975. private _activeMeshesFrozen;
  89976. /**
  89977. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  89978. * @returns the current scene
  89979. */
  89980. freezeActiveMeshes(): Scene;
  89981. /**
  89982. * Use this function to restart evaluating active meshes on every frame
  89983. * @returns the current scene
  89984. */
  89985. unfreezeActiveMeshes(): Scene;
  89986. private _evaluateActiveMeshes;
  89987. private _activeMesh;
  89988. /**
  89989. * Update the transform matrix to update from the current active camera
  89990. * @param force defines a boolean used to force the update even if cache is up to date
  89991. */
  89992. updateTransformMatrix(force?: boolean): void;
  89993. /**
  89994. * 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)
  89995. * @param alternateCamera defines the camera to use
  89996. */
  89997. updateAlternateTransformMatrix(alternateCamera: Camera): void;
  89998. /** @hidden */
  89999. _allowPostProcessClearColor: boolean;
  90000. private _renderForCamera;
  90001. private _processSubCameras;
  90002. private _checkIntersections;
  90003. /** @hidden */
  90004. _advancePhysicsEngineStep(step: number): void;
  90005. /**
  90006. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  90007. */
  90008. getDeterministicFrameTime: () => number;
  90009. /** @hidden */
  90010. _animate(): void;
  90011. /**
  90012. * Render the scene
  90013. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  90014. */
  90015. render(updateCameras?: boolean): void;
  90016. /**
  90017. * Freeze all materials
  90018. * A frozen material will not be updatable but should be faster to render
  90019. */
  90020. freezeMaterials(): void;
  90021. /**
  90022. * Unfreeze all materials
  90023. * A frozen material will not be updatable but should be faster to render
  90024. */
  90025. unfreezeMaterials(): void;
  90026. /**
  90027. * Releases all held ressources
  90028. */
  90029. dispose(): void;
  90030. /**
  90031. * Gets if the scene is already disposed
  90032. */
  90033. readonly isDisposed: boolean;
  90034. /**
  90035. * Call this function to reduce memory footprint of the scene.
  90036. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  90037. */
  90038. clearCachedVertexData(): void;
  90039. /**
  90040. * This function will remove the local cached buffer data from texture.
  90041. * It will save memory but will prevent the texture from being rebuilt
  90042. */
  90043. cleanCachedTextureBuffer(): void;
  90044. /**
  90045. * Get the world extend vectors with an optional filter
  90046. *
  90047. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  90048. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  90049. */
  90050. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  90051. min: Vector3;
  90052. max: Vector3;
  90053. };
  90054. /**
  90055. * Creates a ray that can be used to pick in the scene
  90056. * @param x defines the x coordinate of the origin (on-screen)
  90057. * @param y defines the y coordinate of the origin (on-screen)
  90058. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  90059. * @param camera defines the camera to use for the picking
  90060. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  90061. * @returns a Ray
  90062. */
  90063. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  90064. /**
  90065. * Creates a ray that can be used to pick in the scene
  90066. * @param x defines the x coordinate of the origin (on-screen)
  90067. * @param y defines the y coordinate of the origin (on-screen)
  90068. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  90069. * @param result defines the ray where to store the picking ray
  90070. * @param camera defines the camera to use for the picking
  90071. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  90072. * @returns the current scene
  90073. */
  90074. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  90075. /**
  90076. * Creates a ray that can be used to pick in the scene
  90077. * @param x defines the x coordinate of the origin (on-screen)
  90078. * @param y defines the y coordinate of the origin (on-screen)
  90079. * @param camera defines the camera to use for the picking
  90080. * @returns a Ray
  90081. */
  90082. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  90083. /**
  90084. * Creates a ray that can be used to pick in the scene
  90085. * @param x defines the x coordinate of the origin (on-screen)
  90086. * @param y defines the y coordinate of the origin (on-screen)
  90087. * @param result defines the ray where to store the picking ray
  90088. * @param camera defines the camera to use for the picking
  90089. * @returns the current scene
  90090. */
  90091. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  90092. /** Launch a ray to try to pick a mesh in the scene
  90093. * @param x position on screen
  90094. * @param y position on screen
  90095. * @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
  90096. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  90097. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  90098. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  90099. * @returns a PickingInfo
  90100. */
  90101. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: (p0: Vector3, p1: Vector3, p2: Vector3) => boolean): Nullable<PickingInfo>;
  90102. /** Use the given ray to pick a mesh in the scene
  90103. * @param ray The ray to use to pick meshes
  90104. * @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
  90105. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  90106. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  90107. * @returns a PickingInfo
  90108. */
  90109. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  90110. /**
  90111. * Launch a ray to try to pick a mesh in the scene
  90112. * @param x X position on screen
  90113. * @param y Y position on screen
  90114. * @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
  90115. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  90116. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  90117. * @returns an array of PickingInfo
  90118. */
  90119. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  90120. /**
  90121. * Launch a ray to try to pick a mesh in the scene
  90122. * @param ray Ray to use
  90123. * @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
  90124. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  90125. * @returns an array of PickingInfo
  90126. */
  90127. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  90128. /**
  90129. * Force the value of meshUnderPointer
  90130. * @param mesh defines the mesh to use
  90131. */
  90132. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  90133. /**
  90134. * Gets the mesh under the pointer
  90135. * @returns a Mesh or null if no mesh is under the pointer
  90136. */
  90137. getPointerOverMesh(): Nullable<AbstractMesh>;
  90138. /** @hidden */
  90139. _rebuildGeometries(): void;
  90140. /** @hidden */
  90141. _rebuildTextures(): void;
  90142. private _getByTags;
  90143. /**
  90144. * Get a list of meshes by tags
  90145. * @param tagsQuery defines the tags query to use
  90146. * @param forEach defines a predicate used to filter results
  90147. * @returns an array of Mesh
  90148. */
  90149. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  90150. /**
  90151. * Get a list of cameras by tags
  90152. * @param tagsQuery defines the tags query to use
  90153. * @param forEach defines a predicate used to filter results
  90154. * @returns an array of Camera
  90155. */
  90156. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  90157. /**
  90158. * Get a list of lights by tags
  90159. * @param tagsQuery defines the tags query to use
  90160. * @param forEach defines a predicate used to filter results
  90161. * @returns an array of Light
  90162. */
  90163. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  90164. /**
  90165. * Get a list of materials by tags
  90166. * @param tagsQuery defines the tags query to use
  90167. * @param forEach defines a predicate used to filter results
  90168. * @returns an array of Material
  90169. */
  90170. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  90171. /**
  90172. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  90173. * This allowed control for front to back rendering or reversly depending of the special needs.
  90174. *
  90175. * @param renderingGroupId The rendering group id corresponding to its index
  90176. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  90177. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  90178. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  90179. */
  90180. 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;
  90181. /**
  90182. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  90183. *
  90184. * @param renderingGroupId The rendering group id corresponding to its index
  90185. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  90186. * @param depth Automatically clears depth between groups if true and autoClear is true.
  90187. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  90188. */
  90189. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  90190. /**
  90191. * Gets the current auto clear configuration for one rendering group of the rendering
  90192. * manager.
  90193. * @param index the rendering group index to get the information for
  90194. * @returns The auto clear setup for the requested rendering group
  90195. */
  90196. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  90197. private _blockMaterialDirtyMechanism;
  90198. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  90199. blockMaterialDirtyMechanism: boolean;
  90200. /**
  90201. * Will flag all materials as dirty to trigger new shader compilation
  90202. * @param flag defines the flag used to specify which material part must be marked as dirty
  90203. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  90204. */
  90205. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  90206. /** @hidden */
  90207. _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;
  90208. /** @hidden */
  90209. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  90210. }
  90211. }
  90212. declare module BABYLON {
  90213. /**
  90214. * Set of assets to keep when moving a scene into an asset container.
  90215. */
  90216. export class KeepAssets extends AbstractScene {
  90217. }
  90218. /**
  90219. * Container with a set of assets that can be added or removed from a scene.
  90220. */
  90221. export class AssetContainer extends AbstractScene {
  90222. /**
  90223. * The scene the AssetContainer belongs to.
  90224. */
  90225. scene: Scene;
  90226. /**
  90227. * Instantiates an AssetContainer.
  90228. * @param scene The scene the AssetContainer belongs to.
  90229. */
  90230. constructor(scene: Scene);
  90231. /**
  90232. * Adds all the assets from the container to the scene.
  90233. */
  90234. addAllToScene(): void;
  90235. /**
  90236. * Removes all the assets in the container from the scene
  90237. */
  90238. removeAllFromScene(): void;
  90239. /**
  90240. * Disposes all the assets in the container
  90241. */
  90242. dispose(): void;
  90243. private _moveAssets;
  90244. /**
  90245. * Removes all the assets contained in the scene and adds them to the container.
  90246. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  90247. */
  90248. moveAllFromScene(keepAssets?: KeepAssets): void;
  90249. /**
  90250. * 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.
  90251. * @returns the root mesh
  90252. */
  90253. createRootMesh(): Mesh;
  90254. }
  90255. }
  90256. declare module BABYLON {
  90257. /**
  90258. * Defines how the parser contract is defined.
  90259. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  90260. */
  90261. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  90262. /**
  90263. * Defines how the individual parser contract is defined.
  90264. * These parser can parse an individual asset
  90265. */
  90266. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  90267. /**
  90268. * Base class of the scene acting as a container for the different elements composing a scene.
  90269. * This class is dynamically extended by the different components of the scene increasing
  90270. * flexibility and reducing coupling
  90271. */
  90272. export abstract class AbstractScene {
  90273. /**
  90274. * Stores the list of available parsers in the application.
  90275. */
  90276. private static _BabylonFileParsers;
  90277. /**
  90278. * Stores the list of available individual parsers in the application.
  90279. */
  90280. private static _IndividualBabylonFileParsers;
  90281. /**
  90282. * Adds a parser in the list of available ones
  90283. * @param name Defines the name of the parser
  90284. * @param parser Defines the parser to add
  90285. */
  90286. static AddParser(name: string, parser: BabylonFileParser): void;
  90287. /**
  90288. * Gets a general parser from the list of avaialble ones
  90289. * @param name Defines the name of the parser
  90290. * @returns the requested parser or null
  90291. */
  90292. static GetParser(name: string): Nullable<BabylonFileParser>;
  90293. /**
  90294. * Adds n individual parser in the list of available ones
  90295. * @param name Defines the name of the parser
  90296. * @param parser Defines the parser to add
  90297. */
  90298. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  90299. /**
  90300. * Gets an individual parser from the list of avaialble ones
  90301. * @param name Defines the name of the parser
  90302. * @returns the requested parser or null
  90303. */
  90304. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  90305. /**
  90306. * Parser json data and populate both a scene and its associated container object
  90307. * @param jsonData Defines the data to parse
  90308. * @param scene Defines the scene to parse the data for
  90309. * @param container Defines the container attached to the parsing sequence
  90310. * @param rootUrl Defines the root url of the data
  90311. */
  90312. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  90313. /**
  90314. * Gets the list of root nodes (ie. nodes with no parent)
  90315. */
  90316. rootNodes: Node[];
  90317. /** All of the cameras added to this scene
  90318. * @see http://doc.babylonjs.com/babylon101/cameras
  90319. */
  90320. cameras: Camera[];
  90321. /**
  90322. * All of the lights added to this scene
  90323. * @see http://doc.babylonjs.com/babylon101/lights
  90324. */
  90325. lights: Light[];
  90326. /**
  90327. * All of the (abstract) meshes added to this scene
  90328. */
  90329. meshes: AbstractMesh[];
  90330. /**
  90331. * The list of skeletons added to the scene
  90332. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  90333. */
  90334. skeletons: Skeleton[];
  90335. /**
  90336. * All of the particle systems added to this scene
  90337. * @see http://doc.babylonjs.com/babylon101/particles
  90338. */
  90339. particleSystems: IParticleSystem[];
  90340. /**
  90341. * Gets a list of Animations associated with the scene
  90342. */
  90343. animations: Animation[];
  90344. /**
  90345. * All of the animation groups added to this scene
  90346. * @see http://doc.babylonjs.com/how_to/group
  90347. */
  90348. animationGroups: AnimationGroup[];
  90349. /**
  90350. * All of the multi-materials added to this scene
  90351. * @see http://doc.babylonjs.com/how_to/multi_materials
  90352. */
  90353. multiMaterials: MultiMaterial[];
  90354. /**
  90355. * All of the materials added to this scene
  90356. * In the context of a Scene, it is not supposed to be modified manually.
  90357. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  90358. * Note also that the order of the Material wihin the array is not significant and might change.
  90359. * @see http://doc.babylonjs.com/babylon101/materials
  90360. */
  90361. materials: Material[];
  90362. /**
  90363. * The list of morph target managers added to the scene
  90364. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  90365. */
  90366. morphTargetManagers: MorphTargetManager[];
  90367. /**
  90368. * The list of geometries used in the scene.
  90369. */
  90370. geometries: Geometry[];
  90371. /**
  90372. * All of the tranform nodes added to this scene
  90373. * In the context of a Scene, it is not supposed to be modified manually.
  90374. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  90375. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  90376. * @see http://doc.babylonjs.com/how_to/transformnode
  90377. */
  90378. transformNodes: TransformNode[];
  90379. /**
  90380. * ActionManagers available on the scene.
  90381. */
  90382. actionManagers: AbstractActionManager[];
  90383. /**
  90384. * Textures to keep.
  90385. */
  90386. textures: BaseTexture[];
  90387. }
  90388. }
  90389. declare module BABYLON {
  90390. /**
  90391. * Defines a sound that can be played in the application.
  90392. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  90393. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  90394. */
  90395. export class Sound {
  90396. /**
  90397. * The name of the sound in the scene.
  90398. */
  90399. name: string;
  90400. /**
  90401. * Does the sound autoplay once loaded.
  90402. */
  90403. autoplay: boolean;
  90404. /**
  90405. * Does the sound loop after it finishes playing once.
  90406. */
  90407. loop: boolean;
  90408. /**
  90409. * Does the sound use a custom attenuation curve to simulate the falloff
  90410. * happening when the source gets further away from the camera.
  90411. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  90412. */
  90413. useCustomAttenuation: boolean;
  90414. /**
  90415. * The sound track id this sound belongs to.
  90416. */
  90417. soundTrackId: number;
  90418. /**
  90419. * Is this sound currently played.
  90420. */
  90421. isPlaying: boolean;
  90422. /**
  90423. * Is this sound currently paused.
  90424. */
  90425. isPaused: boolean;
  90426. /**
  90427. * Does this sound enables spatial sound.
  90428. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  90429. */
  90430. spatialSound: boolean;
  90431. /**
  90432. * Define the reference distance the sound should be heard perfectly.
  90433. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  90434. */
  90435. refDistance: number;
  90436. /**
  90437. * Define the roll off factor of spatial sounds.
  90438. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  90439. */
  90440. rolloffFactor: number;
  90441. /**
  90442. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  90443. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  90444. */
  90445. maxDistance: number;
  90446. /**
  90447. * Define the distance attenuation model the sound will follow.
  90448. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  90449. */
  90450. distanceModel: string;
  90451. /**
  90452. * @hidden
  90453. * Back Compat
  90454. **/
  90455. onended: () => any;
  90456. /**
  90457. * Observable event when the current playing sound finishes.
  90458. */
  90459. onEndedObservable: Observable<Sound>;
  90460. private _panningModel;
  90461. private _playbackRate;
  90462. private _streaming;
  90463. private _startTime;
  90464. private _startOffset;
  90465. private _position;
  90466. /** @hidden */
  90467. _positionInEmitterSpace: boolean;
  90468. private _localDirection;
  90469. private _volume;
  90470. private _isReadyToPlay;
  90471. private _isDirectional;
  90472. private _readyToPlayCallback;
  90473. private _audioBuffer;
  90474. private _soundSource;
  90475. private _streamingSource;
  90476. private _soundPanner;
  90477. private _soundGain;
  90478. private _inputAudioNode;
  90479. private _outputAudioNode;
  90480. private _coneInnerAngle;
  90481. private _coneOuterAngle;
  90482. private _coneOuterGain;
  90483. private _scene;
  90484. private _connectedTransformNode;
  90485. private _customAttenuationFunction;
  90486. private _registerFunc;
  90487. private _isOutputConnected;
  90488. private _htmlAudioElement;
  90489. private _urlType;
  90490. /** @hidden */
  90491. static _SceneComponentInitialization: (scene: Scene) => void;
  90492. /**
  90493. * Create a sound and attach it to a scene
  90494. * @param name Name of your sound
  90495. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  90496. * @param scene defines the scene the sound belongs to
  90497. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  90498. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  90499. */
  90500. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  90501. /**
  90502. * Release the sound and its associated resources
  90503. */
  90504. dispose(): void;
  90505. /**
  90506. * Gets if the sounds is ready to be played or not.
  90507. * @returns true if ready, otherwise false
  90508. */
  90509. isReady(): boolean;
  90510. private _soundLoaded;
  90511. /**
  90512. * Sets the data of the sound from an audiobuffer
  90513. * @param audioBuffer The audioBuffer containing the data
  90514. */
  90515. setAudioBuffer(audioBuffer: AudioBuffer): void;
  90516. /**
  90517. * Updates the current sounds options such as maxdistance, loop...
  90518. * @param options A JSON object containing values named as the object properties
  90519. */
  90520. updateOptions(options: any): void;
  90521. private _createSpatialParameters;
  90522. private _updateSpatialParameters;
  90523. /**
  90524. * Switch the panning model to HRTF:
  90525. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  90526. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  90527. */
  90528. switchPanningModelToHRTF(): void;
  90529. /**
  90530. * Switch the panning model to Equal Power:
  90531. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  90532. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  90533. */
  90534. switchPanningModelToEqualPower(): void;
  90535. private _switchPanningModel;
  90536. /**
  90537. * Connect this sound to a sound track audio node like gain...
  90538. * @param soundTrackAudioNode the sound track audio node to connect to
  90539. */
  90540. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  90541. /**
  90542. * Transform this sound into a directional source
  90543. * @param coneInnerAngle Size of the inner cone in degree
  90544. * @param coneOuterAngle Size of the outer cone in degree
  90545. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  90546. */
  90547. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  90548. /**
  90549. * Gets or sets the inner angle for the directional cone.
  90550. */
  90551. /**
  90552. * Gets or sets the inner angle for the directional cone.
  90553. */
  90554. directionalConeInnerAngle: number;
  90555. /**
  90556. * Gets or sets the outer angle for the directional cone.
  90557. */
  90558. /**
  90559. * Gets or sets the outer angle for the directional cone.
  90560. */
  90561. directionalConeOuterAngle: number;
  90562. /**
  90563. * Sets the position of the emitter if spatial sound is enabled
  90564. * @param newPosition Defines the new posisiton
  90565. */
  90566. setPosition(newPosition: Vector3): void;
  90567. /**
  90568. * Sets the local direction of the emitter if spatial sound is enabled
  90569. * @param newLocalDirection Defines the new local direction
  90570. */
  90571. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  90572. private _updateDirection;
  90573. /** @hidden */
  90574. updateDistanceFromListener(): void;
  90575. /**
  90576. * Sets a new custom attenuation function for the sound.
  90577. * @param callback Defines the function used for the attenuation
  90578. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  90579. */
  90580. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  90581. /**
  90582. * Play the sound
  90583. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  90584. * @param offset (optional) Start the sound setting it at a specific time
  90585. */
  90586. play(time?: number, offset?: number): void;
  90587. private _onended;
  90588. /**
  90589. * Stop the sound
  90590. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  90591. */
  90592. stop(time?: number): void;
  90593. /**
  90594. * Put the sound in pause
  90595. */
  90596. pause(): void;
  90597. /**
  90598. * Sets a dedicated volume for this sounds
  90599. * @param newVolume Define the new volume of the sound
  90600. * @param time Define in how long the sound should be at this value
  90601. */
  90602. setVolume(newVolume: number, time?: number): void;
  90603. /**
  90604. * Set the sound play back rate
  90605. * @param newPlaybackRate Define the playback rate the sound should be played at
  90606. */
  90607. setPlaybackRate(newPlaybackRate: number): void;
  90608. /**
  90609. * Gets the volume of the sound.
  90610. * @returns the volume of the sound
  90611. */
  90612. getVolume(): number;
  90613. /**
  90614. * Attach the sound to a dedicated mesh
  90615. * @param transformNode The transform node to connect the sound with
  90616. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  90617. */
  90618. attachToMesh(transformNode: TransformNode): void;
  90619. /**
  90620. * Detach the sound from the previously attached mesh
  90621. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  90622. */
  90623. detachFromMesh(): void;
  90624. private _onRegisterAfterWorldMatrixUpdate;
  90625. /**
  90626. * Clone the current sound in the scene.
  90627. * @returns the new sound clone
  90628. */
  90629. clone(): Nullable<Sound>;
  90630. /**
  90631. * Gets the current underlying audio buffer containing the data
  90632. * @returns the audio buffer
  90633. */
  90634. getAudioBuffer(): Nullable<AudioBuffer>;
  90635. /**
  90636. * Serializes the Sound in a JSON representation
  90637. * @returns the JSON representation of the sound
  90638. */
  90639. serialize(): any;
  90640. /**
  90641. * Parse a JSON representation of a sound to innstantiate in a given scene
  90642. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  90643. * @param scene Define the scene the new parsed sound should be created in
  90644. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  90645. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  90646. * @returns the newly parsed sound
  90647. */
  90648. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  90649. }
  90650. }
  90651. declare module BABYLON {
  90652. /**
  90653. * This defines an action helpful to play a defined sound on a triggered action.
  90654. */
  90655. export class PlaySoundAction extends Action {
  90656. private _sound;
  90657. /**
  90658. * Instantiate the action
  90659. * @param triggerOptions defines the trigger options
  90660. * @param sound defines the sound to play
  90661. * @param condition defines the trigger related conditions
  90662. */
  90663. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  90664. /** @hidden */
  90665. _prepare(): void;
  90666. /**
  90667. * Execute the action and play the sound.
  90668. */
  90669. execute(): void;
  90670. /**
  90671. * Serializes the actions and its related information.
  90672. * @param parent defines the object to serialize in
  90673. * @returns the serialized object
  90674. */
  90675. serialize(parent: any): any;
  90676. }
  90677. /**
  90678. * This defines an action helpful to stop a defined sound on a triggered action.
  90679. */
  90680. export class StopSoundAction extends Action {
  90681. private _sound;
  90682. /**
  90683. * Instantiate the action
  90684. * @param triggerOptions defines the trigger options
  90685. * @param sound defines the sound to stop
  90686. * @param condition defines the trigger related conditions
  90687. */
  90688. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  90689. /** @hidden */
  90690. _prepare(): void;
  90691. /**
  90692. * Execute the action and stop the sound.
  90693. */
  90694. execute(): void;
  90695. /**
  90696. * Serializes the actions and its related information.
  90697. * @param parent defines the object to serialize in
  90698. * @returns the serialized object
  90699. */
  90700. serialize(parent: any): any;
  90701. }
  90702. }
  90703. declare module BABYLON {
  90704. /**
  90705. * This defines an action responsible to change the value of a property
  90706. * by interpolating between its current value and the newly set one once triggered.
  90707. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90708. */
  90709. export class InterpolateValueAction extends Action {
  90710. /**
  90711. * Defines the path of the property where the value should be interpolated
  90712. */
  90713. propertyPath: string;
  90714. /**
  90715. * Defines the target value at the end of the interpolation.
  90716. */
  90717. value: any;
  90718. /**
  90719. * Defines the time it will take for the property to interpolate to the value.
  90720. */
  90721. duration: number;
  90722. /**
  90723. * Defines if the other scene animations should be stopped when the action has been triggered
  90724. */
  90725. stopOtherAnimations?: boolean;
  90726. /**
  90727. * Defines a callback raised once the interpolation animation has been done.
  90728. */
  90729. onInterpolationDone?: () => void;
  90730. /**
  90731. * Observable triggered once the interpolation animation has been done.
  90732. */
  90733. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  90734. private _target;
  90735. private _effectiveTarget;
  90736. private _property;
  90737. /**
  90738. * Instantiate the action
  90739. * @param triggerOptions defines the trigger options
  90740. * @param target defines the object containing the value to interpolate
  90741. * @param propertyPath defines the path to the property in the target object
  90742. * @param value defines the target value at the end of the interpolation
  90743. * @param duration deines the time it will take for the property to interpolate to the value.
  90744. * @param condition defines the trigger related conditions
  90745. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  90746. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  90747. */
  90748. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  90749. /** @hidden */
  90750. _prepare(): void;
  90751. /**
  90752. * Execute the action starts the value interpolation.
  90753. */
  90754. execute(): void;
  90755. /**
  90756. * Serializes the actions and its related information.
  90757. * @param parent defines the object to serialize in
  90758. * @returns the serialized object
  90759. */
  90760. serialize(parent: any): any;
  90761. }
  90762. }
  90763. declare module BABYLON {
  90764. /**
  90765. * Options allowed during the creation of a sound track.
  90766. */
  90767. export interface ISoundTrackOptions {
  90768. /**
  90769. * The volume the sound track should take during creation
  90770. */
  90771. volume?: number;
  90772. /**
  90773. * Define if the sound track is the main sound track of the scene
  90774. */
  90775. mainTrack?: boolean;
  90776. }
  90777. /**
  90778. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  90779. * It will be also used in a future release to apply effects on a specific track.
  90780. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  90781. */
  90782. export class SoundTrack {
  90783. /**
  90784. * The unique identifier of the sound track in the scene.
  90785. */
  90786. id: number;
  90787. /**
  90788. * The list of sounds included in the sound track.
  90789. */
  90790. soundCollection: Array<Sound>;
  90791. private _outputAudioNode;
  90792. private _scene;
  90793. private _isMainTrack;
  90794. private _connectedAnalyser;
  90795. private _options;
  90796. private _isInitialized;
  90797. /**
  90798. * Creates a new sound track.
  90799. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  90800. * @param scene Define the scene the sound track belongs to
  90801. * @param options
  90802. */
  90803. constructor(scene: Scene, options?: ISoundTrackOptions);
  90804. private _initializeSoundTrackAudioGraph;
  90805. /**
  90806. * Release the sound track and its associated resources
  90807. */
  90808. dispose(): void;
  90809. /**
  90810. * Adds a sound to this sound track
  90811. * @param sound define the cound to add
  90812. * @ignoreNaming
  90813. */
  90814. AddSound(sound: Sound): void;
  90815. /**
  90816. * Removes a sound to this sound track
  90817. * @param sound define the cound to remove
  90818. * @ignoreNaming
  90819. */
  90820. RemoveSound(sound: Sound): void;
  90821. /**
  90822. * Set a global volume for the full sound track.
  90823. * @param newVolume Define the new volume of the sound track
  90824. */
  90825. setVolume(newVolume: number): void;
  90826. /**
  90827. * Switch the panning model to HRTF:
  90828. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  90829. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  90830. */
  90831. switchPanningModelToHRTF(): void;
  90832. /**
  90833. * Switch the panning model to Equal Power:
  90834. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  90835. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  90836. */
  90837. switchPanningModelToEqualPower(): void;
  90838. /**
  90839. * Connect the sound track to an audio analyser allowing some amazing
  90840. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  90841. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  90842. * @param analyser The analyser to connect to the engine
  90843. */
  90844. connectToAnalyser(analyser: Analyser): void;
  90845. }
  90846. }
  90847. declare module BABYLON {
  90848. interface AbstractScene {
  90849. /**
  90850. * The list of sounds used in the scene.
  90851. */
  90852. sounds: Nullable<Array<Sound>>;
  90853. }
  90854. interface Scene {
  90855. /**
  90856. * @hidden
  90857. * Backing field
  90858. */
  90859. _mainSoundTrack: SoundTrack;
  90860. /**
  90861. * The main sound track played by the scene.
  90862. * It cotains your primary collection of sounds.
  90863. */
  90864. mainSoundTrack: SoundTrack;
  90865. /**
  90866. * The list of sound tracks added to the scene
  90867. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  90868. */
  90869. soundTracks: Nullable<Array<SoundTrack>>;
  90870. /**
  90871. * Gets a sound using a given name
  90872. * @param name defines the name to search for
  90873. * @return the found sound or null if not found at all.
  90874. */
  90875. getSoundByName(name: string): Nullable<Sound>;
  90876. /**
  90877. * Gets or sets if audio support is enabled
  90878. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  90879. */
  90880. audioEnabled: boolean;
  90881. /**
  90882. * Gets or sets if audio will be output to headphones
  90883. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  90884. */
  90885. headphone: boolean;
  90886. }
  90887. /**
  90888. * Defines the sound scene component responsible to manage any sounds
  90889. * in a given scene.
  90890. */
  90891. export class AudioSceneComponent implements ISceneSerializableComponent {
  90892. /**
  90893. * The component name helpfull to identify the component in the list of scene components.
  90894. */
  90895. readonly name: string;
  90896. /**
  90897. * The scene the component belongs to.
  90898. */
  90899. scene: Scene;
  90900. private _audioEnabled;
  90901. /**
  90902. * Gets whether audio is enabled or not.
  90903. * Please use related enable/disable method to switch state.
  90904. */
  90905. readonly audioEnabled: boolean;
  90906. private _headphone;
  90907. /**
  90908. * Gets whether audio is outputing to headphone or not.
  90909. * Please use the according Switch methods to change output.
  90910. */
  90911. readonly headphone: boolean;
  90912. /**
  90913. * Creates a new instance of the component for the given scene
  90914. * @param scene Defines the scene to register the component in
  90915. */
  90916. constructor(scene: Scene);
  90917. /**
  90918. * Registers the component in a given scene
  90919. */
  90920. register(): void;
  90921. /**
  90922. * Rebuilds the elements related to this component in case of
  90923. * context lost for instance.
  90924. */
  90925. rebuild(): void;
  90926. /**
  90927. * Serializes the component data to the specified json object
  90928. * @param serializationObject The object to serialize to
  90929. */
  90930. serialize(serializationObject: any): void;
  90931. /**
  90932. * Adds all the element from the container to the scene
  90933. * @param container the container holding the elements
  90934. */
  90935. addFromContainer(container: AbstractScene): void;
  90936. /**
  90937. * Removes all the elements in the container from the scene
  90938. * @param container contains the elements to remove
  90939. */
  90940. removeFromContainer(container: AbstractScene): void;
  90941. /**
  90942. * Disposes the component and the associated ressources.
  90943. */
  90944. dispose(): void;
  90945. /**
  90946. * Disables audio in the associated scene.
  90947. */
  90948. disableAudio(): void;
  90949. /**
  90950. * Enables audio in the associated scene.
  90951. */
  90952. enableAudio(): void;
  90953. /**
  90954. * Switch audio to headphone output.
  90955. */
  90956. switchAudioModeForHeadphones(): void;
  90957. /**
  90958. * Switch audio to normal speakers.
  90959. */
  90960. switchAudioModeForNormalSpeakers(): void;
  90961. private _afterRender;
  90962. }
  90963. }
  90964. declare module BABYLON {
  90965. /**
  90966. * Wraps one or more Sound objects and selects one with random weight for playback.
  90967. */
  90968. export class WeightedSound {
  90969. /** When true a Sound will be selected and played when the current playing Sound completes. */
  90970. loop: boolean;
  90971. private _coneInnerAngle;
  90972. private _coneOuterAngle;
  90973. private _volume;
  90974. /** A Sound is currently playing. */
  90975. isPlaying: boolean;
  90976. /** A Sound is currently paused. */
  90977. isPaused: boolean;
  90978. private _sounds;
  90979. private _weights;
  90980. private _currentIndex?;
  90981. /**
  90982. * Creates a new WeightedSound from the list of sounds given.
  90983. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  90984. * @param sounds Array of Sounds that will be selected from.
  90985. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  90986. */
  90987. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  90988. /**
  90989. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  90990. */
  90991. /**
  90992. * The size of cone in degress for a directional sound in which there will be no attenuation.
  90993. */
  90994. directionalConeInnerAngle: number;
  90995. /**
  90996. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  90997. * Listener angles between innerAngle and outerAngle will falloff linearly.
  90998. */
  90999. /**
  91000. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  91001. * Listener angles between innerAngle and outerAngle will falloff linearly.
  91002. */
  91003. directionalConeOuterAngle: number;
  91004. /**
  91005. * Playback volume.
  91006. */
  91007. /**
  91008. * Playback volume.
  91009. */
  91010. volume: number;
  91011. private _onended;
  91012. /**
  91013. * Suspend playback
  91014. */
  91015. pause(): void;
  91016. /**
  91017. * Stop playback
  91018. */
  91019. stop(): void;
  91020. /**
  91021. * Start playback.
  91022. * @param startOffset Position the clip head at a specific time in seconds.
  91023. */
  91024. play(startOffset?: number): void;
  91025. }
  91026. }
  91027. declare module BABYLON {
  91028. /**
  91029. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  91030. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  91031. */
  91032. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  91033. /**
  91034. * Gets the name of the behavior.
  91035. */
  91036. readonly name: string;
  91037. /**
  91038. * The easing function used by animations
  91039. */
  91040. static EasingFunction: BackEase;
  91041. /**
  91042. * The easing mode used by animations
  91043. */
  91044. static EasingMode: number;
  91045. /**
  91046. * The duration of the animation, in milliseconds
  91047. */
  91048. transitionDuration: number;
  91049. /**
  91050. * Length of the distance animated by the transition when lower radius is reached
  91051. */
  91052. lowerRadiusTransitionRange: number;
  91053. /**
  91054. * Length of the distance animated by the transition when upper radius is reached
  91055. */
  91056. upperRadiusTransitionRange: number;
  91057. private _autoTransitionRange;
  91058. /**
  91059. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  91060. */
  91061. /**
  91062. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  91063. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  91064. */
  91065. autoTransitionRange: boolean;
  91066. private _attachedCamera;
  91067. private _onAfterCheckInputsObserver;
  91068. private _onMeshTargetChangedObserver;
  91069. /**
  91070. * Initializes the behavior.
  91071. */
  91072. init(): void;
  91073. /**
  91074. * Attaches the behavior to its arc rotate camera.
  91075. * @param camera Defines the camera to attach the behavior to
  91076. */
  91077. attach(camera: ArcRotateCamera): void;
  91078. /**
  91079. * Detaches the behavior from its current arc rotate camera.
  91080. */
  91081. detach(): void;
  91082. private _radiusIsAnimating;
  91083. private _radiusBounceTransition;
  91084. private _animatables;
  91085. private _cachedWheelPrecision;
  91086. /**
  91087. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  91088. * @param radiusLimit The limit to check against.
  91089. * @return Bool to indicate if at limit.
  91090. */
  91091. private _isRadiusAtLimit;
  91092. /**
  91093. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  91094. * @param radiusDelta The delta by which to animate to. Can be negative.
  91095. */
  91096. private _applyBoundRadiusAnimation;
  91097. /**
  91098. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  91099. */
  91100. protected _clearAnimationLocks(): void;
  91101. /**
  91102. * Stops and removes all animations that have been applied to the camera
  91103. */
  91104. stopAllAnimations(): void;
  91105. }
  91106. }
  91107. declare module BABYLON {
  91108. /**
  91109. * 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.
  91110. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  91111. */
  91112. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  91113. /**
  91114. * Gets the name of the behavior.
  91115. */
  91116. readonly name: string;
  91117. private _mode;
  91118. private _radiusScale;
  91119. private _positionScale;
  91120. private _defaultElevation;
  91121. private _elevationReturnTime;
  91122. private _elevationReturnWaitTime;
  91123. private _zoomStopsAnimation;
  91124. private _framingTime;
  91125. /**
  91126. * The easing function used by animations
  91127. */
  91128. static EasingFunction: ExponentialEase;
  91129. /**
  91130. * The easing mode used by animations
  91131. */
  91132. static EasingMode: number;
  91133. /**
  91134. * Sets the current mode used by the behavior
  91135. */
  91136. /**
  91137. * Gets current mode used by the behavior.
  91138. */
  91139. mode: number;
  91140. /**
  91141. * Sets the scale applied to the radius (1 by default)
  91142. */
  91143. /**
  91144. * Gets the scale applied to the radius
  91145. */
  91146. radiusScale: number;
  91147. /**
  91148. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  91149. */
  91150. /**
  91151. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  91152. */
  91153. positionScale: number;
  91154. /**
  91155. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  91156. * behaviour is triggered, in radians.
  91157. */
  91158. /**
  91159. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  91160. * behaviour is triggered, in radians.
  91161. */
  91162. defaultElevation: number;
  91163. /**
  91164. * Sets the time (in milliseconds) taken to return to the default beta position.
  91165. * Negative value indicates camera should not return to default.
  91166. */
  91167. /**
  91168. * Gets the time (in milliseconds) taken to return to the default beta position.
  91169. * Negative value indicates camera should not return to default.
  91170. */
  91171. elevationReturnTime: number;
  91172. /**
  91173. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  91174. */
  91175. /**
  91176. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  91177. */
  91178. elevationReturnWaitTime: number;
  91179. /**
  91180. * Sets the flag that indicates if user zooming should stop animation.
  91181. */
  91182. /**
  91183. * Gets the flag that indicates if user zooming should stop animation.
  91184. */
  91185. zoomStopsAnimation: boolean;
  91186. /**
  91187. * Sets the transition time when framing the mesh, in milliseconds
  91188. */
  91189. /**
  91190. * Gets the transition time when framing the mesh, in milliseconds
  91191. */
  91192. framingTime: number;
  91193. /**
  91194. * Define if the behavior should automatically change the configured
  91195. * camera limits and sensibilities.
  91196. */
  91197. autoCorrectCameraLimitsAndSensibility: boolean;
  91198. private _onPrePointerObservableObserver;
  91199. private _onAfterCheckInputsObserver;
  91200. private _onMeshTargetChangedObserver;
  91201. private _attachedCamera;
  91202. private _isPointerDown;
  91203. private _lastInteractionTime;
  91204. /**
  91205. * Initializes the behavior.
  91206. */
  91207. init(): void;
  91208. /**
  91209. * Attaches the behavior to its arc rotate camera.
  91210. * @param camera Defines the camera to attach the behavior to
  91211. */
  91212. attach(camera: ArcRotateCamera): void;
  91213. /**
  91214. * Detaches the behavior from its current arc rotate camera.
  91215. */
  91216. detach(): void;
  91217. private _animatables;
  91218. private _betaIsAnimating;
  91219. private _betaTransition;
  91220. private _radiusTransition;
  91221. private _vectorTransition;
  91222. /**
  91223. * Targets the given mesh and updates zoom level accordingly.
  91224. * @param mesh The mesh to target.
  91225. * @param radius Optional. If a cached radius position already exists, overrides default.
  91226. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  91227. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  91228. * @param onAnimationEnd Callback triggered at the end of the framing animation
  91229. */
  91230. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  91231. /**
  91232. * Targets the given mesh with its children and updates zoom level accordingly.
  91233. * @param mesh The mesh to target.
  91234. * @param radius Optional. If a cached radius position already exists, overrides default.
  91235. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  91236. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  91237. * @param onAnimationEnd Callback triggered at the end of the framing animation
  91238. */
  91239. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  91240. /**
  91241. * Targets the given meshes with their children and updates zoom level accordingly.
  91242. * @param meshes The mesh to target.
  91243. * @param radius Optional. If a cached radius position already exists, overrides default.
  91244. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  91245. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  91246. * @param onAnimationEnd Callback triggered at the end of the framing animation
  91247. */
  91248. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  91249. /**
  91250. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  91251. * @param minimumWorld Determines the smaller position of the bounding box extend
  91252. * @param maximumWorld Determines the bigger position of the bounding box extend
  91253. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  91254. * @param onAnimationEnd Callback triggered at the end of the framing animation
  91255. */
  91256. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  91257. /**
  91258. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  91259. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  91260. * frustum width.
  91261. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  91262. * to fully enclose the mesh in the viewing frustum.
  91263. */
  91264. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  91265. /**
  91266. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  91267. * is automatically returned to its default position (expected to be above ground plane).
  91268. */
  91269. private _maintainCameraAboveGround;
  91270. /**
  91271. * Returns the frustum slope based on the canvas ratio and camera FOV
  91272. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  91273. */
  91274. private _getFrustumSlope;
  91275. /**
  91276. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  91277. */
  91278. private _clearAnimationLocks;
  91279. /**
  91280. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  91281. */
  91282. private _applyUserInteraction;
  91283. /**
  91284. * Stops and removes all animations that have been applied to the camera
  91285. */
  91286. stopAllAnimations(): void;
  91287. /**
  91288. * Gets a value indicating if the user is moving the camera
  91289. */
  91290. readonly isUserIsMoving: boolean;
  91291. /**
  91292. * The camera can move all the way towards the mesh.
  91293. */
  91294. static IgnoreBoundsSizeMode: number;
  91295. /**
  91296. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  91297. */
  91298. static FitFrustumSidesMode: number;
  91299. }
  91300. }
  91301. declare module BABYLON {
  91302. /**
  91303. * Base class for Camera Pointer Inputs.
  91304. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  91305. * for example usage.
  91306. */
  91307. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  91308. /**
  91309. * Defines the camera the input is attached to.
  91310. */
  91311. abstract camera: Camera;
  91312. /**
  91313. * Whether keyboard modifier keys are pressed at time of last mouse event.
  91314. */
  91315. protected _altKey: boolean;
  91316. protected _ctrlKey: boolean;
  91317. protected _metaKey: boolean;
  91318. protected _shiftKey: boolean;
  91319. /**
  91320. * Which mouse buttons were pressed at time of last mouse event.
  91321. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  91322. */
  91323. protected _buttonsPressed: number;
  91324. /**
  91325. * Defines the buttons associated with the input to handle camera move.
  91326. */
  91327. buttons: number[];
  91328. /**
  91329. * Attach the input controls to a specific dom element to get the input from.
  91330. * @param element Defines the element the controls should be listened from
  91331. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  91332. */
  91333. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  91334. /**
  91335. * Detach the current controls from the specified dom element.
  91336. * @param element Defines the element to stop listening the inputs from
  91337. */
  91338. detachControl(element: Nullable<HTMLElement>): void;
  91339. /**
  91340. * Gets the class name of the current input.
  91341. * @returns the class name
  91342. */
  91343. getClassName(): string;
  91344. /**
  91345. * Get the friendly name associated with the input class.
  91346. * @returns the input friendly name
  91347. */
  91348. getSimpleName(): string;
  91349. /**
  91350. * Called on pointer POINTERDOUBLETAP event.
  91351. * Override this method to provide functionality on POINTERDOUBLETAP event.
  91352. */
  91353. protected onDoubleTap(type: string): void;
  91354. /**
  91355. * Called on pointer POINTERMOVE event if only a single touch is active.
  91356. * Override this method to provide functionality.
  91357. */
  91358. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  91359. /**
  91360. * Called on pointer POINTERMOVE event if multiple touches are active.
  91361. * Override this method to provide functionality.
  91362. */
  91363. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  91364. /**
  91365. * Called on JS contextmenu event.
  91366. * Override this method to provide functionality.
  91367. */
  91368. protected onContextMenu(evt: PointerEvent): void;
  91369. /**
  91370. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  91371. * press.
  91372. * Override this method to provide functionality.
  91373. */
  91374. protected onButtonDown(evt: PointerEvent, buttonCount: number): void;
  91375. /**
  91376. * Called each time a new POINTERUP event occurs. Ie, for each button
  91377. * release.
  91378. * Override this method to provide functionality.
  91379. */
  91380. protected onButtonUp(evt: PointerEvent): void;
  91381. /**
  91382. * Called when window becomes inactive.
  91383. * Override this method to provide functionality.
  91384. */
  91385. protected onLostFocus(): void;
  91386. private _pointerInput;
  91387. private _observer;
  91388. private _onLostFocus;
  91389. }
  91390. }
  91391. declare module BABYLON {
  91392. /**
  91393. * Manage the pointers inputs to control an arc rotate camera.
  91394. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  91395. */
  91396. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  91397. /**
  91398. * Defines the camera the input is attached to.
  91399. */
  91400. camera: ArcRotateCamera;
  91401. /**
  91402. * Gets the class name of the current input.
  91403. * @returns the class name
  91404. */
  91405. getClassName(): string;
  91406. /**
  91407. * Defines the buttons associated with the input to handle camera move.
  91408. */
  91409. buttons: number[];
  91410. /**
  91411. * Defines the pointer angular sensibility along the X axis or how fast is
  91412. * the camera rotating.
  91413. */
  91414. angularSensibilityX: number;
  91415. /**
  91416. * Defines the pointer angular sensibility along the Y axis or how fast is
  91417. * the camera rotating.
  91418. */
  91419. angularSensibilityY: number;
  91420. /**
  91421. * Defines the pointer pinch precision or how fast is the camera zooming.
  91422. */
  91423. pinchPrecision: number;
  91424. /**
  91425. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  91426. * from 0.
  91427. * It defines the percentage of current camera.radius to use as delta when
  91428. * pinch zoom is used.
  91429. */
  91430. pinchDeltaPercentage: number;
  91431. /**
  91432. * Defines the pointer panning sensibility or how fast is the camera moving.
  91433. */
  91434. panningSensibility: number;
  91435. /**
  91436. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  91437. */
  91438. multiTouchPanning: boolean;
  91439. /**
  91440. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  91441. * zoom (pinch) through multitouch.
  91442. */
  91443. multiTouchPanAndZoom: boolean;
  91444. /**
  91445. * Revers pinch action direction.
  91446. */
  91447. pinchInwards: boolean;
  91448. private _isPanClick;
  91449. private _twoFingerActivityCount;
  91450. private _isPinching;
  91451. /**
  91452. * Called on pointer POINTERMOVE event if only a single touch is active.
  91453. */
  91454. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  91455. /**
  91456. * Called on pointer POINTERDOUBLETAP event.
  91457. */
  91458. protected onDoubleTap(type: string): void;
  91459. /**
  91460. * Called on pointer POINTERMOVE event if multiple touches are active.
  91461. */
  91462. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  91463. /**
  91464. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  91465. * press.
  91466. */
  91467. protected onButtonDown(evt: PointerEvent, buttonCount: number): void;
  91468. /**
  91469. * Called each time a new POINTERUP event occurs. Ie, for each button
  91470. * release.
  91471. */
  91472. protected onButtonUp(evt: PointerEvent): void;
  91473. /**
  91474. * Called when window becomes inactive.
  91475. */
  91476. protected onLostFocus(): void;
  91477. }
  91478. }
  91479. declare module BABYLON {
  91480. /**
  91481. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  91482. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  91483. */
  91484. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  91485. /**
  91486. * Defines the camera the input is attached to.
  91487. */
  91488. camera: ArcRotateCamera;
  91489. /**
  91490. * Defines the list of key codes associated with the up action (increase alpha)
  91491. */
  91492. keysUp: number[];
  91493. /**
  91494. * Defines the list of key codes associated with the down action (decrease alpha)
  91495. */
  91496. keysDown: number[];
  91497. /**
  91498. * Defines the list of key codes associated with the left action (increase beta)
  91499. */
  91500. keysLeft: number[];
  91501. /**
  91502. * Defines the list of key codes associated with the right action (decrease beta)
  91503. */
  91504. keysRight: number[];
  91505. /**
  91506. * Defines the list of key codes associated with the reset action.
  91507. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  91508. */
  91509. keysReset: number[];
  91510. /**
  91511. * Defines the panning sensibility of the inputs.
  91512. * (How fast is the camera paning)
  91513. */
  91514. panningSensibility: number;
  91515. /**
  91516. * Defines the zooming sensibility of the inputs.
  91517. * (How fast is the camera zooming)
  91518. */
  91519. zoomingSensibility: number;
  91520. /**
  91521. * Defines wether maintaining the alt key down switch the movement mode from
  91522. * orientation to zoom.
  91523. */
  91524. useAltToZoom: boolean;
  91525. /**
  91526. * Rotation speed of the camera
  91527. */
  91528. angularSpeed: number;
  91529. private _keys;
  91530. private _ctrlPressed;
  91531. private _altPressed;
  91532. private _onCanvasBlurObserver;
  91533. private _onKeyboardObserver;
  91534. private _engine;
  91535. private _scene;
  91536. /**
  91537. * Attach the input controls to a specific dom element to get the input from.
  91538. * @param element Defines the element the controls should be listened from
  91539. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  91540. */
  91541. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  91542. /**
  91543. * Detach the current controls from the specified dom element.
  91544. * @param element Defines the element to stop listening the inputs from
  91545. */
  91546. detachControl(element: Nullable<HTMLElement>): void;
  91547. /**
  91548. * Update the current camera state depending on the inputs that have been used this frame.
  91549. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  91550. */
  91551. checkInputs(): void;
  91552. /**
  91553. * Gets the class name of the current intput.
  91554. * @returns the class name
  91555. */
  91556. getClassName(): string;
  91557. /**
  91558. * Get the friendly name associated with the input class.
  91559. * @returns the input friendly name
  91560. */
  91561. getSimpleName(): string;
  91562. }
  91563. }
  91564. declare module BABYLON {
  91565. /**
  91566. * Manage the mouse wheel inputs to control an arc rotate camera.
  91567. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  91568. */
  91569. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  91570. /**
  91571. * Defines the camera the input is attached to.
  91572. */
  91573. camera: ArcRotateCamera;
  91574. /**
  91575. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  91576. */
  91577. wheelPrecision: number;
  91578. /**
  91579. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  91580. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  91581. */
  91582. wheelDeltaPercentage: number;
  91583. private _wheel;
  91584. private _observer;
  91585. /**
  91586. * Attach the input controls to a specific dom element to get the input from.
  91587. * @param element Defines the element the controls should be listened from
  91588. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  91589. */
  91590. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  91591. /**
  91592. * Detach the current controls from the specified dom element.
  91593. * @param element Defines the element to stop listening the inputs from
  91594. */
  91595. detachControl(element: Nullable<HTMLElement>): void;
  91596. /**
  91597. * Gets the class name of the current intput.
  91598. * @returns the class name
  91599. */
  91600. getClassName(): string;
  91601. /**
  91602. * Get the friendly name associated with the input class.
  91603. * @returns the input friendly name
  91604. */
  91605. getSimpleName(): string;
  91606. }
  91607. }
  91608. declare module BABYLON {
  91609. /**
  91610. * Default Inputs manager for the ArcRotateCamera.
  91611. * It groups all the default supported inputs for ease of use.
  91612. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  91613. */
  91614. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  91615. /**
  91616. * Instantiates a new ArcRotateCameraInputsManager.
  91617. * @param camera Defines the camera the inputs belong to
  91618. */
  91619. constructor(camera: ArcRotateCamera);
  91620. /**
  91621. * Add mouse wheel input support to the input manager.
  91622. * @returns the current input manager
  91623. */
  91624. addMouseWheel(): ArcRotateCameraInputsManager;
  91625. /**
  91626. * Add pointers input support to the input manager.
  91627. * @returns the current input manager
  91628. */
  91629. addPointers(): ArcRotateCameraInputsManager;
  91630. /**
  91631. * Add keyboard input support to the input manager.
  91632. * @returns the current input manager
  91633. */
  91634. addKeyboard(): ArcRotateCameraInputsManager;
  91635. }
  91636. }
  91637. declare module BABYLON {
  91638. /**
  91639. * This represents an orbital type of camera.
  91640. *
  91641. * 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.
  91642. * 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.
  91643. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  91644. */
  91645. export class ArcRotateCamera extends TargetCamera {
  91646. /**
  91647. * Defines the rotation angle of the camera along the longitudinal axis.
  91648. */
  91649. alpha: number;
  91650. /**
  91651. * Defines the rotation angle of the camera along the latitudinal axis.
  91652. */
  91653. beta: number;
  91654. /**
  91655. * Defines the radius of the camera from it s target point.
  91656. */
  91657. radius: number;
  91658. protected _target: Vector3;
  91659. protected _targetHost: Nullable<AbstractMesh>;
  91660. /**
  91661. * Defines the target point of the camera.
  91662. * The camera looks towards it form the radius distance.
  91663. */
  91664. target: Vector3;
  91665. /**
  91666. * Define the current local position of the camera in the scene
  91667. */
  91668. position: Vector3;
  91669. /**
  91670. * Current inertia value on the longitudinal axis.
  91671. * The bigger this number the longer it will take for the camera to stop.
  91672. */
  91673. inertialAlphaOffset: number;
  91674. /**
  91675. * Current inertia value on the latitudinal axis.
  91676. * The bigger this number the longer it will take for the camera to stop.
  91677. */
  91678. inertialBetaOffset: number;
  91679. /**
  91680. * Current inertia value on the radius axis.
  91681. * The bigger this number the longer it will take for the camera to stop.
  91682. */
  91683. inertialRadiusOffset: number;
  91684. /**
  91685. * Minimum allowed angle on the longitudinal axis.
  91686. * This can help limiting how the Camera is able to move in the scene.
  91687. */
  91688. lowerAlphaLimit: Nullable<number>;
  91689. /**
  91690. * Maximum allowed angle on the longitudinal axis.
  91691. * This can help limiting how the Camera is able to move in the scene.
  91692. */
  91693. upperAlphaLimit: Nullable<number>;
  91694. /**
  91695. * Minimum allowed angle on the latitudinal axis.
  91696. * This can help limiting how the Camera is able to move in the scene.
  91697. */
  91698. lowerBetaLimit: number;
  91699. /**
  91700. * Maximum allowed angle on the latitudinal axis.
  91701. * This can help limiting how the Camera is able to move in the scene.
  91702. */
  91703. upperBetaLimit: number;
  91704. /**
  91705. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  91706. * This can help limiting how the Camera is able to move in the scene.
  91707. */
  91708. lowerRadiusLimit: Nullable<number>;
  91709. /**
  91710. * Maximum allowed distance of the camera to the target (The camera can not get further).
  91711. * This can help limiting how the Camera is able to move in the scene.
  91712. */
  91713. upperRadiusLimit: Nullable<number>;
  91714. /**
  91715. * Defines the current inertia value used during panning of the camera along the X axis.
  91716. */
  91717. inertialPanningX: number;
  91718. /**
  91719. * Defines the current inertia value used during panning of the camera along the Y axis.
  91720. */
  91721. inertialPanningY: number;
  91722. /**
  91723. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  91724. * Basically if your fingers moves away from more than this distance you will be considered
  91725. * in pinch mode.
  91726. */
  91727. pinchToPanMaxDistance: number;
  91728. /**
  91729. * Defines the maximum distance the camera can pan.
  91730. * This could help keeping the cammera always in your scene.
  91731. */
  91732. panningDistanceLimit: Nullable<number>;
  91733. /**
  91734. * Defines the target of the camera before paning.
  91735. */
  91736. panningOriginTarget: Vector3;
  91737. /**
  91738. * Defines the value of the inertia used during panning.
  91739. * 0 would mean stop inertia and one would mean no decelleration at all.
  91740. */
  91741. panningInertia: number;
  91742. /**
  91743. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  91744. */
  91745. angularSensibilityX: number;
  91746. /**
  91747. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  91748. */
  91749. angularSensibilityY: number;
  91750. /**
  91751. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  91752. */
  91753. pinchPrecision: number;
  91754. /**
  91755. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  91756. * It will be used instead of pinchDeltaPrecision if different from 0.
  91757. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  91758. */
  91759. pinchDeltaPercentage: number;
  91760. /**
  91761. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  91762. */
  91763. panningSensibility: number;
  91764. /**
  91765. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  91766. */
  91767. keysUp: number[];
  91768. /**
  91769. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  91770. */
  91771. keysDown: number[];
  91772. /**
  91773. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  91774. */
  91775. keysLeft: number[];
  91776. /**
  91777. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  91778. */
  91779. keysRight: number[];
  91780. /**
  91781. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  91782. */
  91783. wheelPrecision: number;
  91784. /**
  91785. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  91786. * It will be used instead of pinchDeltaPrecision if different from 0.
  91787. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  91788. */
  91789. wheelDeltaPercentage: number;
  91790. /**
  91791. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  91792. */
  91793. zoomOnFactor: number;
  91794. /**
  91795. * Defines a screen offset for the camera position.
  91796. */
  91797. targetScreenOffset: Vector2;
  91798. /**
  91799. * Allows the camera to be completely reversed.
  91800. * If false the camera can not arrive upside down.
  91801. */
  91802. allowUpsideDown: boolean;
  91803. /**
  91804. * Define if double tap/click is used to restore the previously saved state of the camera.
  91805. */
  91806. useInputToRestoreState: boolean;
  91807. /** @hidden */
  91808. _viewMatrix: Matrix;
  91809. /** @hidden */
  91810. _useCtrlForPanning: boolean;
  91811. /** @hidden */
  91812. _panningMouseButton: number;
  91813. /**
  91814. * Defines the input associated to the camera.
  91815. */
  91816. inputs: ArcRotateCameraInputsManager;
  91817. /** @hidden */
  91818. _reset: () => void;
  91819. /**
  91820. * Defines the allowed panning axis.
  91821. */
  91822. panningAxis: Vector3;
  91823. protected _localDirection: Vector3;
  91824. protected _transformedDirection: Vector3;
  91825. private _bouncingBehavior;
  91826. /**
  91827. * Gets the bouncing behavior of the camera if it has been enabled.
  91828. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  91829. */
  91830. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  91831. /**
  91832. * Defines if the bouncing behavior of the camera is enabled on the camera.
  91833. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  91834. */
  91835. useBouncingBehavior: boolean;
  91836. private _framingBehavior;
  91837. /**
  91838. * Gets the framing behavior of the camera if it has been enabled.
  91839. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  91840. */
  91841. readonly framingBehavior: Nullable<FramingBehavior>;
  91842. /**
  91843. * Defines if the framing behavior of the camera is enabled on the camera.
  91844. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  91845. */
  91846. useFramingBehavior: boolean;
  91847. private _autoRotationBehavior;
  91848. /**
  91849. * Gets the auto rotation behavior of the camera if it has been enabled.
  91850. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  91851. */
  91852. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  91853. /**
  91854. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  91855. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  91856. */
  91857. useAutoRotationBehavior: boolean;
  91858. /**
  91859. * Observable triggered when the mesh target has been changed on the camera.
  91860. */
  91861. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  91862. /**
  91863. * Event raised when the camera is colliding with a mesh.
  91864. */
  91865. onCollide: (collidedMesh: AbstractMesh) => void;
  91866. /**
  91867. * Defines whether the camera should check collision with the objects oh the scene.
  91868. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  91869. */
  91870. checkCollisions: boolean;
  91871. /**
  91872. * Defines the collision radius of the camera.
  91873. * This simulates a sphere around the camera.
  91874. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  91875. */
  91876. collisionRadius: Vector3;
  91877. protected _collider: Collider;
  91878. protected _previousPosition: Vector3;
  91879. protected _collisionVelocity: Vector3;
  91880. protected _newPosition: Vector3;
  91881. protected _previousAlpha: number;
  91882. protected _previousBeta: number;
  91883. protected _previousRadius: number;
  91884. protected _collisionTriggered: boolean;
  91885. protected _targetBoundingCenter: Nullable<Vector3>;
  91886. private _computationVector;
  91887. private _tempAxisVector;
  91888. private _tempAxisRotationMatrix;
  91889. /**
  91890. * Instantiates a new ArcRotateCamera in a given scene
  91891. * @param name Defines the name of the camera
  91892. * @param alpha Defines the camera rotation along the logitudinal axis
  91893. * @param beta Defines the camera rotation along the latitudinal axis
  91894. * @param radius Defines the camera distance from its target
  91895. * @param target Defines the camera target
  91896. * @param scene Defines the scene the camera belongs to
  91897. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  91898. */
  91899. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  91900. /** @hidden */
  91901. _initCache(): void;
  91902. /** @hidden */
  91903. _updateCache(ignoreParentClass?: boolean): void;
  91904. protected _getTargetPosition(): Vector3;
  91905. private _storedAlpha;
  91906. private _storedBeta;
  91907. private _storedRadius;
  91908. private _storedTarget;
  91909. /**
  91910. * Stores the current state of the camera (alpha, beta, radius and target)
  91911. * @returns the camera itself
  91912. */
  91913. storeState(): Camera;
  91914. /**
  91915. * @hidden
  91916. * Restored camera state. You must call storeState() first
  91917. */
  91918. _restoreStateValues(): boolean;
  91919. /** @hidden */
  91920. _isSynchronizedViewMatrix(): boolean;
  91921. /**
  91922. * Attached controls to the current camera.
  91923. * @param element Defines the element the controls should be listened from
  91924. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  91925. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  91926. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  91927. */
  91928. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  91929. /**
  91930. * Detach the current controls from the camera.
  91931. * The camera will stop reacting to inputs.
  91932. * @param element Defines the element to stop listening the inputs from
  91933. */
  91934. detachControl(element: HTMLElement): void;
  91935. /** @hidden */
  91936. _checkInputs(): void;
  91937. protected _checkLimits(): void;
  91938. /**
  91939. * Rebuilds angles (alpha, beta) and radius from the give position and target
  91940. * @param updateView defines a boolean forcing the camera to update its position with a view matrix computation first (default is true)
  91941. */
  91942. rebuildAnglesAndRadius(updateView?: boolean): void;
  91943. /**
  91944. * Use a position to define the current camera related information like aplha, beta and radius
  91945. * @param position Defines the position to set the camera at
  91946. */
  91947. setPosition(position: Vector3): void;
  91948. /**
  91949. * Defines the target the camera should look at.
  91950. * This will automatically adapt alpha beta and radius to fit within the new target.
  91951. * @param target Defines the new target as a Vector or a mesh
  91952. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  91953. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  91954. */
  91955. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  91956. /** @hidden */
  91957. _getViewMatrix(): Matrix;
  91958. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  91959. /**
  91960. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  91961. * @param meshes Defines the mesh to zoom on
  91962. * @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)
  91963. */
  91964. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  91965. /**
  91966. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  91967. * The target will be changed but the radius
  91968. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  91969. * @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)
  91970. */
  91971. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  91972. min: Vector3;
  91973. max: Vector3;
  91974. distance: number;
  91975. }, doNotUpdateMaxZ?: boolean): void;
  91976. /**
  91977. * @override
  91978. * Override Camera.createRigCamera
  91979. */
  91980. createRigCamera(name: string, cameraIndex: number): Camera;
  91981. /**
  91982. * @hidden
  91983. * @override
  91984. * Override Camera._updateRigCameras
  91985. */
  91986. _updateRigCameras(): void;
  91987. /**
  91988. * Destroy the camera and release the current resources hold by it.
  91989. */
  91990. dispose(): void;
  91991. /**
  91992. * Gets the current object class name.
  91993. * @return the class name
  91994. */
  91995. getClassName(): string;
  91996. }
  91997. }
  91998. declare module BABYLON {
  91999. /**
  92000. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  92001. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  92002. */
  92003. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  92004. /**
  92005. * Gets the name of the behavior.
  92006. */
  92007. readonly name: string;
  92008. private _zoomStopsAnimation;
  92009. private _idleRotationSpeed;
  92010. private _idleRotationWaitTime;
  92011. private _idleRotationSpinupTime;
  92012. /**
  92013. * Sets the flag that indicates if user zooming should stop animation.
  92014. */
  92015. /**
  92016. * Gets the flag that indicates if user zooming should stop animation.
  92017. */
  92018. zoomStopsAnimation: boolean;
  92019. /**
  92020. * Sets the default speed at which the camera rotates around the model.
  92021. */
  92022. /**
  92023. * Gets the default speed at which the camera rotates around the model.
  92024. */
  92025. idleRotationSpeed: number;
  92026. /**
  92027. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  92028. */
  92029. /**
  92030. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  92031. */
  92032. idleRotationWaitTime: number;
  92033. /**
  92034. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  92035. */
  92036. /**
  92037. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  92038. */
  92039. idleRotationSpinupTime: number;
  92040. /**
  92041. * Gets a value indicating if the camera is currently rotating because of this behavior
  92042. */
  92043. readonly rotationInProgress: boolean;
  92044. private _onPrePointerObservableObserver;
  92045. private _onAfterCheckInputsObserver;
  92046. private _attachedCamera;
  92047. private _isPointerDown;
  92048. private _lastFrameTime;
  92049. private _lastInteractionTime;
  92050. private _cameraRotationSpeed;
  92051. /**
  92052. * Initializes the behavior.
  92053. */
  92054. init(): void;
  92055. /**
  92056. * Attaches the behavior to its arc rotate camera.
  92057. * @param camera Defines the camera to attach the behavior to
  92058. */
  92059. attach(camera: ArcRotateCamera): void;
  92060. /**
  92061. * Detaches the behavior from its current arc rotate camera.
  92062. */
  92063. detach(): void;
  92064. /**
  92065. * Returns true if user is scrolling.
  92066. * @return true if user is scrolling.
  92067. */
  92068. private _userIsZooming;
  92069. private _lastFrameRadius;
  92070. private _shouldAnimationStopForInteraction;
  92071. /**
  92072. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  92073. */
  92074. private _applyUserInteraction;
  92075. private _userIsMoving;
  92076. }
  92077. }
  92078. declare module BABYLON {
  92079. /**
  92080. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  92081. */
  92082. export class AttachToBoxBehavior implements Behavior<Mesh> {
  92083. private ui;
  92084. /**
  92085. * The name of the behavior
  92086. */
  92087. name: string;
  92088. /**
  92089. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  92090. */
  92091. distanceAwayFromFace: number;
  92092. /**
  92093. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  92094. */
  92095. distanceAwayFromBottomOfFace: number;
  92096. private _faceVectors;
  92097. private _target;
  92098. private _scene;
  92099. private _onRenderObserver;
  92100. private _tmpMatrix;
  92101. private _tmpVector;
  92102. /**
  92103. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  92104. * @param ui The transform node that should be attched to the mesh
  92105. */
  92106. constructor(ui: TransformNode);
  92107. /**
  92108. * Initializes the behavior
  92109. */
  92110. init(): void;
  92111. private _closestFace;
  92112. private _zeroVector;
  92113. private _lookAtTmpMatrix;
  92114. private _lookAtToRef;
  92115. /**
  92116. * Attaches the AttachToBoxBehavior to the passed in mesh
  92117. * @param target The mesh that the specified node will be attached to
  92118. */
  92119. attach(target: Mesh): void;
  92120. /**
  92121. * Detaches the behavior from the mesh
  92122. */
  92123. detach(): void;
  92124. }
  92125. }
  92126. declare module BABYLON {
  92127. /**
  92128. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  92129. */
  92130. export class FadeInOutBehavior implements Behavior<Mesh> {
  92131. /**
  92132. * Time in milliseconds to delay before fading in (Default: 0)
  92133. */
  92134. delay: number;
  92135. /**
  92136. * Time in milliseconds for the mesh to fade in (Default: 300)
  92137. */
  92138. fadeInTime: number;
  92139. private _millisecondsPerFrame;
  92140. private _hovered;
  92141. private _hoverValue;
  92142. private _ownerNode;
  92143. /**
  92144. * Instatiates the FadeInOutBehavior
  92145. */
  92146. constructor();
  92147. /**
  92148. * The name of the behavior
  92149. */
  92150. readonly name: string;
  92151. /**
  92152. * Initializes the behavior
  92153. */
  92154. init(): void;
  92155. /**
  92156. * Attaches the fade behavior on the passed in mesh
  92157. * @param ownerNode The mesh that will be faded in/out once attached
  92158. */
  92159. attach(ownerNode: Mesh): void;
  92160. /**
  92161. * Detaches the behavior from the mesh
  92162. */
  92163. detach(): void;
  92164. /**
  92165. * Triggers the mesh to begin fading in or out
  92166. * @param value if the object should fade in or out (true to fade in)
  92167. */
  92168. fadeIn(value: boolean): void;
  92169. private _update;
  92170. private _setAllVisibility;
  92171. }
  92172. }
  92173. declare module BABYLON {
  92174. /**
  92175. * Class containing a set of static utilities functions for managing Pivots
  92176. * @hidden
  92177. */
  92178. export class PivotTools {
  92179. private static _PivotCached;
  92180. private static _OldPivotPoint;
  92181. private static _PivotTranslation;
  92182. private static _PivotTmpVector;
  92183. /** @hidden */
  92184. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  92185. /** @hidden */
  92186. static _RestorePivotPoint(mesh: AbstractMesh): void;
  92187. }
  92188. }
  92189. declare module BABYLON {
  92190. /**
  92191. * Class containing static functions to help procedurally build meshes
  92192. */
  92193. export class PlaneBuilder {
  92194. /**
  92195. * Creates a plane mesh
  92196. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  92197. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  92198. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  92199. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  92200. * * If you create a double-sided mesh, you can choose what parts of 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
  92201. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  92202. * @param name defines the name of the mesh
  92203. * @param options defines the options used to create the mesh
  92204. * @param scene defines the hosting scene
  92205. * @returns the plane mesh
  92206. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  92207. */
  92208. static CreatePlane(name: string, options: {
  92209. size?: number;
  92210. width?: number;
  92211. height?: number;
  92212. sideOrientation?: number;
  92213. frontUVs?: Vector4;
  92214. backUVs?: Vector4;
  92215. updatable?: boolean;
  92216. sourcePlane?: Plane;
  92217. }, scene: Scene): Mesh;
  92218. }
  92219. }
  92220. declare module BABYLON {
  92221. /**
  92222. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  92223. */
  92224. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  92225. private static _AnyMouseID;
  92226. private _attachedNode;
  92227. private _dragPlane;
  92228. private _scene;
  92229. private _pointerObserver;
  92230. private _beforeRenderObserver;
  92231. private static _planeScene;
  92232. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  92233. /**
  92234. * 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)
  92235. */
  92236. maxDragAngle: number;
  92237. /**
  92238. * @hidden
  92239. */
  92240. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  92241. /**
  92242. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  92243. */
  92244. currentDraggingPointerID: number;
  92245. /**
  92246. * The last position where the pointer hit the drag plane in world space
  92247. */
  92248. lastDragPosition: Vector3;
  92249. /**
  92250. * If the behavior is currently in a dragging state
  92251. */
  92252. dragging: boolean;
  92253. /**
  92254. * 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)
  92255. */
  92256. dragDeltaRatio: number;
  92257. /**
  92258. * If the drag plane orientation should be updated during the dragging (Default: true)
  92259. */
  92260. updateDragPlane: boolean;
  92261. private _debugMode;
  92262. private _moving;
  92263. /**
  92264. * Fires each time the attached mesh is dragged with the pointer
  92265. * * delta between last drag position and current drag position in world space
  92266. * * dragDistance along the drag axis
  92267. * * dragPlaneNormal normal of the current drag plane used during the drag
  92268. * * dragPlanePoint in world space where the drag intersects the drag plane
  92269. */
  92270. onDragObservable: Observable<{
  92271. delta: Vector3;
  92272. dragPlanePoint: Vector3;
  92273. dragPlaneNormal: Vector3;
  92274. dragDistance: number;
  92275. pointerId: number;
  92276. }>;
  92277. /**
  92278. * Fires each time a drag begins (eg. mouse down on mesh)
  92279. */
  92280. onDragStartObservable: Observable<{
  92281. dragPlanePoint: Vector3;
  92282. pointerId: number;
  92283. }>;
  92284. /**
  92285. * Fires each time a drag ends (eg. mouse release after drag)
  92286. */
  92287. onDragEndObservable: Observable<{
  92288. dragPlanePoint: Vector3;
  92289. pointerId: number;
  92290. }>;
  92291. /**
  92292. * If the attached mesh should be moved when dragged
  92293. */
  92294. moveAttached: boolean;
  92295. /**
  92296. * If the drag behavior will react to drag events (Default: true)
  92297. */
  92298. enabled: boolean;
  92299. /**
  92300. * If camera controls should be detached during the drag
  92301. */
  92302. detachCameraControls: boolean;
  92303. /**
  92304. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  92305. */
  92306. useObjectOrienationForDragging: boolean;
  92307. private _options;
  92308. /**
  92309. * Creates a pointer drag behavior that can be attached to a mesh
  92310. * @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)
  92311. */
  92312. constructor(options?: {
  92313. dragAxis?: Vector3;
  92314. dragPlaneNormal?: Vector3;
  92315. });
  92316. /**
  92317. * Predicate to determine if it is valid to move the object to a new position when it is moved
  92318. */
  92319. validateDrag: (targetPosition: Vector3) => boolean;
  92320. /**
  92321. * The name of the behavior
  92322. */
  92323. readonly name: string;
  92324. /**
  92325. * Initializes the behavior
  92326. */
  92327. init(): void;
  92328. private _tmpVector;
  92329. private _alternatePickedPoint;
  92330. private _worldDragAxis;
  92331. private _targetPosition;
  92332. private _attachedElement;
  92333. /**
  92334. * Attaches the drag behavior the passed in mesh
  92335. * @param ownerNode The mesh that will be dragged around once attached
  92336. */
  92337. attach(ownerNode: AbstractMesh): void;
  92338. /**
  92339. * Force relase the drag action by code.
  92340. */
  92341. releaseDrag(): void;
  92342. private _startDragRay;
  92343. private _lastPointerRay;
  92344. /**
  92345. * Simulates the start of a pointer drag event on the behavior
  92346. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  92347. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  92348. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  92349. */
  92350. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  92351. private _startDrag;
  92352. private _dragDelta;
  92353. private _moveDrag;
  92354. private _pickWithRayOnDragPlane;
  92355. private _pointA;
  92356. private _pointB;
  92357. private _pointC;
  92358. private _lineA;
  92359. private _lineB;
  92360. private _localAxis;
  92361. private _lookAt;
  92362. private _updateDragPlanePosition;
  92363. /**
  92364. * Detaches the behavior from the mesh
  92365. */
  92366. detach(): void;
  92367. }
  92368. }
  92369. declare module BABYLON {
  92370. /**
  92371. * A behavior that when attached to a mesh will allow the mesh to be scaled
  92372. */
  92373. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  92374. private _dragBehaviorA;
  92375. private _dragBehaviorB;
  92376. private _startDistance;
  92377. private _initialScale;
  92378. private _targetScale;
  92379. private _ownerNode;
  92380. private _sceneRenderObserver;
  92381. /**
  92382. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  92383. */
  92384. constructor();
  92385. /**
  92386. * The name of the behavior
  92387. */
  92388. readonly name: string;
  92389. /**
  92390. * Initializes the behavior
  92391. */
  92392. init(): void;
  92393. private _getCurrentDistance;
  92394. /**
  92395. * Attaches the scale behavior the passed in mesh
  92396. * @param ownerNode The mesh that will be scaled around once attached
  92397. */
  92398. attach(ownerNode: Mesh): void;
  92399. /**
  92400. * Detaches the behavior from the mesh
  92401. */
  92402. detach(): void;
  92403. }
  92404. }
  92405. declare module BABYLON {
  92406. /**
  92407. * 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
  92408. */
  92409. export class SixDofDragBehavior implements Behavior<Mesh> {
  92410. private static _virtualScene;
  92411. private _ownerNode;
  92412. private _sceneRenderObserver;
  92413. private _scene;
  92414. private _targetPosition;
  92415. private _virtualOriginMesh;
  92416. private _virtualDragMesh;
  92417. private _pointerObserver;
  92418. private _moving;
  92419. private _startingOrientation;
  92420. /**
  92421. * 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)
  92422. */
  92423. private zDragFactor;
  92424. /**
  92425. * If the object should rotate to face the drag origin
  92426. */
  92427. rotateDraggedObject: boolean;
  92428. /**
  92429. * If the behavior is currently in a dragging state
  92430. */
  92431. dragging: boolean;
  92432. /**
  92433. * 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)
  92434. */
  92435. dragDeltaRatio: number;
  92436. /**
  92437. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  92438. */
  92439. currentDraggingPointerID: number;
  92440. /**
  92441. * If camera controls should be detached during the drag
  92442. */
  92443. detachCameraControls: boolean;
  92444. /**
  92445. * Fires each time a drag starts
  92446. */
  92447. onDragStartObservable: Observable<{}>;
  92448. /**
  92449. * Fires each time a drag ends (eg. mouse release after drag)
  92450. */
  92451. onDragEndObservable: Observable<{}>;
  92452. /**
  92453. * 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
  92454. */
  92455. constructor();
  92456. /**
  92457. * The name of the behavior
  92458. */
  92459. readonly name: string;
  92460. /**
  92461. * Initializes the behavior
  92462. */
  92463. init(): void;
  92464. /**
  92465. * Attaches the scale behavior the passed in mesh
  92466. * @param ownerNode The mesh that will be scaled around once attached
  92467. */
  92468. attach(ownerNode: Mesh): void;
  92469. /**
  92470. * Detaches the behavior from the mesh
  92471. */
  92472. detach(): void;
  92473. }
  92474. }
  92475. declare module BABYLON {
  92476. /**
  92477. * Class used to apply inverse kinematics to bones
  92478. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  92479. */
  92480. export class BoneIKController {
  92481. private static _tmpVecs;
  92482. private static _tmpQuat;
  92483. private static _tmpMats;
  92484. /**
  92485. * Gets or sets the target mesh
  92486. */
  92487. targetMesh: AbstractMesh;
  92488. /** Gets or sets the mesh used as pole */
  92489. poleTargetMesh: AbstractMesh;
  92490. /**
  92491. * Gets or sets the bone used as pole
  92492. */
  92493. poleTargetBone: Nullable<Bone>;
  92494. /**
  92495. * Gets or sets the target position
  92496. */
  92497. targetPosition: Vector3;
  92498. /**
  92499. * Gets or sets the pole target position
  92500. */
  92501. poleTargetPosition: Vector3;
  92502. /**
  92503. * Gets or sets the pole target local offset
  92504. */
  92505. poleTargetLocalOffset: Vector3;
  92506. /**
  92507. * Gets or sets the pole angle
  92508. */
  92509. poleAngle: number;
  92510. /**
  92511. * Gets or sets the mesh associated with the controller
  92512. */
  92513. mesh: AbstractMesh;
  92514. /**
  92515. * 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)
  92516. */
  92517. slerpAmount: number;
  92518. private _bone1Quat;
  92519. private _bone1Mat;
  92520. private _bone2Ang;
  92521. private _bone1;
  92522. private _bone2;
  92523. private _bone1Length;
  92524. private _bone2Length;
  92525. private _maxAngle;
  92526. private _maxReach;
  92527. private _rightHandedSystem;
  92528. private _bendAxis;
  92529. private _slerping;
  92530. private _adjustRoll;
  92531. /**
  92532. * Gets or sets maximum allowed angle
  92533. */
  92534. maxAngle: number;
  92535. /**
  92536. * Creates a new BoneIKController
  92537. * @param mesh defines the mesh to control
  92538. * @param bone defines the bone to control
  92539. * @param options defines options to set up the controller
  92540. */
  92541. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  92542. targetMesh?: AbstractMesh;
  92543. poleTargetMesh?: AbstractMesh;
  92544. poleTargetBone?: Bone;
  92545. poleTargetLocalOffset?: Vector3;
  92546. poleAngle?: number;
  92547. bendAxis?: Vector3;
  92548. maxAngle?: number;
  92549. slerpAmount?: number;
  92550. });
  92551. private _setMaxAngle;
  92552. /**
  92553. * Force the controller to update the bones
  92554. */
  92555. update(): void;
  92556. }
  92557. }
  92558. declare module BABYLON {
  92559. /**
  92560. * Class used to make a bone look toward a point in space
  92561. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  92562. */
  92563. export class BoneLookController {
  92564. private static _tmpVecs;
  92565. private static _tmpQuat;
  92566. private static _tmpMats;
  92567. /**
  92568. * The target Vector3 that the bone will look at
  92569. */
  92570. target: Vector3;
  92571. /**
  92572. * The mesh that the bone is attached to
  92573. */
  92574. mesh: AbstractMesh;
  92575. /**
  92576. * The bone that will be looking to the target
  92577. */
  92578. bone: Bone;
  92579. /**
  92580. * The up axis of the coordinate system that is used when the bone is rotated
  92581. */
  92582. upAxis: Vector3;
  92583. /**
  92584. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  92585. */
  92586. upAxisSpace: Space;
  92587. /**
  92588. * Used to make an adjustment to the yaw of the bone
  92589. */
  92590. adjustYaw: number;
  92591. /**
  92592. * Used to make an adjustment to the pitch of the bone
  92593. */
  92594. adjustPitch: number;
  92595. /**
  92596. * Used to make an adjustment to the roll of the bone
  92597. */
  92598. adjustRoll: number;
  92599. /**
  92600. * 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)
  92601. */
  92602. slerpAmount: number;
  92603. private _minYaw;
  92604. private _maxYaw;
  92605. private _minPitch;
  92606. private _maxPitch;
  92607. private _minYawSin;
  92608. private _minYawCos;
  92609. private _maxYawSin;
  92610. private _maxYawCos;
  92611. private _midYawConstraint;
  92612. private _minPitchTan;
  92613. private _maxPitchTan;
  92614. private _boneQuat;
  92615. private _slerping;
  92616. private _transformYawPitch;
  92617. private _transformYawPitchInv;
  92618. private _firstFrameSkipped;
  92619. private _yawRange;
  92620. private _fowardAxis;
  92621. /**
  92622. * Gets or sets the minimum yaw angle that the bone can look to
  92623. */
  92624. minYaw: number;
  92625. /**
  92626. * Gets or sets the maximum yaw angle that the bone can look to
  92627. */
  92628. maxYaw: number;
  92629. /**
  92630. * Gets or sets the minimum pitch angle that the bone can look to
  92631. */
  92632. minPitch: number;
  92633. /**
  92634. * Gets or sets the maximum pitch angle that the bone can look to
  92635. */
  92636. maxPitch: number;
  92637. /**
  92638. * Create a BoneLookController
  92639. * @param mesh the mesh that the bone belongs to
  92640. * @param bone the bone that will be looking to the target
  92641. * @param target the target Vector3 to look at
  92642. * @param options optional settings:
  92643. * * maxYaw: the maximum angle the bone will yaw to
  92644. * * minYaw: the minimum angle the bone will yaw to
  92645. * * maxPitch: the maximum angle the bone will pitch to
  92646. * * minPitch: the minimum angle the bone will yaw to
  92647. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  92648. * * upAxis: the up axis of the coordinate system
  92649. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  92650. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  92651. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  92652. * * adjustYaw: used to make an adjustment to the yaw of the bone
  92653. * * adjustPitch: used to make an adjustment to the pitch of the bone
  92654. * * adjustRoll: used to make an adjustment to the roll of the bone
  92655. **/
  92656. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  92657. maxYaw?: number;
  92658. minYaw?: number;
  92659. maxPitch?: number;
  92660. minPitch?: number;
  92661. slerpAmount?: number;
  92662. upAxis?: Vector3;
  92663. upAxisSpace?: Space;
  92664. yawAxis?: Vector3;
  92665. pitchAxis?: Vector3;
  92666. adjustYaw?: number;
  92667. adjustPitch?: number;
  92668. adjustRoll?: number;
  92669. });
  92670. /**
  92671. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  92672. */
  92673. update(): void;
  92674. private _getAngleDiff;
  92675. private _getAngleBetween;
  92676. private _isAngleBetween;
  92677. }
  92678. }
  92679. declare module BABYLON {
  92680. /**
  92681. * Manage the gamepad inputs to control an arc rotate camera.
  92682. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  92683. */
  92684. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  92685. /**
  92686. * Defines the camera the input is attached to.
  92687. */
  92688. camera: ArcRotateCamera;
  92689. /**
  92690. * Defines the gamepad the input is gathering event from.
  92691. */
  92692. gamepad: Nullable<Gamepad>;
  92693. /**
  92694. * Defines the gamepad rotation sensiblity.
  92695. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  92696. */
  92697. gamepadRotationSensibility: number;
  92698. /**
  92699. * Defines the gamepad move sensiblity.
  92700. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  92701. */
  92702. gamepadMoveSensibility: number;
  92703. private _onGamepadConnectedObserver;
  92704. private _onGamepadDisconnectedObserver;
  92705. /**
  92706. * Attach the input controls to a specific dom element to get the input from.
  92707. * @param element Defines the element the controls should be listened from
  92708. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  92709. */
  92710. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  92711. /**
  92712. * Detach the current controls from the specified dom element.
  92713. * @param element Defines the element to stop listening the inputs from
  92714. */
  92715. detachControl(element: Nullable<HTMLElement>): void;
  92716. /**
  92717. * Update the current camera state depending on the inputs that have been used this frame.
  92718. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  92719. */
  92720. checkInputs(): void;
  92721. /**
  92722. * Gets the class name of the current intput.
  92723. * @returns the class name
  92724. */
  92725. getClassName(): string;
  92726. /**
  92727. * Get the friendly name associated with the input class.
  92728. * @returns the input friendly name
  92729. */
  92730. getSimpleName(): string;
  92731. }
  92732. }
  92733. declare module BABYLON {
  92734. interface ArcRotateCameraInputsManager {
  92735. /**
  92736. * Add orientation input support to the input manager.
  92737. * @returns the current input manager
  92738. */
  92739. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  92740. }
  92741. /**
  92742. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  92743. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  92744. */
  92745. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  92746. /**
  92747. * Defines the camera the input is attached to.
  92748. */
  92749. camera: ArcRotateCamera;
  92750. /**
  92751. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  92752. */
  92753. alphaCorrection: number;
  92754. /**
  92755. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  92756. */
  92757. gammaCorrection: number;
  92758. private _alpha;
  92759. private _gamma;
  92760. private _dirty;
  92761. private _deviceOrientationHandler;
  92762. /**
  92763. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  92764. */
  92765. constructor();
  92766. /**
  92767. * Attach the input controls to a specific dom element to get the input from.
  92768. * @param element Defines the element the controls should be listened from
  92769. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  92770. */
  92771. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  92772. /** @hidden */
  92773. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  92774. /**
  92775. * Update the current camera state depending on the inputs that have been used this frame.
  92776. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  92777. */
  92778. checkInputs(): void;
  92779. /**
  92780. * Detach the current controls from the specified dom element.
  92781. * @param element Defines the element to stop listening the inputs from
  92782. */
  92783. detachControl(element: Nullable<HTMLElement>): void;
  92784. /**
  92785. * Gets the class name of the current intput.
  92786. * @returns the class name
  92787. */
  92788. getClassName(): string;
  92789. /**
  92790. * Get the friendly name associated with the input class.
  92791. * @returns the input friendly name
  92792. */
  92793. getSimpleName(): string;
  92794. }
  92795. }
  92796. declare module BABYLON {
  92797. /**
  92798. * Listen to mouse events to control the camera.
  92799. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  92800. */
  92801. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  92802. /**
  92803. * Defines the camera the input is attached to.
  92804. */
  92805. camera: FlyCamera;
  92806. /**
  92807. * Defines if touch is enabled. (Default is true.)
  92808. */
  92809. touchEnabled: boolean;
  92810. /**
  92811. * Defines the buttons associated with the input to handle camera rotation.
  92812. */
  92813. buttons: number[];
  92814. /**
  92815. * Assign buttons for Yaw control.
  92816. */
  92817. buttonsYaw: number[];
  92818. /**
  92819. * Assign buttons for Pitch control.
  92820. */
  92821. buttonsPitch: number[];
  92822. /**
  92823. * Assign buttons for Roll control.
  92824. */
  92825. buttonsRoll: number[];
  92826. /**
  92827. * Detect if any button is being pressed while mouse is moved.
  92828. * -1 = Mouse locked.
  92829. * 0 = Left button.
  92830. * 1 = Middle Button.
  92831. * 2 = Right Button.
  92832. */
  92833. activeButton: number;
  92834. /**
  92835. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  92836. * Higher values reduce its sensitivity.
  92837. */
  92838. angularSensibility: number;
  92839. private _mousemoveCallback;
  92840. private _observer;
  92841. private _rollObserver;
  92842. private previousPosition;
  92843. private noPreventDefault;
  92844. private element;
  92845. /**
  92846. * Listen to mouse events to control the camera.
  92847. * @param touchEnabled Define if touch is enabled. (Default is true.)
  92848. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  92849. */
  92850. constructor(touchEnabled?: boolean);
  92851. /**
  92852. * Attach the mouse control to the HTML DOM element.
  92853. * @param element Defines the element that listens to the input events.
  92854. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  92855. */
  92856. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  92857. /**
  92858. * Detach the current controls from the specified dom element.
  92859. * @param element Defines the element to stop listening the inputs from
  92860. */
  92861. detachControl(element: Nullable<HTMLElement>): void;
  92862. /**
  92863. * Gets the class name of the current input.
  92864. * @returns the class name.
  92865. */
  92866. getClassName(): string;
  92867. /**
  92868. * Get the friendly name associated with the input class.
  92869. * @returns the input's friendly name.
  92870. */
  92871. getSimpleName(): string;
  92872. private _pointerInput;
  92873. private _onMouseMove;
  92874. /**
  92875. * Rotate camera by mouse offset.
  92876. */
  92877. private rotateCamera;
  92878. }
  92879. }
  92880. declare module BABYLON {
  92881. /**
  92882. * Default Inputs manager for the FlyCamera.
  92883. * It groups all the default supported inputs for ease of use.
  92884. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  92885. */
  92886. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  92887. /**
  92888. * Instantiates a new FlyCameraInputsManager.
  92889. * @param camera Defines the camera the inputs belong to.
  92890. */
  92891. constructor(camera: FlyCamera);
  92892. /**
  92893. * Add keyboard input support to the input manager.
  92894. * @returns the new FlyCameraKeyboardMoveInput().
  92895. */
  92896. addKeyboard(): FlyCameraInputsManager;
  92897. /**
  92898. * Add mouse input support to the input manager.
  92899. * @param touchEnabled Enable touch screen support.
  92900. * @returns the new FlyCameraMouseInput().
  92901. */
  92902. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  92903. }
  92904. }
  92905. declare module BABYLON {
  92906. /**
  92907. * This is a flying camera, designed for 3D movement and rotation in all directions,
  92908. * such as in a 3D Space Shooter or a Flight Simulator.
  92909. */
  92910. export class FlyCamera extends TargetCamera {
  92911. /**
  92912. * Define the collision ellipsoid of the camera.
  92913. * This is helpful for simulating a camera body, like a player's body.
  92914. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  92915. */
  92916. ellipsoid: Vector3;
  92917. /**
  92918. * Define an offset for the position of the ellipsoid around the camera.
  92919. * This can be helpful if the camera is attached away from the player's body center,
  92920. * such as at its head.
  92921. */
  92922. ellipsoidOffset: Vector3;
  92923. /**
  92924. * Enable or disable collisions of the camera with the rest of the scene objects.
  92925. */
  92926. checkCollisions: boolean;
  92927. /**
  92928. * Enable or disable gravity on the camera.
  92929. */
  92930. applyGravity: boolean;
  92931. /**
  92932. * Define the current direction the camera is moving to.
  92933. */
  92934. cameraDirection: Vector3;
  92935. /**
  92936. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  92937. * This overrides and empties cameraRotation.
  92938. */
  92939. rotationQuaternion: Quaternion;
  92940. /**
  92941. * Track Roll to maintain the wanted Rolling when looking around.
  92942. */
  92943. _trackRoll: number;
  92944. /**
  92945. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  92946. */
  92947. rollCorrect: number;
  92948. /**
  92949. * Mimic a banked turn, Rolling the camera when Yawing.
  92950. * It's recommended to use rollCorrect = 10 for faster banking correction.
  92951. */
  92952. bankedTurn: boolean;
  92953. /**
  92954. * Limit in radians for how much Roll banking will add. (Default: 90°)
  92955. */
  92956. bankedTurnLimit: number;
  92957. /**
  92958. * Value of 0 disables the banked Roll.
  92959. * Value of 1 is equal to the Yaw angle in radians.
  92960. */
  92961. bankedTurnMultiplier: number;
  92962. /**
  92963. * The inputs manager loads all the input sources, such as keyboard and mouse.
  92964. */
  92965. inputs: FlyCameraInputsManager;
  92966. /**
  92967. * Gets the input sensibility for mouse input.
  92968. * Higher values reduce sensitivity.
  92969. */
  92970. /**
  92971. * Sets the input sensibility for a mouse input.
  92972. * Higher values reduce sensitivity.
  92973. */
  92974. angularSensibility: number;
  92975. /**
  92976. * Get the keys for camera movement forward.
  92977. */
  92978. /**
  92979. * Set the keys for camera movement forward.
  92980. */
  92981. keysForward: number[];
  92982. /**
  92983. * Get the keys for camera movement backward.
  92984. */
  92985. keysBackward: number[];
  92986. /**
  92987. * Get the keys for camera movement up.
  92988. */
  92989. /**
  92990. * Set the keys for camera movement up.
  92991. */
  92992. keysUp: number[];
  92993. /**
  92994. * Get the keys for camera movement down.
  92995. */
  92996. /**
  92997. * Set the keys for camera movement down.
  92998. */
  92999. keysDown: number[];
  93000. /**
  93001. * Get the keys for camera movement left.
  93002. */
  93003. /**
  93004. * Set the keys for camera movement left.
  93005. */
  93006. keysLeft: number[];
  93007. /**
  93008. * Set the keys for camera movement right.
  93009. */
  93010. /**
  93011. * Set the keys for camera movement right.
  93012. */
  93013. keysRight: number[];
  93014. /**
  93015. * Event raised when the camera collides with a mesh in the scene.
  93016. */
  93017. onCollide: (collidedMesh: AbstractMesh) => void;
  93018. private _collider;
  93019. private _needMoveForGravity;
  93020. private _oldPosition;
  93021. private _diffPosition;
  93022. private _newPosition;
  93023. /** @hidden */
  93024. _localDirection: Vector3;
  93025. /** @hidden */
  93026. _transformedDirection: Vector3;
  93027. /**
  93028. * Instantiates a FlyCamera.
  93029. * This is a flying camera, designed for 3D movement and rotation in all directions,
  93030. * such as in a 3D Space Shooter or a Flight Simulator.
  93031. * @param name Define the name of the camera in the scene.
  93032. * @param position Define the starting position of the camera in the scene.
  93033. * @param scene Define the scene the camera belongs to.
  93034. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  93035. */
  93036. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  93037. /**
  93038. * Attach a control to the HTML DOM element.
  93039. * @param element Defines the element that listens to the input events.
  93040. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  93041. */
  93042. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  93043. /**
  93044. * Detach a control from the HTML DOM element.
  93045. * The camera will stop reacting to that input.
  93046. * @param element Defines the element that listens to the input events.
  93047. */
  93048. detachControl(element: HTMLElement): void;
  93049. private _collisionMask;
  93050. /**
  93051. * Get the mask that the camera ignores in collision events.
  93052. */
  93053. /**
  93054. * Set the mask that the camera ignores in collision events.
  93055. */
  93056. collisionMask: number;
  93057. /** @hidden */
  93058. _collideWithWorld(displacement: Vector3): void;
  93059. /** @hidden */
  93060. private _onCollisionPositionChange;
  93061. /** @hidden */
  93062. _checkInputs(): void;
  93063. /** @hidden */
  93064. _decideIfNeedsToMove(): boolean;
  93065. /** @hidden */
  93066. _updatePosition(): void;
  93067. /**
  93068. * Restore the Roll to its target value at the rate specified.
  93069. * @param rate - Higher means slower restoring.
  93070. * @hidden
  93071. */
  93072. restoreRoll(rate: number): void;
  93073. /**
  93074. * Destroy the camera and release the current resources held by it.
  93075. */
  93076. dispose(): void;
  93077. /**
  93078. * Get the current object class name.
  93079. * @returns the class name.
  93080. */
  93081. getClassName(): string;
  93082. }
  93083. }
  93084. declare module BABYLON {
  93085. /**
  93086. * Listen to keyboard events to control the camera.
  93087. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  93088. */
  93089. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  93090. /**
  93091. * Defines the camera the input is attached to.
  93092. */
  93093. camera: FlyCamera;
  93094. /**
  93095. * The list of keyboard keys used to control the forward move of the camera.
  93096. */
  93097. keysForward: number[];
  93098. /**
  93099. * The list of keyboard keys used to control the backward move of the camera.
  93100. */
  93101. keysBackward: number[];
  93102. /**
  93103. * The list of keyboard keys used to control the forward move of the camera.
  93104. */
  93105. keysUp: number[];
  93106. /**
  93107. * The list of keyboard keys used to control the backward move of the camera.
  93108. */
  93109. keysDown: number[];
  93110. /**
  93111. * The list of keyboard keys used to control the right strafe move of the camera.
  93112. */
  93113. keysRight: number[];
  93114. /**
  93115. * The list of keyboard keys used to control the left strafe move of the camera.
  93116. */
  93117. keysLeft: number[];
  93118. private _keys;
  93119. private _onCanvasBlurObserver;
  93120. private _onKeyboardObserver;
  93121. private _engine;
  93122. private _scene;
  93123. /**
  93124. * Attach the input controls to a specific dom element to get the input from.
  93125. * @param element Defines the element the controls should be listened from
  93126. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  93127. */
  93128. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  93129. /**
  93130. * Detach the current controls from the specified dom element.
  93131. * @param element Defines the element to stop listening the inputs from
  93132. */
  93133. detachControl(element: Nullable<HTMLElement>): void;
  93134. /**
  93135. * Gets the class name of the current intput.
  93136. * @returns the class name
  93137. */
  93138. getClassName(): string;
  93139. /** @hidden */
  93140. _onLostFocus(e: FocusEvent): void;
  93141. /**
  93142. * Get the friendly name associated with the input class.
  93143. * @returns the input friendly name
  93144. */
  93145. getSimpleName(): string;
  93146. /**
  93147. * Update the current camera state depending on the inputs that have been used this frame.
  93148. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  93149. */
  93150. checkInputs(): void;
  93151. }
  93152. }
  93153. declare module BABYLON {
  93154. /**
  93155. * Manage the mouse wheel inputs to control a follow camera.
  93156. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  93157. */
  93158. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  93159. /**
  93160. * Defines the camera the input is attached to.
  93161. */
  93162. camera: FollowCamera;
  93163. /**
  93164. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  93165. */
  93166. axisControlRadius: boolean;
  93167. /**
  93168. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  93169. */
  93170. axisControlHeight: boolean;
  93171. /**
  93172. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  93173. */
  93174. axisControlRotation: boolean;
  93175. /**
  93176. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  93177. * relation to mouseWheel events.
  93178. */
  93179. wheelPrecision: number;
  93180. /**
  93181. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  93182. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  93183. */
  93184. wheelDeltaPercentage: number;
  93185. private _wheel;
  93186. private _observer;
  93187. /**
  93188. * Attach the input controls to a specific dom element to get the input from.
  93189. * @param element Defines the element the controls should be listened from
  93190. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  93191. */
  93192. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  93193. /**
  93194. * Detach the current controls from the specified dom element.
  93195. * @param element Defines the element to stop listening the inputs from
  93196. */
  93197. detachControl(element: Nullable<HTMLElement>): void;
  93198. /**
  93199. * Gets the class name of the current intput.
  93200. * @returns the class name
  93201. */
  93202. getClassName(): string;
  93203. /**
  93204. * Get the friendly name associated with the input class.
  93205. * @returns the input friendly name
  93206. */
  93207. getSimpleName(): string;
  93208. }
  93209. }
  93210. declare module BABYLON {
  93211. /**
  93212. * Manage the pointers inputs to control an follow camera.
  93213. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  93214. */
  93215. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  93216. /**
  93217. * Defines the camera the input is attached to.
  93218. */
  93219. camera: FollowCamera;
  93220. /**
  93221. * Gets the class name of the current input.
  93222. * @returns the class name
  93223. */
  93224. getClassName(): string;
  93225. /**
  93226. * Defines the pointer angular sensibility along the X axis or how fast is
  93227. * the camera rotating.
  93228. * A negative number will reverse the axis direction.
  93229. */
  93230. angularSensibilityX: number;
  93231. /**
  93232. * Defines the pointer angular sensibility along the Y axis or how fast is
  93233. * the camera rotating.
  93234. * A negative number will reverse the axis direction.
  93235. */
  93236. angularSensibilityY: number;
  93237. /**
  93238. * Defines the pointer pinch precision or how fast is the camera zooming.
  93239. * A negative number will reverse the axis direction.
  93240. */
  93241. pinchPrecision: number;
  93242. /**
  93243. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  93244. * from 0.
  93245. * It defines the percentage of current camera.radius to use as delta when
  93246. * pinch zoom is used.
  93247. */
  93248. pinchDeltaPercentage: number;
  93249. /**
  93250. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  93251. */
  93252. axisXControlRadius: boolean;
  93253. /**
  93254. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  93255. */
  93256. axisXControlHeight: boolean;
  93257. /**
  93258. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  93259. */
  93260. axisXControlRotation: boolean;
  93261. /**
  93262. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  93263. */
  93264. axisYControlRadius: boolean;
  93265. /**
  93266. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  93267. */
  93268. axisYControlHeight: boolean;
  93269. /**
  93270. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  93271. */
  93272. axisYControlRotation: boolean;
  93273. /**
  93274. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  93275. */
  93276. axisPinchControlRadius: boolean;
  93277. /**
  93278. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  93279. */
  93280. axisPinchControlHeight: boolean;
  93281. /**
  93282. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  93283. */
  93284. axisPinchControlRotation: boolean;
  93285. /**
  93286. * Log error messages if basic misconfiguration has occurred.
  93287. */
  93288. warningEnable: boolean;
  93289. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  93290. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  93291. private _warningCounter;
  93292. private _warning;
  93293. }
  93294. }
  93295. declare module BABYLON {
  93296. /**
  93297. * Default Inputs manager for the FollowCamera.
  93298. * It groups all the default supported inputs for ease of use.
  93299. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  93300. */
  93301. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  93302. /**
  93303. * Instantiates a new FollowCameraInputsManager.
  93304. * @param camera Defines the camera the inputs belong to
  93305. */
  93306. constructor(camera: FollowCamera);
  93307. /**
  93308. * Add keyboard input support to the input manager.
  93309. * @returns the current input manager
  93310. */
  93311. addKeyboard(): FollowCameraInputsManager;
  93312. /**
  93313. * Add mouse wheel input support to the input manager.
  93314. * @returns the current input manager
  93315. */
  93316. addMouseWheel(): FollowCameraInputsManager;
  93317. /**
  93318. * Add pointers input support to the input manager.
  93319. * @returns the current input manager
  93320. */
  93321. addPointers(): FollowCameraInputsManager;
  93322. /**
  93323. * Add orientation input support to the input manager.
  93324. * @returns the current input manager
  93325. */
  93326. addVRDeviceOrientation(): FollowCameraInputsManager;
  93327. }
  93328. }
  93329. declare module BABYLON {
  93330. /**
  93331. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  93332. * an arc rotate version arcFollowCamera are available.
  93333. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  93334. */
  93335. export class FollowCamera extends TargetCamera {
  93336. /**
  93337. * Distance the follow camera should follow an object at
  93338. */
  93339. radius: number;
  93340. /**
  93341. * Minimum allowed distance of the camera to the axis of rotation
  93342. * (The camera can not get closer).
  93343. * This can help limiting how the Camera is able to move in the scene.
  93344. */
  93345. lowerRadiusLimit: Nullable<number>;
  93346. /**
  93347. * Maximum allowed distance of the camera to the axis of rotation
  93348. * (The camera can not get further).
  93349. * This can help limiting how the Camera is able to move in the scene.
  93350. */
  93351. upperRadiusLimit: Nullable<number>;
  93352. /**
  93353. * Define a rotation offset between the camera and the object it follows
  93354. */
  93355. rotationOffset: number;
  93356. /**
  93357. * Minimum allowed angle to camera position relative to target object.
  93358. * This can help limiting how the Camera is able to move in the scene.
  93359. */
  93360. lowerRotationOffsetLimit: Nullable<number>;
  93361. /**
  93362. * Maximum allowed angle to camera position relative to target object.
  93363. * This can help limiting how the Camera is able to move in the scene.
  93364. */
  93365. upperRotationOffsetLimit: Nullable<number>;
  93366. /**
  93367. * Define a height offset between the camera and the object it follows.
  93368. * It can help following an object from the top (like a car chaing a plane)
  93369. */
  93370. heightOffset: number;
  93371. /**
  93372. * Minimum allowed height of camera position relative to target object.
  93373. * This can help limiting how the Camera is able to move in the scene.
  93374. */
  93375. lowerHeightOffsetLimit: Nullable<number>;
  93376. /**
  93377. * Maximum allowed height of camera position relative to target object.
  93378. * This can help limiting how the Camera is able to move in the scene.
  93379. */
  93380. upperHeightOffsetLimit: Nullable<number>;
  93381. /**
  93382. * Define how fast the camera can accelerate to follow it s target.
  93383. */
  93384. cameraAcceleration: number;
  93385. /**
  93386. * Define the speed limit of the camera following an object.
  93387. */
  93388. maxCameraSpeed: number;
  93389. /**
  93390. * Define the target of the camera.
  93391. */
  93392. lockedTarget: Nullable<AbstractMesh>;
  93393. /**
  93394. * Defines the input associated with the camera.
  93395. */
  93396. inputs: FollowCameraInputsManager;
  93397. /**
  93398. * Instantiates the follow camera.
  93399. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  93400. * @param name Define the name of the camera in the scene
  93401. * @param position Define the position of the camera
  93402. * @param scene Define the scene the camera belong to
  93403. * @param lockedTarget Define the target of the camera
  93404. */
  93405. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  93406. private _follow;
  93407. /**
  93408. * Attached controls to the current camera.
  93409. * @param element Defines the element the controls should be listened from
  93410. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  93411. */
  93412. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  93413. /**
  93414. * Detach the current controls from the camera.
  93415. * The camera will stop reacting to inputs.
  93416. * @param element Defines the element to stop listening the inputs from
  93417. */
  93418. detachControl(element: HTMLElement): void;
  93419. /** @hidden */
  93420. _checkInputs(): void;
  93421. private _checkLimits;
  93422. /**
  93423. * Gets the camera class name.
  93424. * @returns the class name
  93425. */
  93426. getClassName(): string;
  93427. }
  93428. /**
  93429. * Arc Rotate version of the follow camera.
  93430. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  93431. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  93432. */
  93433. export class ArcFollowCamera extends TargetCamera {
  93434. /** The longitudinal angle of the camera */
  93435. alpha: number;
  93436. /** The latitudinal angle of the camera */
  93437. beta: number;
  93438. /** The radius of the camera from its target */
  93439. radius: number;
  93440. /** Define the camera target (the messh it should follow) */
  93441. target: Nullable<AbstractMesh>;
  93442. private _cartesianCoordinates;
  93443. /**
  93444. * Instantiates a new ArcFollowCamera
  93445. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  93446. * @param name Define the name of the camera
  93447. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  93448. * @param beta Define the rotation angle of the camera around the elevation axis
  93449. * @param radius Define the radius of the camera from its target point
  93450. * @param target Define the target of the camera
  93451. * @param scene Define the scene the camera belongs to
  93452. */
  93453. constructor(name: string,
  93454. /** The longitudinal angle of the camera */
  93455. alpha: number,
  93456. /** The latitudinal angle of the camera */
  93457. beta: number,
  93458. /** The radius of the camera from its target */
  93459. radius: number,
  93460. /** Define the camera target (the messh it should follow) */
  93461. target: Nullable<AbstractMesh>, scene: Scene);
  93462. private _follow;
  93463. /** @hidden */
  93464. _checkInputs(): void;
  93465. /**
  93466. * Returns the class name of the object.
  93467. * It is mostly used internally for serialization purposes.
  93468. */
  93469. getClassName(): string;
  93470. }
  93471. }
  93472. declare module BABYLON {
  93473. /**
  93474. * Manage the keyboard inputs to control the movement of a follow camera.
  93475. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  93476. */
  93477. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  93478. /**
  93479. * Defines the camera the input is attached to.
  93480. */
  93481. camera: FollowCamera;
  93482. /**
  93483. * Defines the list of key codes associated with the up action (increase heightOffset)
  93484. */
  93485. keysHeightOffsetIncr: number[];
  93486. /**
  93487. * Defines the list of key codes associated with the down action (decrease heightOffset)
  93488. */
  93489. keysHeightOffsetDecr: number[];
  93490. /**
  93491. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  93492. */
  93493. keysHeightOffsetModifierAlt: boolean;
  93494. /**
  93495. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  93496. */
  93497. keysHeightOffsetModifierCtrl: boolean;
  93498. /**
  93499. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  93500. */
  93501. keysHeightOffsetModifierShift: boolean;
  93502. /**
  93503. * Defines the list of key codes associated with the left action (increase rotationOffset)
  93504. */
  93505. keysRotationOffsetIncr: number[];
  93506. /**
  93507. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  93508. */
  93509. keysRotationOffsetDecr: number[];
  93510. /**
  93511. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  93512. */
  93513. keysRotationOffsetModifierAlt: boolean;
  93514. /**
  93515. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  93516. */
  93517. keysRotationOffsetModifierCtrl: boolean;
  93518. /**
  93519. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  93520. */
  93521. keysRotationOffsetModifierShift: boolean;
  93522. /**
  93523. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  93524. */
  93525. keysRadiusIncr: number[];
  93526. /**
  93527. * Defines the list of key codes associated with the zoom-out action (increase radius)
  93528. */
  93529. keysRadiusDecr: number[];
  93530. /**
  93531. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  93532. */
  93533. keysRadiusModifierAlt: boolean;
  93534. /**
  93535. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  93536. */
  93537. keysRadiusModifierCtrl: boolean;
  93538. /**
  93539. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  93540. */
  93541. keysRadiusModifierShift: boolean;
  93542. /**
  93543. * Defines the rate of change of heightOffset.
  93544. */
  93545. heightSensibility: number;
  93546. /**
  93547. * Defines the rate of change of rotationOffset.
  93548. */
  93549. rotationSensibility: number;
  93550. /**
  93551. * Defines the rate of change of radius.
  93552. */
  93553. radiusSensibility: number;
  93554. private _keys;
  93555. private _ctrlPressed;
  93556. private _altPressed;
  93557. private _shiftPressed;
  93558. private _onCanvasBlurObserver;
  93559. private _onKeyboardObserver;
  93560. private _engine;
  93561. private _scene;
  93562. /**
  93563. * Attach the input controls to a specific dom element to get the input from.
  93564. * @param element Defines the element the controls should be listened from
  93565. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  93566. */
  93567. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  93568. /**
  93569. * Detach the current controls from the specified dom element.
  93570. * @param element Defines the element to stop listening the inputs from
  93571. */
  93572. detachControl(element: Nullable<HTMLElement>): void;
  93573. /**
  93574. * Update the current camera state depending on the inputs that have been used this frame.
  93575. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  93576. */
  93577. checkInputs(): void;
  93578. /**
  93579. * Gets the class name of the current input.
  93580. * @returns the class name
  93581. */
  93582. getClassName(): string;
  93583. /**
  93584. * Get the friendly name associated with the input class.
  93585. * @returns the input friendly name
  93586. */
  93587. getSimpleName(): string;
  93588. /**
  93589. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  93590. * allow modification of the heightOffset value.
  93591. */
  93592. private _modifierHeightOffset;
  93593. /**
  93594. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  93595. * allow modification of the rotationOffset value.
  93596. */
  93597. private _modifierRotationOffset;
  93598. /**
  93599. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  93600. * allow modification of the radius value.
  93601. */
  93602. private _modifierRadius;
  93603. }
  93604. }
  93605. declare module BABYLON {
  93606. interface FreeCameraInputsManager {
  93607. /**
  93608. * Add orientation input support to the input manager.
  93609. * @returns the current input manager
  93610. */
  93611. addDeviceOrientation(): FreeCameraInputsManager;
  93612. }
  93613. /**
  93614. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  93615. * Screen rotation is taken into account.
  93616. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  93617. */
  93618. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  93619. private _camera;
  93620. private _screenOrientationAngle;
  93621. private _constantTranform;
  93622. private _screenQuaternion;
  93623. private _alpha;
  93624. private _beta;
  93625. private _gamma;
  93626. /**
  93627. * Instantiates a new input
  93628. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  93629. */
  93630. constructor();
  93631. /**
  93632. * Define the camera controlled by the input.
  93633. */
  93634. camera: FreeCamera;
  93635. /**
  93636. * Attach the input controls to a specific dom element to get the input from.
  93637. * @param element Defines the element the controls should be listened from
  93638. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  93639. */
  93640. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  93641. private _orientationChanged;
  93642. private _deviceOrientation;
  93643. /**
  93644. * Detach the current controls from the specified dom element.
  93645. * @param element Defines the element to stop listening the inputs from
  93646. */
  93647. detachControl(element: Nullable<HTMLElement>): void;
  93648. /**
  93649. * Update the current camera state depending on the inputs that have been used this frame.
  93650. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  93651. */
  93652. checkInputs(): void;
  93653. /**
  93654. * Gets the class name of the current intput.
  93655. * @returns the class name
  93656. */
  93657. getClassName(): string;
  93658. /**
  93659. * Get the friendly name associated with the input class.
  93660. * @returns the input friendly name
  93661. */
  93662. getSimpleName(): string;
  93663. }
  93664. }
  93665. declare module BABYLON {
  93666. /**
  93667. * Manage the gamepad inputs to control a free camera.
  93668. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  93669. */
  93670. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  93671. /**
  93672. * Define the camera the input is attached to.
  93673. */
  93674. camera: FreeCamera;
  93675. /**
  93676. * Define the Gamepad controlling the input
  93677. */
  93678. gamepad: Nullable<Gamepad>;
  93679. /**
  93680. * Defines the gamepad rotation sensiblity.
  93681. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  93682. */
  93683. gamepadAngularSensibility: number;
  93684. /**
  93685. * Defines the gamepad move sensiblity.
  93686. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  93687. */
  93688. gamepadMoveSensibility: number;
  93689. private _onGamepadConnectedObserver;
  93690. private _onGamepadDisconnectedObserver;
  93691. private _cameraTransform;
  93692. private _deltaTransform;
  93693. private _vector3;
  93694. private _vector2;
  93695. /**
  93696. * Attach the input controls to a specific dom element to get the input from.
  93697. * @param element Defines the element the controls should be listened from
  93698. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  93699. */
  93700. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  93701. /**
  93702. * Detach the current controls from the specified dom element.
  93703. * @param element Defines the element to stop listening the inputs from
  93704. */
  93705. detachControl(element: Nullable<HTMLElement>): void;
  93706. /**
  93707. * Update the current camera state depending on the inputs that have been used this frame.
  93708. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  93709. */
  93710. checkInputs(): void;
  93711. /**
  93712. * Gets the class name of the current intput.
  93713. * @returns the class name
  93714. */
  93715. getClassName(): string;
  93716. /**
  93717. * Get the friendly name associated with the input class.
  93718. * @returns the input friendly name
  93719. */
  93720. getSimpleName(): string;
  93721. }
  93722. }
  93723. declare module BABYLON {
  93724. /**
  93725. * Defines the potential axis of a Joystick
  93726. */
  93727. export enum JoystickAxis {
  93728. /** X axis */
  93729. X = 0,
  93730. /** Y axis */
  93731. Y = 1,
  93732. /** Z axis */
  93733. Z = 2
  93734. }
  93735. /**
  93736. * Class used to define virtual joystick (used in touch mode)
  93737. */
  93738. export class VirtualJoystick {
  93739. /**
  93740. * Gets or sets a boolean indicating that left and right values must be inverted
  93741. */
  93742. reverseLeftRight: boolean;
  93743. /**
  93744. * Gets or sets a boolean indicating that up and down values must be inverted
  93745. */
  93746. reverseUpDown: boolean;
  93747. /**
  93748. * Gets the offset value for the position (ie. the change of the position value)
  93749. */
  93750. deltaPosition: Vector3;
  93751. /**
  93752. * Gets a boolean indicating if the virtual joystick was pressed
  93753. */
  93754. pressed: boolean;
  93755. /**
  93756. * Canvas the virtual joystick will render onto, default z-index of this is 5
  93757. */
  93758. static Canvas: Nullable<HTMLCanvasElement>;
  93759. private static _globalJoystickIndex;
  93760. private static vjCanvasContext;
  93761. private static vjCanvasWidth;
  93762. private static vjCanvasHeight;
  93763. private static halfWidth;
  93764. private _action;
  93765. private _axisTargetedByLeftAndRight;
  93766. private _axisTargetedByUpAndDown;
  93767. private _joystickSensibility;
  93768. private _inversedSensibility;
  93769. private _joystickPointerID;
  93770. private _joystickColor;
  93771. private _joystickPointerPos;
  93772. private _joystickPreviousPointerPos;
  93773. private _joystickPointerStartPos;
  93774. private _deltaJoystickVector;
  93775. private _leftJoystick;
  93776. private _touches;
  93777. private _onPointerDownHandlerRef;
  93778. private _onPointerMoveHandlerRef;
  93779. private _onPointerUpHandlerRef;
  93780. private _onResize;
  93781. /**
  93782. * Creates a new virtual joystick
  93783. * @param leftJoystick defines that the joystick is for left hand (false by default)
  93784. */
  93785. constructor(leftJoystick?: boolean);
  93786. /**
  93787. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  93788. * @param newJoystickSensibility defines the new sensibility
  93789. */
  93790. setJoystickSensibility(newJoystickSensibility: number): void;
  93791. private _onPointerDown;
  93792. private _onPointerMove;
  93793. private _onPointerUp;
  93794. /**
  93795. * Change the color of the virtual joystick
  93796. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  93797. */
  93798. setJoystickColor(newColor: string): void;
  93799. /**
  93800. * Defines a callback to call when the joystick is touched
  93801. * @param action defines the callback
  93802. */
  93803. setActionOnTouch(action: () => any): void;
  93804. /**
  93805. * Defines which axis you'd like to control for left & right
  93806. * @param axis defines the axis to use
  93807. */
  93808. setAxisForLeftRight(axis: JoystickAxis): void;
  93809. /**
  93810. * Defines which axis you'd like to control for up & down
  93811. * @param axis defines the axis to use
  93812. */
  93813. setAxisForUpDown(axis: JoystickAxis): void;
  93814. private _drawVirtualJoystick;
  93815. /**
  93816. * Release internal HTML canvas
  93817. */
  93818. releaseCanvas(): void;
  93819. }
  93820. }
  93821. declare module BABYLON {
  93822. interface FreeCameraInputsManager {
  93823. /**
  93824. * Add virtual joystick input support to the input manager.
  93825. * @returns the current input manager
  93826. */
  93827. addVirtualJoystick(): FreeCameraInputsManager;
  93828. }
  93829. /**
  93830. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  93831. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  93832. */
  93833. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  93834. /**
  93835. * Defines the camera the input is attached to.
  93836. */
  93837. camera: FreeCamera;
  93838. private _leftjoystick;
  93839. private _rightjoystick;
  93840. /**
  93841. * Gets the left stick of the virtual joystick.
  93842. * @returns The virtual Joystick
  93843. */
  93844. getLeftJoystick(): VirtualJoystick;
  93845. /**
  93846. * Gets the right stick of the virtual joystick.
  93847. * @returns The virtual Joystick
  93848. */
  93849. getRightJoystick(): VirtualJoystick;
  93850. /**
  93851. * Update the current camera state depending on the inputs that have been used this frame.
  93852. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  93853. */
  93854. checkInputs(): void;
  93855. /**
  93856. * Attach the input controls to a specific dom element to get the input from.
  93857. * @param element Defines the element the controls should be listened from
  93858. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  93859. */
  93860. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  93861. /**
  93862. * Detach the current controls from the specified dom element.
  93863. * @param element Defines the element to stop listening the inputs from
  93864. */
  93865. detachControl(element: Nullable<HTMLElement>): void;
  93866. /**
  93867. * Gets the class name of the current intput.
  93868. * @returns the class name
  93869. */
  93870. getClassName(): string;
  93871. /**
  93872. * Get the friendly name associated with the input class.
  93873. * @returns the input friendly name
  93874. */
  93875. getSimpleName(): string;
  93876. }
  93877. }
  93878. declare module BABYLON {
  93879. /**
  93880. * This represents a FPS type of camera controlled by touch.
  93881. * This is like a universal camera minus the Gamepad controls.
  93882. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  93883. */
  93884. export class TouchCamera extends FreeCamera {
  93885. /**
  93886. * Defines the touch sensibility for rotation.
  93887. * The higher the faster.
  93888. */
  93889. touchAngularSensibility: number;
  93890. /**
  93891. * Defines the touch sensibility for move.
  93892. * The higher the faster.
  93893. */
  93894. touchMoveSensibility: number;
  93895. /**
  93896. * Instantiates a new touch camera.
  93897. * This represents a FPS type of camera controlled by touch.
  93898. * This is like a universal camera minus the Gamepad controls.
  93899. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  93900. * @param name Define the name of the camera in the scene
  93901. * @param position Define the start position of the camera in the scene
  93902. * @param scene Define the scene the camera belongs to
  93903. */
  93904. constructor(name: string, position: Vector3, scene: Scene);
  93905. /**
  93906. * Gets the current object class name.
  93907. * @return the class name
  93908. */
  93909. getClassName(): string;
  93910. /** @hidden */
  93911. _setupInputs(): void;
  93912. }
  93913. }
  93914. declare module BABYLON {
  93915. /**
  93916. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  93917. * being tilted forward or back and left or right.
  93918. */
  93919. export class DeviceOrientationCamera extends FreeCamera {
  93920. private _initialQuaternion;
  93921. private _quaternionCache;
  93922. /**
  93923. * Creates a new device orientation camera
  93924. * @param name The name of the camera
  93925. * @param position The start position camera
  93926. * @param scene The scene the camera belongs to
  93927. */
  93928. constructor(name: string, position: Vector3, scene: Scene);
  93929. /**
  93930. * Gets the current instance class name ("DeviceOrientationCamera").
  93931. * This helps avoiding instanceof at run time.
  93932. * @returns the class name
  93933. */
  93934. getClassName(): string;
  93935. /**
  93936. * @hidden
  93937. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  93938. */
  93939. _checkInputs(): void;
  93940. /**
  93941. * Reset the camera to its default orientation on the specified axis only.
  93942. * @param axis The axis to reset
  93943. */
  93944. resetToCurrentRotation(axis?: Axis): void;
  93945. }
  93946. }
  93947. declare module BABYLON {
  93948. /**
  93949. * 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,
  93950. * which still works and will still be found in many Playgrounds.
  93951. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  93952. */
  93953. export class UniversalCamera extends TouchCamera {
  93954. /**
  93955. * Defines the gamepad rotation sensiblity.
  93956. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  93957. */
  93958. gamepadAngularSensibility: number;
  93959. /**
  93960. * Defines the gamepad move sensiblity.
  93961. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  93962. */
  93963. gamepadMoveSensibility: number;
  93964. /**
  93965. * 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,
  93966. * which still works and will still be found in many Playgrounds.
  93967. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  93968. * @param name Define the name of the camera in the scene
  93969. * @param position Define the start position of the camera in the scene
  93970. * @param scene Define the scene the camera belongs to
  93971. */
  93972. constructor(name: string, position: Vector3, scene: Scene);
  93973. /**
  93974. * Gets the current object class name.
  93975. * @return the class name
  93976. */
  93977. getClassName(): string;
  93978. }
  93979. }
  93980. declare module BABYLON {
  93981. /**
  93982. * This represents a FPS type of camera. This is only here for back compat purpose.
  93983. * Please use the UniversalCamera instead as both are identical.
  93984. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  93985. */
  93986. export class GamepadCamera extends UniversalCamera {
  93987. /**
  93988. * Instantiates a new Gamepad Camera
  93989. * This represents a FPS type of camera. This is only here for back compat purpose.
  93990. * Please use the UniversalCamera instead as both are identical.
  93991. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  93992. * @param name Define the name of the camera in the scene
  93993. * @param position Define the start position of the camera in the scene
  93994. * @param scene Define the scene the camera belongs to
  93995. */
  93996. constructor(name: string, position: Vector3, scene: Scene);
  93997. /**
  93998. * Gets the current object class name.
  93999. * @return the class name
  94000. */
  94001. getClassName(): string;
  94002. }
  94003. }
  94004. declare module BABYLON {
  94005. /** @hidden */
  94006. export var passPixelShader: {
  94007. name: string;
  94008. shader: string;
  94009. };
  94010. }
  94011. declare module BABYLON {
  94012. /** @hidden */
  94013. export var passCubePixelShader: {
  94014. name: string;
  94015. shader: string;
  94016. };
  94017. }
  94018. declare module BABYLON {
  94019. /**
  94020. * PassPostProcess which produces an output the same as it's input
  94021. */
  94022. export class PassPostProcess extends PostProcess {
  94023. /**
  94024. * Creates the PassPostProcess
  94025. * @param name The name of the effect.
  94026. * @param options The required width/height ratio to downsize to before computing the render pass.
  94027. * @param camera The camera to apply the render pass to.
  94028. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  94029. * @param engine The engine which the post process will be applied. (default: current engine)
  94030. * @param reusable If the post process can be reused on the same frame. (default: false)
  94031. * @param textureType The type of texture to be used when performing the post processing.
  94032. * @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)
  94033. */
  94034. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  94035. }
  94036. /**
  94037. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  94038. */
  94039. export class PassCubePostProcess extends PostProcess {
  94040. private _face;
  94041. /**
  94042. * Gets or sets the cube face to display.
  94043. * * 0 is +X
  94044. * * 1 is -X
  94045. * * 2 is +Y
  94046. * * 3 is -Y
  94047. * * 4 is +Z
  94048. * * 5 is -Z
  94049. */
  94050. face: number;
  94051. /**
  94052. * Creates the PassCubePostProcess
  94053. * @param name The name of the effect.
  94054. * @param options The required width/height ratio to downsize to before computing the render pass.
  94055. * @param camera The camera to apply the render pass to.
  94056. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  94057. * @param engine The engine which the post process will be applied. (default: current engine)
  94058. * @param reusable If the post process can be reused on the same frame. (default: false)
  94059. * @param textureType The type of texture to be used when performing the post processing.
  94060. * @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)
  94061. */
  94062. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  94063. }
  94064. }
  94065. declare module BABYLON {
  94066. /** @hidden */
  94067. export var anaglyphPixelShader: {
  94068. name: string;
  94069. shader: string;
  94070. };
  94071. }
  94072. declare module BABYLON {
  94073. /**
  94074. * Postprocess used to generate anaglyphic rendering
  94075. */
  94076. export class AnaglyphPostProcess extends PostProcess {
  94077. private _passedProcess;
  94078. /**
  94079. * Creates a new AnaglyphPostProcess
  94080. * @param name defines postprocess name
  94081. * @param options defines creation options or target ratio scale
  94082. * @param rigCameras defines cameras using this postprocess
  94083. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  94084. * @param engine defines hosting engine
  94085. * @param reusable defines if the postprocess will be reused multiple times per frame
  94086. */
  94087. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  94088. }
  94089. }
  94090. declare module BABYLON {
  94091. /**
  94092. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  94093. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  94094. */
  94095. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  94096. /**
  94097. * Creates a new AnaglyphArcRotateCamera
  94098. * @param name defines camera name
  94099. * @param alpha defines alpha angle (in radians)
  94100. * @param beta defines beta angle (in radians)
  94101. * @param radius defines radius
  94102. * @param target defines camera target
  94103. * @param interaxialDistance defines distance between each color axis
  94104. * @param scene defines the hosting scene
  94105. */
  94106. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  94107. /**
  94108. * Gets camera class name
  94109. * @returns AnaglyphArcRotateCamera
  94110. */
  94111. getClassName(): string;
  94112. }
  94113. }
  94114. declare module BABYLON {
  94115. /**
  94116. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  94117. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  94118. */
  94119. export class AnaglyphFreeCamera extends FreeCamera {
  94120. /**
  94121. * Creates a new AnaglyphFreeCamera
  94122. * @param name defines camera name
  94123. * @param position defines initial position
  94124. * @param interaxialDistance defines distance between each color axis
  94125. * @param scene defines the hosting scene
  94126. */
  94127. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  94128. /**
  94129. * Gets camera class name
  94130. * @returns AnaglyphFreeCamera
  94131. */
  94132. getClassName(): string;
  94133. }
  94134. }
  94135. declare module BABYLON {
  94136. /**
  94137. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  94138. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  94139. */
  94140. export class AnaglyphGamepadCamera extends GamepadCamera {
  94141. /**
  94142. * Creates a new AnaglyphGamepadCamera
  94143. * @param name defines camera name
  94144. * @param position defines initial position
  94145. * @param interaxialDistance defines distance between each color axis
  94146. * @param scene defines the hosting scene
  94147. */
  94148. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  94149. /**
  94150. * Gets camera class name
  94151. * @returns AnaglyphGamepadCamera
  94152. */
  94153. getClassName(): string;
  94154. }
  94155. }
  94156. declare module BABYLON {
  94157. /**
  94158. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  94159. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  94160. */
  94161. export class AnaglyphUniversalCamera extends UniversalCamera {
  94162. /**
  94163. * Creates a new AnaglyphUniversalCamera
  94164. * @param name defines camera name
  94165. * @param position defines initial position
  94166. * @param interaxialDistance defines distance between each color axis
  94167. * @param scene defines the hosting scene
  94168. */
  94169. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  94170. /**
  94171. * Gets camera class name
  94172. * @returns AnaglyphUniversalCamera
  94173. */
  94174. getClassName(): string;
  94175. }
  94176. }
  94177. declare module BABYLON {
  94178. /** @hidden */
  94179. export var stereoscopicInterlacePixelShader: {
  94180. name: string;
  94181. shader: string;
  94182. };
  94183. }
  94184. declare module BABYLON {
  94185. /**
  94186. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  94187. */
  94188. export class StereoscopicInterlacePostProcess extends PostProcess {
  94189. private _stepSize;
  94190. private _passedProcess;
  94191. /**
  94192. * Initializes a StereoscopicInterlacePostProcess
  94193. * @param name The name of the effect.
  94194. * @param rigCameras The rig cameras to be appled to the post process
  94195. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  94196. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  94197. * @param engine The engine which the post process will be applied. (default: current engine)
  94198. * @param reusable If the post process can be reused on the same frame. (default: false)
  94199. */
  94200. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  94201. }
  94202. }
  94203. declare module BABYLON {
  94204. /**
  94205. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  94206. * @see http://doc.babylonjs.com/features/cameras
  94207. */
  94208. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  94209. /**
  94210. * Creates a new StereoscopicArcRotateCamera
  94211. * @param name defines camera name
  94212. * @param alpha defines alpha angle (in radians)
  94213. * @param beta defines beta angle (in radians)
  94214. * @param radius defines radius
  94215. * @param target defines camera target
  94216. * @param interaxialDistance defines distance between each color axis
  94217. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  94218. * @param scene defines the hosting scene
  94219. */
  94220. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  94221. /**
  94222. * Gets camera class name
  94223. * @returns StereoscopicArcRotateCamera
  94224. */
  94225. getClassName(): string;
  94226. }
  94227. }
  94228. declare module BABYLON {
  94229. /**
  94230. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  94231. * @see http://doc.babylonjs.com/features/cameras
  94232. */
  94233. export class StereoscopicFreeCamera extends FreeCamera {
  94234. /**
  94235. * Creates a new StereoscopicFreeCamera
  94236. * @param name defines camera name
  94237. * @param position defines initial position
  94238. * @param interaxialDistance defines distance between each color axis
  94239. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  94240. * @param scene defines the hosting scene
  94241. */
  94242. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  94243. /**
  94244. * Gets camera class name
  94245. * @returns StereoscopicFreeCamera
  94246. */
  94247. getClassName(): string;
  94248. }
  94249. }
  94250. declare module BABYLON {
  94251. /**
  94252. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  94253. * @see http://doc.babylonjs.com/features/cameras
  94254. */
  94255. export class StereoscopicGamepadCamera extends GamepadCamera {
  94256. /**
  94257. * Creates a new StereoscopicGamepadCamera
  94258. * @param name defines camera name
  94259. * @param position defines initial position
  94260. * @param interaxialDistance defines distance between each color axis
  94261. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  94262. * @param scene defines the hosting scene
  94263. */
  94264. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  94265. /**
  94266. * Gets camera class name
  94267. * @returns StereoscopicGamepadCamera
  94268. */
  94269. getClassName(): string;
  94270. }
  94271. }
  94272. declare module BABYLON {
  94273. /**
  94274. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  94275. * @see http://doc.babylonjs.com/features/cameras
  94276. */
  94277. export class StereoscopicUniversalCamera extends UniversalCamera {
  94278. /**
  94279. * Creates a new StereoscopicUniversalCamera
  94280. * @param name defines camera name
  94281. * @param position defines initial position
  94282. * @param interaxialDistance defines distance between each color axis
  94283. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  94284. * @param scene defines the hosting scene
  94285. */
  94286. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  94287. /**
  94288. * Gets camera class name
  94289. * @returns StereoscopicUniversalCamera
  94290. */
  94291. getClassName(): string;
  94292. }
  94293. }
  94294. declare module BABYLON {
  94295. /**
  94296. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  94297. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  94298. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  94299. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  94300. */
  94301. export class VirtualJoysticksCamera extends FreeCamera {
  94302. /**
  94303. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  94304. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  94305. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  94306. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  94307. * @param name Define the name of the camera in the scene
  94308. * @param position Define the start position of the camera in the scene
  94309. * @param scene Define the scene the camera belongs to
  94310. */
  94311. constructor(name: string, position: Vector3, scene: Scene);
  94312. /**
  94313. * Gets the current object class name.
  94314. * @return the class name
  94315. */
  94316. getClassName(): string;
  94317. }
  94318. }
  94319. declare module BABYLON {
  94320. /**
  94321. * This represents all the required metrics to create a VR camera.
  94322. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  94323. */
  94324. export class VRCameraMetrics {
  94325. /**
  94326. * Define the horizontal resolution off the screen.
  94327. */
  94328. hResolution: number;
  94329. /**
  94330. * Define the vertical resolution off the screen.
  94331. */
  94332. vResolution: number;
  94333. /**
  94334. * Define the horizontal screen size.
  94335. */
  94336. hScreenSize: number;
  94337. /**
  94338. * Define the vertical screen size.
  94339. */
  94340. vScreenSize: number;
  94341. /**
  94342. * Define the vertical screen center position.
  94343. */
  94344. vScreenCenter: number;
  94345. /**
  94346. * Define the distance of the eyes to the screen.
  94347. */
  94348. eyeToScreenDistance: number;
  94349. /**
  94350. * Define the distance between both lenses
  94351. */
  94352. lensSeparationDistance: number;
  94353. /**
  94354. * Define the distance between both viewer's eyes.
  94355. */
  94356. interpupillaryDistance: number;
  94357. /**
  94358. * Define the distortion factor of the VR postprocess.
  94359. * Please, touch with care.
  94360. */
  94361. distortionK: number[];
  94362. /**
  94363. * Define the chromatic aberration correction factors for the VR post process.
  94364. */
  94365. chromaAbCorrection: number[];
  94366. /**
  94367. * Define the scale factor of the post process.
  94368. * The smaller the better but the slower.
  94369. */
  94370. postProcessScaleFactor: number;
  94371. /**
  94372. * Define an offset for the lens center.
  94373. */
  94374. lensCenterOffset: number;
  94375. /**
  94376. * Define if the current vr camera should compensate the distortion of the lense or not.
  94377. */
  94378. compensateDistortion: boolean;
  94379. /**
  94380. * Gets the rendering aspect ratio based on the provided resolutions.
  94381. */
  94382. readonly aspectRatio: number;
  94383. /**
  94384. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  94385. */
  94386. readonly aspectRatioFov: number;
  94387. /**
  94388. * @hidden
  94389. */
  94390. readonly leftHMatrix: Matrix;
  94391. /**
  94392. * @hidden
  94393. */
  94394. readonly rightHMatrix: Matrix;
  94395. /**
  94396. * @hidden
  94397. */
  94398. readonly leftPreViewMatrix: Matrix;
  94399. /**
  94400. * @hidden
  94401. */
  94402. readonly rightPreViewMatrix: Matrix;
  94403. /**
  94404. * Get the default VRMetrics based on the most generic setup.
  94405. * @returns the default vr metrics
  94406. */
  94407. static GetDefault(): VRCameraMetrics;
  94408. }
  94409. }
  94410. declare module BABYLON {
  94411. /** @hidden */
  94412. export var vrDistortionCorrectionPixelShader: {
  94413. name: string;
  94414. shader: string;
  94415. };
  94416. }
  94417. declare module BABYLON {
  94418. /**
  94419. * VRDistortionCorrectionPostProcess used for mobile VR
  94420. */
  94421. export class VRDistortionCorrectionPostProcess extends PostProcess {
  94422. private _isRightEye;
  94423. private _distortionFactors;
  94424. private _postProcessScaleFactor;
  94425. private _lensCenterOffset;
  94426. private _scaleIn;
  94427. private _scaleFactor;
  94428. private _lensCenter;
  94429. /**
  94430. * Initializes the VRDistortionCorrectionPostProcess
  94431. * @param name The name of the effect.
  94432. * @param camera The camera to apply the render pass to.
  94433. * @param isRightEye If this is for the right eye distortion
  94434. * @param vrMetrics All the required metrics for the VR camera
  94435. */
  94436. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  94437. }
  94438. }
  94439. declare module BABYLON {
  94440. /**
  94441. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  94442. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  94443. */
  94444. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  94445. /**
  94446. * Creates a new VRDeviceOrientationArcRotateCamera
  94447. * @param name defines camera name
  94448. * @param alpha defines the camera rotation along the logitudinal axis
  94449. * @param beta defines the camera rotation along the latitudinal axis
  94450. * @param radius defines the camera distance from its target
  94451. * @param target defines the camera target
  94452. * @param scene defines the scene the camera belongs to
  94453. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  94454. * @param vrCameraMetrics defines the vr metrics associated to the camera
  94455. */
  94456. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  94457. /**
  94458. * Gets camera class name
  94459. * @returns VRDeviceOrientationArcRotateCamera
  94460. */
  94461. getClassName(): string;
  94462. }
  94463. }
  94464. declare module BABYLON {
  94465. /**
  94466. * Camera used to simulate VR rendering (based on FreeCamera)
  94467. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  94468. */
  94469. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  94470. /**
  94471. * Creates a new VRDeviceOrientationFreeCamera
  94472. * @param name defines camera name
  94473. * @param position defines the start position of the camera
  94474. * @param scene defines the scene the camera belongs to
  94475. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  94476. * @param vrCameraMetrics defines the vr metrics associated to the camera
  94477. */
  94478. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  94479. /**
  94480. * Gets camera class name
  94481. * @returns VRDeviceOrientationFreeCamera
  94482. */
  94483. getClassName(): string;
  94484. }
  94485. }
  94486. declare module BABYLON {
  94487. /**
  94488. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  94489. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  94490. */
  94491. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  94492. /**
  94493. * Creates a new VRDeviceOrientationGamepadCamera
  94494. * @param name defines camera name
  94495. * @param position defines the start position of the camera
  94496. * @param scene defines the scene the camera belongs to
  94497. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  94498. * @param vrCameraMetrics defines the vr metrics associated to the camera
  94499. */
  94500. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  94501. /**
  94502. * Gets camera class name
  94503. * @returns VRDeviceOrientationGamepadCamera
  94504. */
  94505. getClassName(): string;
  94506. }
  94507. }
  94508. declare module BABYLON {
  94509. /**
  94510. * Defines supported buttons for XBox360 compatible gamepads
  94511. */
  94512. export enum Xbox360Button {
  94513. /** A */
  94514. A = 0,
  94515. /** B */
  94516. B = 1,
  94517. /** X */
  94518. X = 2,
  94519. /** Y */
  94520. Y = 3,
  94521. /** Start */
  94522. Start = 4,
  94523. /** Back */
  94524. Back = 5,
  94525. /** Left button */
  94526. LB = 6,
  94527. /** Right button */
  94528. RB = 7,
  94529. /** Left stick */
  94530. LeftStick = 8,
  94531. /** Right stick */
  94532. RightStick = 9
  94533. }
  94534. /** Defines values for XBox360 DPad */
  94535. export enum Xbox360Dpad {
  94536. /** Up */
  94537. Up = 0,
  94538. /** Down */
  94539. Down = 1,
  94540. /** Left */
  94541. Left = 2,
  94542. /** Right */
  94543. Right = 3
  94544. }
  94545. /**
  94546. * Defines a XBox360 gamepad
  94547. */
  94548. export class Xbox360Pad extends Gamepad {
  94549. private _leftTrigger;
  94550. private _rightTrigger;
  94551. private _onlefttriggerchanged;
  94552. private _onrighttriggerchanged;
  94553. private _onbuttondown;
  94554. private _onbuttonup;
  94555. private _ondpaddown;
  94556. private _ondpadup;
  94557. /** Observable raised when a button is pressed */
  94558. onButtonDownObservable: Observable<Xbox360Button>;
  94559. /** Observable raised when a button is released */
  94560. onButtonUpObservable: Observable<Xbox360Button>;
  94561. /** Observable raised when a pad is pressed */
  94562. onPadDownObservable: Observable<Xbox360Dpad>;
  94563. /** Observable raised when a pad is released */
  94564. onPadUpObservable: Observable<Xbox360Dpad>;
  94565. private _buttonA;
  94566. private _buttonB;
  94567. private _buttonX;
  94568. private _buttonY;
  94569. private _buttonBack;
  94570. private _buttonStart;
  94571. private _buttonLB;
  94572. private _buttonRB;
  94573. private _buttonLeftStick;
  94574. private _buttonRightStick;
  94575. private _dPadUp;
  94576. private _dPadDown;
  94577. private _dPadLeft;
  94578. private _dPadRight;
  94579. private _isXboxOnePad;
  94580. /**
  94581. * Creates a new XBox360 gamepad object
  94582. * @param id defines the id of this gamepad
  94583. * @param index defines its index
  94584. * @param gamepad defines the internal HTML gamepad object
  94585. * @param xboxOne defines if it is a XBox One gamepad
  94586. */
  94587. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  94588. /**
  94589. * Defines the callback to call when left trigger is pressed
  94590. * @param callback defines the callback to use
  94591. */
  94592. onlefttriggerchanged(callback: (value: number) => void): void;
  94593. /**
  94594. * Defines the callback to call when right trigger is pressed
  94595. * @param callback defines the callback to use
  94596. */
  94597. onrighttriggerchanged(callback: (value: number) => void): void;
  94598. /**
  94599. * Gets the left trigger value
  94600. */
  94601. /**
  94602. * Sets the left trigger value
  94603. */
  94604. leftTrigger: number;
  94605. /**
  94606. * Gets the right trigger value
  94607. */
  94608. /**
  94609. * Sets the right trigger value
  94610. */
  94611. rightTrigger: number;
  94612. /**
  94613. * Defines the callback to call when a button is pressed
  94614. * @param callback defines the callback to use
  94615. */
  94616. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  94617. /**
  94618. * Defines the callback to call when a button is released
  94619. * @param callback defines the callback to use
  94620. */
  94621. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  94622. /**
  94623. * Defines the callback to call when a pad is pressed
  94624. * @param callback defines the callback to use
  94625. */
  94626. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  94627. /**
  94628. * Defines the callback to call when a pad is released
  94629. * @param callback defines the callback to use
  94630. */
  94631. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  94632. private _setButtonValue;
  94633. private _setDPadValue;
  94634. /**
  94635. * Gets the value of the `A` button
  94636. */
  94637. /**
  94638. * Sets the value of the `A` button
  94639. */
  94640. buttonA: number;
  94641. /**
  94642. * Gets the value of the `B` button
  94643. */
  94644. /**
  94645. * Sets the value of the `B` button
  94646. */
  94647. buttonB: number;
  94648. /**
  94649. * Gets the value of the `X` button
  94650. */
  94651. /**
  94652. * Sets the value of the `X` button
  94653. */
  94654. buttonX: number;
  94655. /**
  94656. * Gets the value of the `Y` button
  94657. */
  94658. /**
  94659. * Sets the value of the `Y` button
  94660. */
  94661. buttonY: number;
  94662. /**
  94663. * Gets the value of the `Start` button
  94664. */
  94665. /**
  94666. * Sets the value of the `Start` button
  94667. */
  94668. buttonStart: number;
  94669. /**
  94670. * Gets the value of the `Back` button
  94671. */
  94672. /**
  94673. * Sets the value of the `Back` button
  94674. */
  94675. buttonBack: number;
  94676. /**
  94677. * Gets the value of the `Left` button
  94678. */
  94679. /**
  94680. * Sets the value of the `Left` button
  94681. */
  94682. buttonLB: number;
  94683. /**
  94684. * Gets the value of the `Right` button
  94685. */
  94686. /**
  94687. * Sets the value of the `Right` button
  94688. */
  94689. buttonRB: number;
  94690. /**
  94691. * Gets the value of the Left joystick
  94692. */
  94693. /**
  94694. * Sets the value of the Left joystick
  94695. */
  94696. buttonLeftStick: number;
  94697. /**
  94698. * Gets the value of the Right joystick
  94699. */
  94700. /**
  94701. * Sets the value of the Right joystick
  94702. */
  94703. buttonRightStick: number;
  94704. /**
  94705. * Gets the value of D-pad up
  94706. */
  94707. /**
  94708. * Sets the value of D-pad up
  94709. */
  94710. dPadUp: number;
  94711. /**
  94712. * Gets the value of D-pad down
  94713. */
  94714. /**
  94715. * Sets the value of D-pad down
  94716. */
  94717. dPadDown: number;
  94718. /**
  94719. * Gets the value of D-pad left
  94720. */
  94721. /**
  94722. * Sets the value of D-pad left
  94723. */
  94724. dPadLeft: number;
  94725. /**
  94726. * Gets the value of D-pad right
  94727. */
  94728. /**
  94729. * Sets the value of D-pad right
  94730. */
  94731. dPadRight: number;
  94732. /**
  94733. * Force the gamepad to synchronize with device values
  94734. */
  94735. update(): void;
  94736. /**
  94737. * Disposes the gamepad
  94738. */
  94739. dispose(): void;
  94740. }
  94741. }
  94742. declare module BABYLON {
  94743. /**
  94744. * Base class of materials working in push mode in babylon JS
  94745. * @hidden
  94746. */
  94747. export class PushMaterial extends Material {
  94748. protected _activeEffect: Effect;
  94749. protected _normalMatrix: Matrix;
  94750. /**
  94751. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  94752. * This means that the material can keep using a previous shader while a new one is being compiled.
  94753. * This is mostly used when shader parallel compilation is supported (true by default)
  94754. */
  94755. allowShaderHotSwapping: boolean;
  94756. constructor(name: string, scene: Scene);
  94757. getEffect(): Effect;
  94758. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  94759. /**
  94760. * Binds the given world matrix to the active effect
  94761. *
  94762. * @param world the matrix to bind
  94763. */
  94764. bindOnlyWorldMatrix(world: Matrix): void;
  94765. /**
  94766. * Binds the given normal matrix to the active effect
  94767. *
  94768. * @param normalMatrix the matrix to bind
  94769. */
  94770. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  94771. bind(world: Matrix, mesh?: Mesh): void;
  94772. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  94773. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  94774. }
  94775. }
  94776. declare module BABYLON {
  94777. /**
  94778. * This groups all the flags used to control the materials channel.
  94779. */
  94780. export class MaterialFlags {
  94781. private static _DiffuseTextureEnabled;
  94782. /**
  94783. * Are diffuse textures enabled in the application.
  94784. */
  94785. static DiffuseTextureEnabled: boolean;
  94786. private static _AmbientTextureEnabled;
  94787. /**
  94788. * Are ambient textures enabled in the application.
  94789. */
  94790. static AmbientTextureEnabled: boolean;
  94791. private static _OpacityTextureEnabled;
  94792. /**
  94793. * Are opacity textures enabled in the application.
  94794. */
  94795. static OpacityTextureEnabled: boolean;
  94796. private static _ReflectionTextureEnabled;
  94797. /**
  94798. * Are reflection textures enabled in the application.
  94799. */
  94800. static ReflectionTextureEnabled: boolean;
  94801. private static _EmissiveTextureEnabled;
  94802. /**
  94803. * Are emissive textures enabled in the application.
  94804. */
  94805. static EmissiveTextureEnabled: boolean;
  94806. private static _SpecularTextureEnabled;
  94807. /**
  94808. * Are specular textures enabled in the application.
  94809. */
  94810. static SpecularTextureEnabled: boolean;
  94811. private static _BumpTextureEnabled;
  94812. /**
  94813. * Are bump textures enabled in the application.
  94814. */
  94815. static BumpTextureEnabled: boolean;
  94816. private static _LightmapTextureEnabled;
  94817. /**
  94818. * Are lightmap textures enabled in the application.
  94819. */
  94820. static LightmapTextureEnabled: boolean;
  94821. private static _RefractionTextureEnabled;
  94822. /**
  94823. * Are refraction textures enabled in the application.
  94824. */
  94825. static RefractionTextureEnabled: boolean;
  94826. private static _ColorGradingTextureEnabled;
  94827. /**
  94828. * Are color grading textures enabled in the application.
  94829. */
  94830. static ColorGradingTextureEnabled: boolean;
  94831. private static _FresnelEnabled;
  94832. /**
  94833. * Are fresnels enabled in the application.
  94834. */
  94835. static FresnelEnabled: boolean;
  94836. private static _ClearCoatTextureEnabled;
  94837. /**
  94838. * Are clear coat textures enabled in the application.
  94839. */
  94840. static ClearCoatTextureEnabled: boolean;
  94841. private static _ClearCoatBumpTextureEnabled;
  94842. /**
  94843. * Are clear coat bump textures enabled in the application.
  94844. */
  94845. static ClearCoatBumpTextureEnabled: boolean;
  94846. private static _ClearCoatTintTextureEnabled;
  94847. /**
  94848. * Are clear coat tint textures enabled in the application.
  94849. */
  94850. static ClearCoatTintTextureEnabled: boolean;
  94851. }
  94852. }
  94853. declare module BABYLON {
  94854. /** @hidden */
  94855. export var defaultFragmentDeclaration: {
  94856. name: string;
  94857. shader: string;
  94858. };
  94859. }
  94860. declare module BABYLON {
  94861. /** @hidden */
  94862. export var defaultUboDeclaration: {
  94863. name: string;
  94864. shader: string;
  94865. };
  94866. }
  94867. declare module BABYLON {
  94868. /** @hidden */
  94869. export var lightFragmentDeclaration: {
  94870. name: string;
  94871. shader: string;
  94872. };
  94873. }
  94874. declare module BABYLON {
  94875. /** @hidden */
  94876. export var lightUboDeclaration: {
  94877. name: string;
  94878. shader: string;
  94879. };
  94880. }
  94881. declare module BABYLON {
  94882. /** @hidden */
  94883. export var lightsFragmentFunctions: {
  94884. name: string;
  94885. shader: string;
  94886. };
  94887. }
  94888. declare module BABYLON {
  94889. /** @hidden */
  94890. export var shadowsFragmentFunctions: {
  94891. name: string;
  94892. shader: string;
  94893. };
  94894. }
  94895. declare module BABYLON {
  94896. /** @hidden */
  94897. export var fresnelFunction: {
  94898. name: string;
  94899. shader: string;
  94900. };
  94901. }
  94902. declare module BABYLON {
  94903. /** @hidden */
  94904. export var reflectionFunction: {
  94905. name: string;
  94906. shader: string;
  94907. };
  94908. }
  94909. declare module BABYLON {
  94910. /** @hidden */
  94911. export var bumpFragmentFunctions: {
  94912. name: string;
  94913. shader: string;
  94914. };
  94915. }
  94916. declare module BABYLON {
  94917. /** @hidden */
  94918. export var logDepthDeclaration: {
  94919. name: string;
  94920. shader: string;
  94921. };
  94922. }
  94923. declare module BABYLON {
  94924. /** @hidden */
  94925. export var bumpFragment: {
  94926. name: string;
  94927. shader: string;
  94928. };
  94929. }
  94930. declare module BABYLON {
  94931. /** @hidden */
  94932. export var depthPrePass: {
  94933. name: string;
  94934. shader: string;
  94935. };
  94936. }
  94937. declare module BABYLON {
  94938. /** @hidden */
  94939. export var lightFragment: {
  94940. name: string;
  94941. shader: string;
  94942. };
  94943. }
  94944. declare module BABYLON {
  94945. /** @hidden */
  94946. export var logDepthFragment: {
  94947. name: string;
  94948. shader: string;
  94949. };
  94950. }
  94951. declare module BABYLON {
  94952. /** @hidden */
  94953. export var defaultPixelShader: {
  94954. name: string;
  94955. shader: string;
  94956. };
  94957. }
  94958. declare module BABYLON {
  94959. /** @hidden */
  94960. export var defaultVertexDeclaration: {
  94961. name: string;
  94962. shader: string;
  94963. };
  94964. }
  94965. declare module BABYLON {
  94966. /** @hidden */
  94967. export var bumpVertexDeclaration: {
  94968. name: string;
  94969. shader: string;
  94970. };
  94971. }
  94972. declare module BABYLON {
  94973. /** @hidden */
  94974. export var bumpVertex: {
  94975. name: string;
  94976. shader: string;
  94977. };
  94978. }
  94979. declare module BABYLON {
  94980. /** @hidden */
  94981. export var fogVertex: {
  94982. name: string;
  94983. shader: string;
  94984. };
  94985. }
  94986. declare module BABYLON {
  94987. /** @hidden */
  94988. export var shadowsVertex: {
  94989. name: string;
  94990. shader: string;
  94991. };
  94992. }
  94993. declare module BABYLON {
  94994. /** @hidden */
  94995. export var pointCloudVertex: {
  94996. name: string;
  94997. shader: string;
  94998. };
  94999. }
  95000. declare module BABYLON {
  95001. /** @hidden */
  95002. export var logDepthVertex: {
  95003. name: string;
  95004. shader: string;
  95005. };
  95006. }
  95007. declare module BABYLON {
  95008. /** @hidden */
  95009. export var defaultVertexShader: {
  95010. name: string;
  95011. shader: string;
  95012. };
  95013. }
  95014. declare module BABYLON {
  95015. /** @hidden */
  95016. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  95017. MAINUV1: boolean;
  95018. MAINUV2: boolean;
  95019. DIFFUSE: boolean;
  95020. DIFFUSEDIRECTUV: number;
  95021. AMBIENT: boolean;
  95022. AMBIENTDIRECTUV: number;
  95023. OPACITY: boolean;
  95024. OPACITYDIRECTUV: number;
  95025. OPACITYRGB: boolean;
  95026. REFLECTION: boolean;
  95027. EMISSIVE: boolean;
  95028. EMISSIVEDIRECTUV: number;
  95029. SPECULAR: boolean;
  95030. SPECULARDIRECTUV: number;
  95031. BUMP: boolean;
  95032. BUMPDIRECTUV: number;
  95033. PARALLAX: boolean;
  95034. PARALLAXOCCLUSION: boolean;
  95035. SPECULAROVERALPHA: boolean;
  95036. CLIPPLANE: boolean;
  95037. CLIPPLANE2: boolean;
  95038. CLIPPLANE3: boolean;
  95039. CLIPPLANE4: boolean;
  95040. ALPHATEST: boolean;
  95041. DEPTHPREPASS: boolean;
  95042. ALPHAFROMDIFFUSE: boolean;
  95043. POINTSIZE: boolean;
  95044. FOG: boolean;
  95045. SPECULARTERM: boolean;
  95046. DIFFUSEFRESNEL: boolean;
  95047. OPACITYFRESNEL: boolean;
  95048. REFLECTIONFRESNEL: boolean;
  95049. REFRACTIONFRESNEL: boolean;
  95050. EMISSIVEFRESNEL: boolean;
  95051. FRESNEL: boolean;
  95052. NORMAL: boolean;
  95053. UV1: boolean;
  95054. UV2: boolean;
  95055. VERTEXCOLOR: boolean;
  95056. VERTEXALPHA: boolean;
  95057. NUM_BONE_INFLUENCERS: number;
  95058. BonesPerMesh: number;
  95059. BONETEXTURE: boolean;
  95060. INSTANCES: boolean;
  95061. GLOSSINESS: boolean;
  95062. ROUGHNESS: boolean;
  95063. EMISSIVEASILLUMINATION: boolean;
  95064. LINKEMISSIVEWITHDIFFUSE: boolean;
  95065. REFLECTIONFRESNELFROMSPECULAR: boolean;
  95066. LIGHTMAP: boolean;
  95067. LIGHTMAPDIRECTUV: number;
  95068. OBJECTSPACE_NORMALMAP: boolean;
  95069. USELIGHTMAPASSHADOWMAP: boolean;
  95070. REFLECTIONMAP_3D: boolean;
  95071. REFLECTIONMAP_SPHERICAL: boolean;
  95072. REFLECTIONMAP_PLANAR: boolean;
  95073. REFLECTIONMAP_CUBIC: boolean;
  95074. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  95075. REFLECTIONMAP_PROJECTION: boolean;
  95076. REFLECTIONMAP_SKYBOX: boolean;
  95077. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  95078. REFLECTIONMAP_EXPLICIT: boolean;
  95079. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  95080. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  95081. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  95082. INVERTCUBICMAP: boolean;
  95083. LOGARITHMICDEPTH: boolean;
  95084. REFRACTION: boolean;
  95085. REFRACTIONMAP_3D: boolean;
  95086. REFLECTIONOVERALPHA: boolean;
  95087. TWOSIDEDLIGHTING: boolean;
  95088. SHADOWFLOAT: boolean;
  95089. MORPHTARGETS: boolean;
  95090. MORPHTARGETS_NORMAL: boolean;
  95091. MORPHTARGETS_TANGENT: boolean;
  95092. NUM_MORPH_INFLUENCERS: number;
  95093. NONUNIFORMSCALING: boolean;
  95094. PREMULTIPLYALPHA: boolean;
  95095. IMAGEPROCESSING: boolean;
  95096. VIGNETTE: boolean;
  95097. VIGNETTEBLENDMODEMULTIPLY: boolean;
  95098. VIGNETTEBLENDMODEOPAQUE: boolean;
  95099. TONEMAPPING: boolean;
  95100. TONEMAPPING_ACES: boolean;
  95101. CONTRAST: boolean;
  95102. COLORCURVES: boolean;
  95103. COLORGRADING: boolean;
  95104. COLORGRADING3D: boolean;
  95105. SAMPLER3DGREENDEPTH: boolean;
  95106. SAMPLER3DBGRMAP: boolean;
  95107. IMAGEPROCESSINGPOSTPROCESS: boolean;
  95108. /**
  95109. * If the reflection texture on this material is in linear color space
  95110. * @hidden
  95111. */
  95112. IS_REFLECTION_LINEAR: boolean;
  95113. /**
  95114. * If the refraction texture on this material is in linear color space
  95115. * @hidden
  95116. */
  95117. IS_REFRACTION_LINEAR: boolean;
  95118. EXPOSURE: boolean;
  95119. constructor();
  95120. setReflectionMode(modeToEnable: string): void;
  95121. }
  95122. /**
  95123. * This is the default material used in Babylon. It is the best trade off between quality
  95124. * and performances.
  95125. * @see http://doc.babylonjs.com/babylon101/materials
  95126. */
  95127. export class StandardMaterial extends PushMaterial {
  95128. private _diffuseTexture;
  95129. /**
  95130. * The basic texture of the material as viewed under a light.
  95131. */
  95132. diffuseTexture: Nullable<BaseTexture>;
  95133. private _ambientTexture;
  95134. /**
  95135. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  95136. */
  95137. ambientTexture: Nullable<BaseTexture>;
  95138. private _opacityTexture;
  95139. /**
  95140. * Define the transparency of the material from a texture.
  95141. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  95142. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  95143. */
  95144. opacityTexture: Nullable<BaseTexture>;
  95145. private _reflectionTexture;
  95146. /**
  95147. * Define the texture used to display the reflection.
  95148. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  95149. */
  95150. reflectionTexture: Nullable<BaseTexture>;
  95151. private _emissiveTexture;
  95152. /**
  95153. * Define texture of the material as if self lit.
  95154. * This will be mixed in the final result even in the absence of light.
  95155. */
  95156. emissiveTexture: Nullable<BaseTexture>;
  95157. private _specularTexture;
  95158. /**
  95159. * Define how the color and intensity of the highlight given by the light in the material.
  95160. */
  95161. specularTexture: Nullable<BaseTexture>;
  95162. private _bumpTexture;
  95163. /**
  95164. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  95165. * 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.
  95166. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  95167. */
  95168. bumpTexture: Nullable<BaseTexture>;
  95169. private _lightmapTexture;
  95170. /**
  95171. * Complex lighting can be computationally expensive to compute at runtime.
  95172. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  95173. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  95174. */
  95175. lightmapTexture: Nullable<BaseTexture>;
  95176. private _refractionTexture;
  95177. /**
  95178. * Define the texture used to display the refraction.
  95179. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  95180. */
  95181. refractionTexture: Nullable<BaseTexture>;
  95182. /**
  95183. * The color of the material lit by the environmental background lighting.
  95184. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  95185. */
  95186. ambientColor: Color3;
  95187. /**
  95188. * The basic color of the material as viewed under a light.
  95189. */
  95190. diffuseColor: Color3;
  95191. /**
  95192. * Define how the color and intensity of the highlight given by the light in the material.
  95193. */
  95194. specularColor: Color3;
  95195. /**
  95196. * Define the color of the material as if self lit.
  95197. * This will be mixed in the final result even in the absence of light.
  95198. */
  95199. emissiveColor: Color3;
  95200. /**
  95201. * Defines how sharp are the highlights in the material.
  95202. * The bigger the value the sharper giving a more glossy feeling to the result.
  95203. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  95204. */
  95205. specularPower: number;
  95206. private _useAlphaFromDiffuseTexture;
  95207. /**
  95208. * Does the transparency come from the diffuse texture alpha channel.
  95209. */
  95210. useAlphaFromDiffuseTexture: boolean;
  95211. private _useEmissiveAsIllumination;
  95212. /**
  95213. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  95214. */
  95215. useEmissiveAsIllumination: boolean;
  95216. private _linkEmissiveWithDiffuse;
  95217. /**
  95218. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  95219. * the emissive level when the final color is close to one.
  95220. */
  95221. linkEmissiveWithDiffuse: boolean;
  95222. private _useSpecularOverAlpha;
  95223. /**
  95224. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  95225. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  95226. */
  95227. useSpecularOverAlpha: boolean;
  95228. private _useReflectionOverAlpha;
  95229. /**
  95230. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  95231. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  95232. */
  95233. useReflectionOverAlpha: boolean;
  95234. private _disableLighting;
  95235. /**
  95236. * Does lights from the scene impacts this material.
  95237. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  95238. */
  95239. disableLighting: boolean;
  95240. private _useObjectSpaceNormalMap;
  95241. /**
  95242. * Allows using an object space normal map (instead of tangent space).
  95243. */
  95244. useObjectSpaceNormalMap: boolean;
  95245. private _useParallax;
  95246. /**
  95247. * Is parallax enabled or not.
  95248. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  95249. */
  95250. useParallax: boolean;
  95251. private _useParallaxOcclusion;
  95252. /**
  95253. * Is parallax occlusion enabled or not.
  95254. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  95255. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  95256. */
  95257. useParallaxOcclusion: boolean;
  95258. /**
  95259. * 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.
  95260. */
  95261. parallaxScaleBias: number;
  95262. private _roughness;
  95263. /**
  95264. * Helps to define how blurry the reflections should appears in the material.
  95265. */
  95266. roughness: number;
  95267. /**
  95268. * In case of refraction, define the value of the indice of refraction.
  95269. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  95270. */
  95271. indexOfRefraction: number;
  95272. /**
  95273. * Invert the refraction texture alongside the y axis.
  95274. * It can be useful with procedural textures or probe for instance.
  95275. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  95276. */
  95277. invertRefractionY: boolean;
  95278. /**
  95279. * Defines the alpha limits in alpha test mode.
  95280. */
  95281. alphaCutOff: number;
  95282. private _useLightmapAsShadowmap;
  95283. /**
  95284. * In case of light mapping, define whether the map contains light or shadow informations.
  95285. */
  95286. useLightmapAsShadowmap: boolean;
  95287. private _diffuseFresnelParameters;
  95288. /**
  95289. * Define the diffuse fresnel parameters of the material.
  95290. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  95291. */
  95292. diffuseFresnelParameters: FresnelParameters;
  95293. private _opacityFresnelParameters;
  95294. /**
  95295. * Define the opacity fresnel parameters of the material.
  95296. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  95297. */
  95298. opacityFresnelParameters: FresnelParameters;
  95299. private _reflectionFresnelParameters;
  95300. /**
  95301. * Define the reflection fresnel parameters of the material.
  95302. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  95303. */
  95304. reflectionFresnelParameters: FresnelParameters;
  95305. private _refractionFresnelParameters;
  95306. /**
  95307. * Define the refraction fresnel parameters of the material.
  95308. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  95309. */
  95310. refractionFresnelParameters: FresnelParameters;
  95311. private _emissiveFresnelParameters;
  95312. /**
  95313. * Define the emissive fresnel parameters of the material.
  95314. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  95315. */
  95316. emissiveFresnelParameters: FresnelParameters;
  95317. private _useReflectionFresnelFromSpecular;
  95318. /**
  95319. * If true automatically deducts the fresnels values from the material specularity.
  95320. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  95321. */
  95322. useReflectionFresnelFromSpecular: boolean;
  95323. private _useGlossinessFromSpecularMapAlpha;
  95324. /**
  95325. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  95326. */
  95327. useGlossinessFromSpecularMapAlpha: boolean;
  95328. private _maxSimultaneousLights;
  95329. /**
  95330. * Defines the maximum number of lights that can be used in the material
  95331. */
  95332. maxSimultaneousLights: number;
  95333. private _invertNormalMapX;
  95334. /**
  95335. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  95336. */
  95337. invertNormalMapX: boolean;
  95338. private _invertNormalMapY;
  95339. /**
  95340. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  95341. */
  95342. invertNormalMapY: boolean;
  95343. private _twoSidedLighting;
  95344. /**
  95345. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  95346. */
  95347. twoSidedLighting: boolean;
  95348. /**
  95349. * Default configuration related to image processing available in the standard Material.
  95350. */
  95351. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  95352. /**
  95353. * Gets the image processing configuration used either in this material.
  95354. */
  95355. /**
  95356. * Sets the Default image processing configuration used either in the this material.
  95357. *
  95358. * If sets to null, the scene one is in use.
  95359. */
  95360. imageProcessingConfiguration: ImageProcessingConfiguration;
  95361. /**
  95362. * Keep track of the image processing observer to allow dispose and replace.
  95363. */
  95364. private _imageProcessingObserver;
  95365. /**
  95366. * Attaches a new image processing configuration to the Standard Material.
  95367. * @param configuration
  95368. */
  95369. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  95370. /**
  95371. * Gets wether the color curves effect is enabled.
  95372. */
  95373. /**
  95374. * Sets wether the color curves effect is enabled.
  95375. */
  95376. cameraColorCurvesEnabled: boolean;
  95377. /**
  95378. * Gets wether the color grading effect is enabled.
  95379. */
  95380. /**
  95381. * Gets wether the color grading effect is enabled.
  95382. */
  95383. cameraColorGradingEnabled: boolean;
  95384. /**
  95385. * Gets wether tonemapping is enabled or not.
  95386. */
  95387. /**
  95388. * Sets wether tonemapping is enabled or not
  95389. */
  95390. cameraToneMappingEnabled: boolean;
  95391. /**
  95392. * The camera exposure used on this material.
  95393. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  95394. * This corresponds to a photographic exposure.
  95395. */
  95396. /**
  95397. * The camera exposure used on this material.
  95398. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  95399. * This corresponds to a photographic exposure.
  95400. */
  95401. cameraExposure: number;
  95402. /**
  95403. * Gets The camera contrast used on this material.
  95404. */
  95405. /**
  95406. * Sets The camera contrast used on this material.
  95407. */
  95408. cameraContrast: number;
  95409. /**
  95410. * Gets the Color Grading 2D Lookup Texture.
  95411. */
  95412. /**
  95413. * Sets the Color Grading 2D Lookup Texture.
  95414. */
  95415. cameraColorGradingTexture: Nullable<BaseTexture>;
  95416. /**
  95417. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  95418. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  95419. * 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;
  95420. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  95421. */
  95422. /**
  95423. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  95424. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  95425. * 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;
  95426. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  95427. */
  95428. cameraColorCurves: Nullable<ColorCurves>;
  95429. /**
  95430. * Custom callback helping to override the default shader used in the material.
  95431. */
  95432. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  95433. protected _renderTargets: SmartArray<RenderTargetTexture>;
  95434. protected _worldViewProjectionMatrix: Matrix;
  95435. protected _globalAmbientColor: Color3;
  95436. protected _useLogarithmicDepth: boolean;
  95437. /**
  95438. * Instantiates a new standard material.
  95439. * This is the default material used in Babylon. It is the best trade off between quality
  95440. * and performances.
  95441. * @see http://doc.babylonjs.com/babylon101/materials
  95442. * @param name Define the name of the material in the scene
  95443. * @param scene Define the scene the material belong to
  95444. */
  95445. constructor(name: string, scene: Scene);
  95446. /**
  95447. * Gets a boolean indicating that current material needs to register RTT
  95448. */
  95449. readonly hasRenderTargetTextures: boolean;
  95450. /**
  95451. * Gets the current class name of the material e.g. "StandardMaterial"
  95452. * Mainly use in serialization.
  95453. * @returns the class name
  95454. */
  95455. getClassName(): string;
  95456. /**
  95457. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  95458. * You can try switching to logarithmic depth.
  95459. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  95460. */
  95461. useLogarithmicDepth: boolean;
  95462. /**
  95463. * Specifies if the material will require alpha blending
  95464. * @returns a boolean specifying if alpha blending is needed
  95465. */
  95466. needAlphaBlending(): boolean;
  95467. /**
  95468. * Specifies if this material should be rendered in alpha test mode
  95469. * @returns a boolean specifying if an alpha test is needed.
  95470. */
  95471. needAlphaTesting(): boolean;
  95472. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  95473. /**
  95474. * Get the texture used for alpha test purpose.
  95475. * @returns the diffuse texture in case of the standard material.
  95476. */
  95477. getAlphaTestTexture(): Nullable<BaseTexture>;
  95478. /**
  95479. * Get if the submesh is ready to be used and all its information available.
  95480. * Child classes can use it to update shaders
  95481. * @param mesh defines the mesh to check
  95482. * @param subMesh defines which submesh to check
  95483. * @param useInstances specifies that instances should be used
  95484. * @returns a boolean indicating that the submesh is ready or not
  95485. */
  95486. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  95487. /**
  95488. * Builds the material UBO layouts.
  95489. * Used internally during the effect preparation.
  95490. */
  95491. buildUniformLayout(): void;
  95492. /**
  95493. * Unbinds the material from the mesh
  95494. */
  95495. unbind(): void;
  95496. /**
  95497. * Binds the submesh to this material by preparing the effect and shader to draw
  95498. * @param world defines the world transformation matrix
  95499. * @param mesh defines the mesh containing the submesh
  95500. * @param subMesh defines the submesh to bind the material to
  95501. */
  95502. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  95503. /**
  95504. * Get the list of animatables in the material.
  95505. * @returns the list of animatables object used in the material
  95506. */
  95507. getAnimatables(): IAnimatable[];
  95508. /**
  95509. * Gets the active textures from the material
  95510. * @returns an array of textures
  95511. */
  95512. getActiveTextures(): BaseTexture[];
  95513. /**
  95514. * Specifies if the material uses a texture
  95515. * @param texture defines the texture to check against the material
  95516. * @returns a boolean specifying if the material uses the texture
  95517. */
  95518. hasTexture(texture: BaseTexture): boolean;
  95519. /**
  95520. * Disposes the material
  95521. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  95522. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  95523. */
  95524. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  95525. /**
  95526. * Makes a duplicate of the material, and gives it a new name
  95527. * @param name defines the new name for the duplicated material
  95528. * @returns the cloned material
  95529. */
  95530. clone(name: string): StandardMaterial;
  95531. /**
  95532. * Serializes this material in a JSON representation
  95533. * @returns the serialized material object
  95534. */
  95535. serialize(): any;
  95536. /**
  95537. * Creates a standard material from parsed material data
  95538. * @param source defines the JSON representation of the material
  95539. * @param scene defines the hosting scene
  95540. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  95541. * @returns a new standard material
  95542. */
  95543. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  95544. /**
  95545. * Are diffuse textures enabled in the application.
  95546. */
  95547. static DiffuseTextureEnabled: boolean;
  95548. /**
  95549. * Are ambient textures enabled in the application.
  95550. */
  95551. static AmbientTextureEnabled: boolean;
  95552. /**
  95553. * Are opacity textures enabled in the application.
  95554. */
  95555. static OpacityTextureEnabled: boolean;
  95556. /**
  95557. * Are reflection textures enabled in the application.
  95558. */
  95559. static ReflectionTextureEnabled: boolean;
  95560. /**
  95561. * Are emissive textures enabled in the application.
  95562. */
  95563. static EmissiveTextureEnabled: boolean;
  95564. /**
  95565. * Are specular textures enabled in the application.
  95566. */
  95567. static SpecularTextureEnabled: boolean;
  95568. /**
  95569. * Are bump textures enabled in the application.
  95570. */
  95571. static BumpTextureEnabled: boolean;
  95572. /**
  95573. * Are lightmap textures enabled in the application.
  95574. */
  95575. static LightmapTextureEnabled: boolean;
  95576. /**
  95577. * Are refraction textures enabled in the application.
  95578. */
  95579. static RefractionTextureEnabled: boolean;
  95580. /**
  95581. * Are color grading textures enabled in the application.
  95582. */
  95583. static ColorGradingTextureEnabled: boolean;
  95584. /**
  95585. * Are fresnels enabled in the application.
  95586. */
  95587. static FresnelEnabled: boolean;
  95588. }
  95589. }
  95590. declare module BABYLON {
  95591. /**
  95592. * A class extending Texture allowing drawing on a texture
  95593. * @see http://doc.babylonjs.com/how_to/dynamictexture
  95594. */
  95595. export class DynamicTexture extends Texture {
  95596. private _generateMipMaps;
  95597. private _canvas;
  95598. private _context;
  95599. private _engine;
  95600. /**
  95601. * Creates a DynamicTexture
  95602. * @param name defines the name of the texture
  95603. * @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
  95604. * @param scene defines the scene where you want the texture
  95605. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  95606. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  95607. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  95608. */
  95609. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  95610. /**
  95611. * Get the current class name of the texture useful for serialization or dynamic coding.
  95612. * @returns "DynamicTexture"
  95613. */
  95614. getClassName(): string;
  95615. /**
  95616. * Gets the current state of canRescale
  95617. */
  95618. readonly canRescale: boolean;
  95619. private _recreate;
  95620. /**
  95621. * Scales the texture
  95622. * @param ratio the scale factor to apply to both width and height
  95623. */
  95624. scale(ratio: number): void;
  95625. /**
  95626. * Resizes the texture
  95627. * @param width the new width
  95628. * @param height the new height
  95629. */
  95630. scaleTo(width: number, height: number): void;
  95631. /**
  95632. * Gets the context of the canvas used by the texture
  95633. * @returns the canvas context of the dynamic texture
  95634. */
  95635. getContext(): CanvasRenderingContext2D;
  95636. /**
  95637. * Clears the texture
  95638. */
  95639. clear(): void;
  95640. /**
  95641. * Updates the texture
  95642. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  95643. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  95644. */
  95645. update(invertY?: boolean, premulAlpha?: boolean): void;
  95646. /**
  95647. * Draws text onto the texture
  95648. * @param text defines the text to be drawn
  95649. * @param x defines the placement of the text from the left
  95650. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  95651. * @param font defines the font to be used with font-style, font-size, font-name
  95652. * @param color defines the color used for the text
  95653. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  95654. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  95655. * @param update defines whether texture is immediately update (default is true)
  95656. */
  95657. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  95658. /**
  95659. * Clones the texture
  95660. * @returns the clone of the texture.
  95661. */
  95662. clone(): DynamicTexture;
  95663. /**
  95664. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  95665. * @returns a serialized dynamic texture object
  95666. */
  95667. serialize(): any;
  95668. /** @hidden */
  95669. _rebuild(): void;
  95670. }
  95671. }
  95672. declare module BABYLON {
  95673. /** @hidden */
  95674. export var imageProcessingPixelShader: {
  95675. name: string;
  95676. shader: string;
  95677. };
  95678. }
  95679. declare module BABYLON {
  95680. /**
  95681. * ImageProcessingPostProcess
  95682. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  95683. */
  95684. export class ImageProcessingPostProcess extends PostProcess {
  95685. /**
  95686. * Default configuration related to image processing available in the PBR Material.
  95687. */
  95688. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  95689. /**
  95690. * Gets the image processing configuration used either in this material.
  95691. */
  95692. /**
  95693. * Sets the Default image processing configuration used either in the this material.
  95694. *
  95695. * If sets to null, the scene one is in use.
  95696. */
  95697. imageProcessingConfiguration: ImageProcessingConfiguration;
  95698. /**
  95699. * Keep track of the image processing observer to allow dispose and replace.
  95700. */
  95701. private _imageProcessingObserver;
  95702. /**
  95703. * Attaches a new image processing configuration to the PBR Material.
  95704. * @param configuration
  95705. */
  95706. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  95707. /**
  95708. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  95709. */
  95710. /**
  95711. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  95712. */
  95713. colorCurves: Nullable<ColorCurves>;
  95714. /**
  95715. * Gets wether the color curves effect is enabled.
  95716. */
  95717. /**
  95718. * Sets wether the color curves effect is enabled.
  95719. */
  95720. colorCurvesEnabled: boolean;
  95721. /**
  95722. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  95723. */
  95724. /**
  95725. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  95726. */
  95727. colorGradingTexture: Nullable<BaseTexture>;
  95728. /**
  95729. * Gets wether the color grading effect is enabled.
  95730. */
  95731. /**
  95732. * Gets wether the color grading effect is enabled.
  95733. */
  95734. colorGradingEnabled: boolean;
  95735. /**
  95736. * Gets exposure used in the effect.
  95737. */
  95738. /**
  95739. * Sets exposure used in the effect.
  95740. */
  95741. exposure: number;
  95742. /**
  95743. * Gets wether tonemapping is enabled or not.
  95744. */
  95745. /**
  95746. * Sets wether tonemapping is enabled or not
  95747. */
  95748. toneMappingEnabled: boolean;
  95749. /**
  95750. * Gets the type of tone mapping effect.
  95751. */
  95752. /**
  95753. * Sets the type of tone mapping effect.
  95754. */
  95755. toneMappingType: number;
  95756. /**
  95757. * Gets contrast used in the effect.
  95758. */
  95759. /**
  95760. * Sets contrast used in the effect.
  95761. */
  95762. contrast: number;
  95763. /**
  95764. * Gets Vignette stretch size.
  95765. */
  95766. /**
  95767. * Sets Vignette stretch size.
  95768. */
  95769. vignetteStretch: number;
  95770. /**
  95771. * Gets Vignette centre X Offset.
  95772. */
  95773. /**
  95774. * Sets Vignette centre X Offset.
  95775. */
  95776. vignetteCentreX: number;
  95777. /**
  95778. * Gets Vignette centre Y Offset.
  95779. */
  95780. /**
  95781. * Sets Vignette centre Y Offset.
  95782. */
  95783. vignetteCentreY: number;
  95784. /**
  95785. * Gets Vignette weight or intensity of the vignette effect.
  95786. */
  95787. /**
  95788. * Sets Vignette weight or intensity of the vignette effect.
  95789. */
  95790. vignetteWeight: number;
  95791. /**
  95792. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  95793. * if vignetteEnabled is set to true.
  95794. */
  95795. /**
  95796. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  95797. * if vignetteEnabled is set to true.
  95798. */
  95799. vignetteColor: Color4;
  95800. /**
  95801. * Gets Camera field of view used by the Vignette effect.
  95802. */
  95803. /**
  95804. * Sets Camera field of view used by the Vignette effect.
  95805. */
  95806. vignetteCameraFov: number;
  95807. /**
  95808. * Gets the vignette blend mode allowing different kind of effect.
  95809. */
  95810. /**
  95811. * Sets the vignette blend mode allowing different kind of effect.
  95812. */
  95813. vignetteBlendMode: number;
  95814. /**
  95815. * Gets wether the vignette effect is enabled.
  95816. */
  95817. /**
  95818. * Sets wether the vignette effect is enabled.
  95819. */
  95820. vignetteEnabled: boolean;
  95821. private _fromLinearSpace;
  95822. /**
  95823. * Gets wether the input of the processing is in Gamma or Linear Space.
  95824. */
  95825. /**
  95826. * Sets wether the input of the processing is in Gamma or Linear Space.
  95827. */
  95828. fromLinearSpace: boolean;
  95829. /**
  95830. * Defines cache preventing GC.
  95831. */
  95832. private _defines;
  95833. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  95834. /**
  95835. * "ImageProcessingPostProcess"
  95836. * @returns "ImageProcessingPostProcess"
  95837. */
  95838. getClassName(): string;
  95839. protected _updateParameters(): void;
  95840. dispose(camera?: Camera): void;
  95841. }
  95842. }
  95843. declare module BABYLON {
  95844. /**
  95845. * Class containing static functions to help procedurally build meshes
  95846. */
  95847. export class GroundBuilder {
  95848. /**
  95849. * Creates a ground mesh
  95850. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  95851. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  95852. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  95853. * @param name defines the name of the mesh
  95854. * @param options defines the options used to create the mesh
  95855. * @param scene defines the hosting scene
  95856. * @returns the ground mesh
  95857. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  95858. */
  95859. static CreateGround(name: string, options: {
  95860. width?: number;
  95861. height?: number;
  95862. subdivisions?: number;
  95863. subdivisionsX?: number;
  95864. subdivisionsY?: number;
  95865. updatable?: boolean;
  95866. }, scene: any): Mesh;
  95867. /**
  95868. * Creates a tiled ground mesh
  95869. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  95870. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  95871. * * 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
  95872. * * 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
  95873. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  95874. * @param name defines the name of the mesh
  95875. * @param options defines the options used to create the mesh
  95876. * @param scene defines the hosting scene
  95877. * @returns the tiled ground mesh
  95878. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  95879. */
  95880. static CreateTiledGround(name: string, options: {
  95881. xmin: number;
  95882. zmin: number;
  95883. xmax: number;
  95884. zmax: number;
  95885. subdivisions?: {
  95886. w: number;
  95887. h: number;
  95888. };
  95889. precision?: {
  95890. w: number;
  95891. h: number;
  95892. };
  95893. updatable?: boolean;
  95894. }, scene: Scene): Mesh;
  95895. /**
  95896. * Creates a ground mesh from a height map
  95897. * * The parameter `url` sets the URL of the height map image resource.
  95898. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  95899. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  95900. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  95901. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  95902. * * 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.
  95903. * * 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).
  95904. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  95905. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  95906. * @param name defines the name of the mesh
  95907. * @param url defines the url to the height map
  95908. * @param options defines the options used to create the mesh
  95909. * @param scene defines the hosting scene
  95910. * @returns the ground mesh
  95911. * @see https://doc.babylonjs.com/babylon101/height_map
  95912. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  95913. */
  95914. static CreateGroundFromHeightMap(name: string, url: string, options: {
  95915. width?: number;
  95916. height?: number;
  95917. subdivisions?: number;
  95918. minHeight?: number;
  95919. maxHeight?: number;
  95920. colorFilter?: Color3;
  95921. alphaFilter?: number;
  95922. updatable?: boolean;
  95923. onReady?: (mesh: GroundMesh) => void;
  95924. }, scene: Scene): GroundMesh;
  95925. }
  95926. }
  95927. declare module BABYLON {
  95928. /**
  95929. * Class containing static functions to help procedurally build meshes
  95930. */
  95931. export class TorusBuilder {
  95932. /**
  95933. * Creates a torus mesh
  95934. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  95935. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  95936. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  95937. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  95938. * * If you create a double-sided mesh, you can choose what parts of 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
  95939. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  95940. * @param name defines the name of the mesh
  95941. * @param options defines the options used to create the mesh
  95942. * @param scene defines the hosting scene
  95943. * @returns the torus mesh
  95944. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  95945. */
  95946. static CreateTorus(name: string, options: {
  95947. diameter?: number;
  95948. thickness?: number;
  95949. tessellation?: number;
  95950. updatable?: boolean;
  95951. sideOrientation?: number;
  95952. frontUVs?: Vector4;
  95953. backUVs?: Vector4;
  95954. }, scene: any): Mesh;
  95955. }
  95956. }
  95957. declare module BABYLON {
  95958. /**
  95959. * Class containing static functions to help procedurally build meshes
  95960. */
  95961. export class CylinderBuilder {
  95962. /**
  95963. * Creates a cylinder or a cone mesh
  95964. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  95965. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  95966. * * 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.
  95967. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  95968. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  95969. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  95970. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  95971. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  95972. * * 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).
  95973. * * 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
  95974. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  95975. * * 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
  95976. * * 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.
  95977. * * If `enclose` is false, a ring surface is one element.
  95978. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  95979. * * 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
  95980. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  95981. * * If you create a double-sided mesh, you can choose what parts of 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
  95982. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  95983. * @param name defines the name of the mesh
  95984. * @param options defines the options used to create the mesh
  95985. * @param scene defines the hosting scene
  95986. * @returns the cylinder mesh
  95987. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  95988. */
  95989. static CreateCylinder(name: string, options: {
  95990. height?: number;
  95991. diameterTop?: number;
  95992. diameterBottom?: number;
  95993. diameter?: number;
  95994. tessellation?: number;
  95995. subdivisions?: number;
  95996. arc?: number;
  95997. faceColors?: Color4[];
  95998. faceUV?: Vector4[];
  95999. updatable?: boolean;
  96000. hasRings?: boolean;
  96001. enclose?: boolean;
  96002. sideOrientation?: number;
  96003. frontUVs?: Vector4;
  96004. backUVs?: Vector4;
  96005. }, scene: any): Mesh;
  96006. }
  96007. }
  96008. declare module BABYLON {
  96009. /**
  96010. * Manager for handling gamepads
  96011. */
  96012. export class GamepadManager {
  96013. private _scene?;
  96014. private _babylonGamepads;
  96015. private _oneGamepadConnected;
  96016. /** @hidden */
  96017. _isMonitoring: boolean;
  96018. private _gamepadEventSupported;
  96019. private _gamepadSupport;
  96020. /**
  96021. * observable to be triggered when the gamepad controller has been connected
  96022. */
  96023. onGamepadConnectedObservable: Observable<Gamepad>;
  96024. /**
  96025. * observable to be triggered when the gamepad controller has been disconnected
  96026. */
  96027. onGamepadDisconnectedObservable: Observable<Gamepad>;
  96028. private _onGamepadConnectedEvent;
  96029. private _onGamepadDisconnectedEvent;
  96030. /**
  96031. * Initializes the gamepad manager
  96032. * @param _scene BabylonJS scene
  96033. */
  96034. constructor(_scene?: Scene | undefined);
  96035. /**
  96036. * The gamepads in the game pad manager
  96037. */
  96038. readonly gamepads: Gamepad[];
  96039. /**
  96040. * Get the gamepad controllers based on type
  96041. * @param type The type of gamepad controller
  96042. * @returns Nullable gamepad
  96043. */
  96044. getGamepadByType(type?: number): Nullable<Gamepad>;
  96045. /**
  96046. * Disposes the gamepad manager
  96047. */
  96048. dispose(): void;
  96049. private _addNewGamepad;
  96050. private _startMonitoringGamepads;
  96051. private _stopMonitoringGamepads;
  96052. /** @hidden */
  96053. _checkGamepadsStatus(): void;
  96054. private _updateGamepadObjects;
  96055. }
  96056. }
  96057. declare module BABYLON {
  96058. interface Scene {
  96059. /** @hidden */
  96060. _gamepadManager: Nullable<GamepadManager>;
  96061. /**
  96062. * Gets the gamepad manager associated with the scene
  96063. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  96064. */
  96065. gamepadManager: GamepadManager;
  96066. }
  96067. /**
  96068. * Interface representing a free camera inputs manager
  96069. */
  96070. interface FreeCameraInputsManager {
  96071. /**
  96072. * Adds gamepad input support to the FreeCameraInputsManager.
  96073. * @returns the FreeCameraInputsManager
  96074. */
  96075. addGamepad(): FreeCameraInputsManager;
  96076. }
  96077. /**
  96078. * Interface representing an arc rotate camera inputs manager
  96079. */
  96080. interface ArcRotateCameraInputsManager {
  96081. /**
  96082. * Adds gamepad input support to the ArcRotateCamera InputManager.
  96083. * @returns the camera inputs manager
  96084. */
  96085. addGamepad(): ArcRotateCameraInputsManager;
  96086. }
  96087. /**
  96088. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  96089. */
  96090. export class GamepadSystemSceneComponent implements ISceneComponent {
  96091. /**
  96092. * The component name helpfull to identify the component in the list of scene components.
  96093. */
  96094. readonly name: string;
  96095. /**
  96096. * The scene the component belongs to.
  96097. */
  96098. scene: Scene;
  96099. /**
  96100. * Creates a new instance of the component for the given scene
  96101. * @param scene Defines the scene to register the component in
  96102. */
  96103. constructor(scene: Scene);
  96104. /**
  96105. * Registers the component in a given scene
  96106. */
  96107. register(): void;
  96108. /**
  96109. * Rebuilds the elements related to this component in case of
  96110. * context lost for instance.
  96111. */
  96112. rebuild(): void;
  96113. /**
  96114. * Disposes the component and the associated ressources
  96115. */
  96116. dispose(): void;
  96117. private _beforeCameraUpdate;
  96118. }
  96119. }
  96120. declare module BABYLON {
  96121. /**
  96122. * Options to modify the vr teleportation behavior.
  96123. */
  96124. export interface VRTeleportationOptions {
  96125. /**
  96126. * The name of the mesh which should be used as the teleportation floor. (default: null)
  96127. */
  96128. floorMeshName?: string;
  96129. /**
  96130. * A list of meshes to be used as the teleportation floor. (default: empty)
  96131. */
  96132. floorMeshes?: Mesh[];
  96133. }
  96134. /**
  96135. * Options to modify the vr experience helper's behavior.
  96136. */
  96137. export interface VRExperienceHelperOptions extends WebVROptions {
  96138. /**
  96139. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  96140. */
  96141. createDeviceOrientationCamera?: boolean;
  96142. /**
  96143. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  96144. */
  96145. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  96146. /**
  96147. * Uses the main button on the controller to toggle the laser casted. (default: true)
  96148. */
  96149. laserToggle?: boolean;
  96150. /**
  96151. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  96152. */
  96153. floorMeshes?: Mesh[];
  96154. /**
  96155. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  96156. */
  96157. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  96158. }
  96159. /**
  96160. * Event containing information after VR has been entered
  96161. */
  96162. export class OnAfterEnteringVRObservableEvent {
  96163. /**
  96164. * If entering vr was successful
  96165. */
  96166. success: boolean;
  96167. }
  96168. /**
  96169. * Helps to quickly add VR support to an existing scene.
  96170. * See http://doc.babylonjs.com/how_to/webvr_helper
  96171. */
  96172. export class VRExperienceHelper {
  96173. /** Options to modify the vr experience helper's behavior. */
  96174. webVROptions: VRExperienceHelperOptions;
  96175. private _scene;
  96176. private _position;
  96177. private _btnVR;
  96178. private _btnVRDisplayed;
  96179. private _webVRsupported;
  96180. private _webVRready;
  96181. private _webVRrequesting;
  96182. private _webVRpresenting;
  96183. private _hasEnteredVR;
  96184. private _fullscreenVRpresenting;
  96185. private _canvas;
  96186. private _webVRCamera;
  96187. private _vrDeviceOrientationCamera;
  96188. private _deviceOrientationCamera;
  96189. private _existingCamera;
  96190. private _onKeyDown;
  96191. private _onVrDisplayPresentChange;
  96192. private _onVRDisplayChanged;
  96193. private _onVRRequestPresentStart;
  96194. private _onVRRequestPresentComplete;
  96195. /**
  96196. * Observable raised right before entering VR.
  96197. */
  96198. onEnteringVRObservable: Observable<VRExperienceHelper>;
  96199. /**
  96200. * Observable raised when entering VR has completed.
  96201. */
  96202. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  96203. /**
  96204. * Observable raised when exiting VR.
  96205. */
  96206. onExitingVRObservable: Observable<VRExperienceHelper>;
  96207. /**
  96208. * Observable raised when controller mesh is loaded.
  96209. */
  96210. onControllerMeshLoadedObservable: Observable<WebVRController>;
  96211. /** Return this.onEnteringVRObservable
  96212. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  96213. */
  96214. readonly onEnteringVR: Observable<VRExperienceHelper>;
  96215. /** Return this.onExitingVRObservable
  96216. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  96217. */
  96218. readonly onExitingVR: Observable<VRExperienceHelper>;
  96219. /** Return this.onControllerMeshLoadedObservable
  96220. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  96221. */
  96222. readonly onControllerMeshLoaded: Observable<WebVRController>;
  96223. private _rayLength;
  96224. private _useCustomVRButton;
  96225. private _teleportationRequested;
  96226. private _teleportActive;
  96227. private _floorMeshName;
  96228. private _floorMeshesCollection;
  96229. private _rotationAllowed;
  96230. private _teleportBackwardsVector;
  96231. private _teleportationTarget;
  96232. private _isDefaultTeleportationTarget;
  96233. private _postProcessMove;
  96234. private _teleportationFillColor;
  96235. private _teleportationBorderColor;
  96236. private _rotationAngle;
  96237. private _haloCenter;
  96238. private _cameraGazer;
  96239. private _padSensibilityUp;
  96240. private _padSensibilityDown;
  96241. private _leftController;
  96242. private _rightController;
  96243. /**
  96244. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  96245. */
  96246. onNewMeshSelected: Observable<AbstractMesh>;
  96247. /**
  96248. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  96249. */
  96250. onNewMeshPicked: Observable<PickingInfo>;
  96251. private _circleEase;
  96252. /**
  96253. * Observable raised before camera teleportation
  96254. */
  96255. onBeforeCameraTeleport: Observable<Vector3>;
  96256. /**
  96257. * Observable raised after camera teleportation
  96258. */
  96259. onAfterCameraTeleport: Observable<Vector3>;
  96260. /**
  96261. * Observable raised when current selected mesh gets unselected
  96262. */
  96263. onSelectedMeshUnselected: Observable<AbstractMesh>;
  96264. private _raySelectionPredicate;
  96265. /**
  96266. * To be optionaly changed by user to define custom ray selection
  96267. */
  96268. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  96269. /**
  96270. * To be optionaly changed by user to define custom selection logic (after ray selection)
  96271. */
  96272. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  96273. /**
  96274. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  96275. */
  96276. teleportationEnabled: boolean;
  96277. private _defaultHeight;
  96278. private _teleportationInitialized;
  96279. private _interactionsEnabled;
  96280. private _interactionsRequested;
  96281. private _displayGaze;
  96282. private _displayLaserPointer;
  96283. /**
  96284. * The mesh used to display where the user is going to teleport.
  96285. */
  96286. /**
  96287. * Sets the mesh to be used to display where the user is going to teleport.
  96288. */
  96289. teleportationTarget: Mesh;
  96290. /**
  96291. * 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
  96292. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  96293. * See http://doc.babylonjs.com/resources/baking_transformations
  96294. */
  96295. gazeTrackerMesh: Mesh;
  96296. /**
  96297. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  96298. */
  96299. updateGazeTrackerScale: boolean;
  96300. /**
  96301. * If the gaze trackers color should be updated when selecting meshes
  96302. */
  96303. updateGazeTrackerColor: boolean;
  96304. /**
  96305. * The gaze tracking mesh corresponding to the left controller
  96306. */
  96307. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  96308. /**
  96309. * The gaze tracking mesh corresponding to the right controller
  96310. */
  96311. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  96312. /**
  96313. * If the ray of the gaze should be displayed.
  96314. */
  96315. /**
  96316. * Sets if the ray of the gaze should be displayed.
  96317. */
  96318. displayGaze: boolean;
  96319. /**
  96320. * If the ray of the LaserPointer should be displayed.
  96321. */
  96322. /**
  96323. * Sets if the ray of the LaserPointer should be displayed.
  96324. */
  96325. displayLaserPointer: boolean;
  96326. /**
  96327. * The deviceOrientationCamera used as the camera when not in VR.
  96328. */
  96329. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  96330. /**
  96331. * Based on the current WebVR support, returns the current VR camera used.
  96332. */
  96333. readonly currentVRCamera: Nullable<Camera>;
  96334. /**
  96335. * The webVRCamera which is used when in VR.
  96336. */
  96337. readonly webVRCamera: WebVRFreeCamera;
  96338. /**
  96339. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  96340. */
  96341. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  96342. private readonly _teleportationRequestInitiated;
  96343. /**
  96344. * Defines wether or not Pointer lock should be requested when switching to
  96345. * full screen.
  96346. */
  96347. requestPointerLockOnFullScreen: boolean;
  96348. /**
  96349. * Instantiates a VRExperienceHelper.
  96350. * Helps to quickly add VR support to an existing scene.
  96351. * @param scene The scene the VRExperienceHelper belongs to.
  96352. * @param webVROptions Options to modify the vr experience helper's behavior.
  96353. */
  96354. constructor(scene: Scene,
  96355. /** Options to modify the vr experience helper's behavior. */
  96356. webVROptions?: VRExperienceHelperOptions);
  96357. private _onDefaultMeshLoaded;
  96358. private _onResize;
  96359. private _onFullscreenChange;
  96360. /**
  96361. * Gets a value indicating if we are currently in VR mode.
  96362. */
  96363. readonly isInVRMode: boolean;
  96364. private onVrDisplayPresentChange;
  96365. private onVRDisplayChanged;
  96366. private moveButtonToBottomRight;
  96367. private displayVRButton;
  96368. private updateButtonVisibility;
  96369. private _cachedAngularSensibility;
  96370. /**
  96371. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  96372. * Otherwise, will use the fullscreen API.
  96373. */
  96374. enterVR(): void;
  96375. /**
  96376. * Attempt to exit VR, or fullscreen.
  96377. */
  96378. exitVR(): void;
  96379. /**
  96380. * The position of the vr experience helper.
  96381. */
  96382. /**
  96383. * Sets the position of the vr experience helper.
  96384. */
  96385. position: Vector3;
  96386. /**
  96387. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  96388. */
  96389. enableInteractions(): void;
  96390. private readonly _noControllerIsActive;
  96391. private beforeRender;
  96392. private _isTeleportationFloor;
  96393. /**
  96394. * Adds a floor mesh to be used for teleportation.
  96395. * @param floorMesh the mesh to be used for teleportation.
  96396. */
  96397. addFloorMesh(floorMesh: Mesh): void;
  96398. /**
  96399. * Removes a floor mesh from being used for teleportation.
  96400. * @param floorMesh the mesh to be removed.
  96401. */
  96402. removeFloorMesh(floorMesh: Mesh): void;
  96403. /**
  96404. * Enables interactions and teleportation using the VR controllers and gaze.
  96405. * @param vrTeleportationOptions options to modify teleportation behavior.
  96406. */
  96407. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  96408. private _onNewGamepadConnected;
  96409. private _tryEnableInteractionOnController;
  96410. private _onNewGamepadDisconnected;
  96411. private _enableInteractionOnController;
  96412. private _checkTeleportWithRay;
  96413. private _checkRotate;
  96414. private _checkTeleportBackwards;
  96415. private _enableTeleportationOnController;
  96416. private _createTeleportationCircles;
  96417. private _displayTeleportationTarget;
  96418. private _hideTeleportationTarget;
  96419. private _rotateCamera;
  96420. private _moveTeleportationSelectorTo;
  96421. private _workingVector;
  96422. private _workingQuaternion;
  96423. private _workingMatrix;
  96424. /**
  96425. * Teleports the users feet to the desired location
  96426. * @param location The location where the user's feet should be placed
  96427. */
  96428. teleportCamera(location: Vector3): void;
  96429. private _convertNormalToDirectionOfRay;
  96430. private _castRayAndSelectObject;
  96431. private _notifySelectedMeshUnselected;
  96432. /**
  96433. * Sets the color of the laser ray from the vr controllers.
  96434. * @param color new color for the ray.
  96435. */
  96436. changeLaserColor(color: Color3): void;
  96437. /**
  96438. * Sets the color of the ray from the vr headsets gaze.
  96439. * @param color new color for the ray.
  96440. */
  96441. changeGazeColor(color: Color3): void;
  96442. /**
  96443. * Exits VR and disposes of the vr experience helper
  96444. */
  96445. dispose(): void;
  96446. /**
  96447. * Gets the name of the VRExperienceHelper class
  96448. * @returns "VRExperienceHelper"
  96449. */
  96450. getClassName(): string;
  96451. }
  96452. }
  96453. declare module BABYLON {
  96454. /**
  96455. * Manages an XRSession
  96456. * @see https://doc.babylonjs.com/how_to/webxr
  96457. */
  96458. export class WebXRSessionManager implements IDisposable {
  96459. private scene;
  96460. /**
  96461. * Fires every time a new xrFrame arrives which can be used to update the camera
  96462. */
  96463. onXRFrameObservable: Observable<any>;
  96464. /**
  96465. * Fires when the xr session is ended either by the device or manually done
  96466. */
  96467. onXRSessionEnded: Observable<any>;
  96468. /** @hidden */
  96469. _xrSession: XRSession;
  96470. /** @hidden */
  96471. _frameOfReference: XRFrameOfReference;
  96472. /** @hidden */
  96473. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  96474. /** @hidden */
  96475. _currentXRFrame: Nullable<XRFrame>;
  96476. private _xrNavigator;
  96477. private _xrDevice;
  96478. private _tmpMatrix;
  96479. /**
  96480. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  96481. * @param scene The scene which the session should be created for
  96482. */
  96483. constructor(scene: Scene);
  96484. /**
  96485. * Initializes the manager
  96486. * After initialization enterXR can be called to start an XR session
  96487. * @returns Promise which resolves after it is initialized
  96488. */
  96489. initializeAsync(): Promise<void>;
  96490. /**
  96491. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  96492. * @param sessionCreationOptions xr options to create the session with
  96493. * @param frameOfReferenceType option to configure how the xr pose is expressed
  96494. * @returns Promise which resolves after it enters XR
  96495. */
  96496. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  96497. /**
  96498. * Stops the xrSession and restores the renderloop
  96499. * @returns Promise which resolves after it exits XR
  96500. */
  96501. exitXRAsync(): Promise<void>;
  96502. /**
  96503. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  96504. * @param ray ray to cast into the environment
  96505. * @returns Promise which resolves with a collision point in the environment if it exists
  96506. */
  96507. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  96508. /**
  96509. * Checks if a session would be supported for the creation options specified
  96510. * @param options creation options to check if they are supported
  96511. * @returns true if supported
  96512. */
  96513. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  96514. /**
  96515. * @hidden
  96516. * Converts the render layer of xrSession to a render target
  96517. * @param session session to create render target for
  96518. * @param scene scene the new render target should be created for
  96519. */
  96520. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  96521. /**
  96522. * Disposes of the session manager
  96523. */
  96524. dispose(): void;
  96525. }
  96526. }
  96527. declare module BABYLON {
  96528. /**
  96529. * WebXR Camera which holds the views for the xrSession
  96530. * @see https://doc.babylonjs.com/how_to/webxr
  96531. */
  96532. export class WebXRCamera extends FreeCamera {
  96533. private static _TmpMatrix;
  96534. /**
  96535. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  96536. * @param name the name of the camera
  96537. * @param scene the scene to add the camera to
  96538. */
  96539. constructor(name: string, scene: Scene);
  96540. private _updateNumberOfRigCameras;
  96541. /** @hidden */
  96542. _updateForDualEyeDebugging(pupilDistance?: number): void;
  96543. /**
  96544. * Updates the cameras position from the current pose information of the XR session
  96545. * @param xrSessionManager the session containing pose information
  96546. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  96547. */
  96548. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  96549. }
  96550. }
  96551. declare module BABYLON {
  96552. /**
  96553. * States of the webXR experience
  96554. */
  96555. export enum WebXRState {
  96556. /**
  96557. * Transitioning to being in XR mode
  96558. */
  96559. ENTERING_XR = 0,
  96560. /**
  96561. * Transitioning to non XR mode
  96562. */
  96563. EXITING_XR = 1,
  96564. /**
  96565. * In XR mode and presenting
  96566. */
  96567. IN_XR = 2,
  96568. /**
  96569. * Not entered XR mode
  96570. */
  96571. NOT_IN_XR = 3
  96572. }
  96573. /**
  96574. * Helper class used to enable XR
  96575. * @see https://doc.babylonjs.com/how_to/webxr
  96576. */
  96577. export class WebXRExperienceHelper implements IDisposable {
  96578. private scene;
  96579. /**
  96580. * 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
  96581. */
  96582. container: AbstractMesh;
  96583. /**
  96584. * Camera used to render xr content
  96585. */
  96586. camera: WebXRCamera;
  96587. /**
  96588. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  96589. */
  96590. state: WebXRState;
  96591. private _setState;
  96592. private static _TmpVector;
  96593. /**
  96594. * Fires when the state of the experience helper has changed
  96595. */
  96596. onStateChangedObservable: Observable<WebXRState>;
  96597. /** @hidden */
  96598. _sessionManager: WebXRSessionManager;
  96599. private _nonVRCamera;
  96600. private _originalSceneAutoClear;
  96601. private _supported;
  96602. /**
  96603. * Creates the experience helper
  96604. * @param scene the scene to attach the experience helper to
  96605. * @returns a promise for the experience helper
  96606. */
  96607. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  96608. /**
  96609. * Creates a WebXRExperienceHelper
  96610. * @param scene The scene the helper should be created in
  96611. */
  96612. private constructor();
  96613. /**
  96614. * Exits XR mode and returns the scene to its original state
  96615. * @returns promise that resolves after xr mode has exited
  96616. */
  96617. exitXRAsync(): Promise<void>;
  96618. /**
  96619. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  96620. * @param sessionCreationOptions options for the XR session
  96621. * @param frameOfReference frame of reference of the XR session
  96622. * @returns promise that resolves after xr mode has entered
  96623. */
  96624. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  96625. /**
  96626. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  96627. * @param ray ray to cast into the environment
  96628. * @returns Promise which resolves with a collision point in the environment if it exists
  96629. */
  96630. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  96631. /**
  96632. * Updates the global position of the camera by moving the camera's container
  96633. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  96634. * @param position The desired global position of the camera
  96635. */
  96636. setPositionOfCameraUsingContainer(position: Vector3): void;
  96637. /**
  96638. * Rotates the xr camera by rotating the camera's container around the camera's position
  96639. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  96640. * @param rotation the desired quaternion rotation to apply to the camera
  96641. */
  96642. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  96643. /**
  96644. * Checks if the creation options are supported by the xr session
  96645. * @param options creation options
  96646. * @returns true if supported
  96647. */
  96648. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  96649. /**
  96650. * Disposes of the experience helper
  96651. */
  96652. dispose(): void;
  96653. }
  96654. }
  96655. declare module BABYLON {
  96656. /**
  96657. * Button which can be used to enter a different mode of XR
  96658. */
  96659. export class WebXREnterExitUIButton {
  96660. /** button element */
  96661. element: HTMLElement;
  96662. /** XR initialization options for the button */
  96663. initializationOptions: XRSessionCreationOptions;
  96664. /**
  96665. * Creates a WebXREnterExitUIButton
  96666. * @param element button element
  96667. * @param initializationOptions XR initialization options for the button
  96668. */
  96669. constructor(
  96670. /** button element */
  96671. element: HTMLElement,
  96672. /** XR initialization options for the button */
  96673. initializationOptions: XRSessionCreationOptions);
  96674. /**
  96675. * Overwritable function which can be used to update the button's visuals when the state changes
  96676. * @param activeButton the current active button in the UI
  96677. */
  96678. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  96679. }
  96680. /**
  96681. * Options to create the webXR UI
  96682. */
  96683. export class WebXREnterExitUIOptions {
  96684. /**
  96685. * Context to enter xr with
  96686. */
  96687. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  96688. /**
  96689. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  96690. */
  96691. customButtons?: Array<WebXREnterExitUIButton>;
  96692. }
  96693. /**
  96694. * UI to allow the user to enter/exit XR mode
  96695. */
  96696. export class WebXREnterExitUI implements IDisposable {
  96697. private scene;
  96698. private _overlay;
  96699. private _buttons;
  96700. private _activeButton;
  96701. /**
  96702. * Fired every time the active button is changed.
  96703. *
  96704. * When xr is entered via a button that launches xr that button will be the callback parameter
  96705. *
  96706. * When exiting xr the callback parameter will be null)
  96707. */
  96708. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  96709. /**
  96710. * Creates UI to allow the user to enter/exit XR mode
  96711. * @param scene the scene to add the ui to
  96712. * @param helper the xr experience helper to enter/exit xr with
  96713. * @param options options to configure the UI
  96714. * @returns the created ui
  96715. */
  96716. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  96717. private constructor();
  96718. private _updateButtons;
  96719. /**
  96720. * Disposes of the object
  96721. */
  96722. dispose(): void;
  96723. }
  96724. }
  96725. declare module BABYLON {
  96726. /**
  96727. * Represents an XR input
  96728. */
  96729. export class WebXRController {
  96730. /**
  96731. * 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
  96732. */
  96733. grip?: AbstractMesh;
  96734. /**
  96735. * Pointer which can be used to select objects or attach a visible laser to
  96736. */
  96737. pointer: AbstractMesh;
  96738. /**
  96739. * Creates the controller
  96740. * @see https://doc.babylonjs.com/how_to/webxr
  96741. * @param scene the scene which the controller should be associated to
  96742. */
  96743. constructor(scene: Scene);
  96744. /**
  96745. * Disposes of the object
  96746. */
  96747. dispose(): void;
  96748. }
  96749. /**
  96750. * XR input used to track XR inputs such as controllers/rays
  96751. */
  96752. export class WebXRInput implements IDisposable {
  96753. private helper;
  96754. /**
  96755. * XR controllers being tracked
  96756. */
  96757. controllers: Array<WebXRController>;
  96758. private _tmpMatrix;
  96759. private _frameObserver;
  96760. /**
  96761. * Initializes the WebXRInput
  96762. * @param helper experience helper which the input should be created for
  96763. */
  96764. constructor(helper: WebXRExperienceHelper);
  96765. /**
  96766. * Disposes of the object
  96767. */
  96768. dispose(): void;
  96769. }
  96770. }
  96771. declare module BABYLON {
  96772. /**
  96773. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  96774. */
  96775. export class WebXRManagedOutputCanvas implements IDisposable {
  96776. private _canvas;
  96777. /**
  96778. * xrpresent context of the canvas which can be used to display/mirror xr content
  96779. */
  96780. canvasContext: Nullable<WebGLRenderingContext>;
  96781. /**
  96782. * Initializes the canvas to be added/removed upon entering/exiting xr
  96783. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  96784. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  96785. */
  96786. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  96787. /**
  96788. * Disposes of the object
  96789. */
  96790. dispose(): void;
  96791. private _setManagedOutputCanvas;
  96792. private _addCanvas;
  96793. private _removeCanvas;
  96794. }
  96795. }
  96796. declare module BABYLON {
  96797. /**
  96798. * Contains an array of blocks representing the octree
  96799. */
  96800. export interface IOctreeContainer<T> {
  96801. /**
  96802. * Blocks within the octree
  96803. */
  96804. blocks: Array<OctreeBlock<T>>;
  96805. }
  96806. /**
  96807. * Class used to store a cell in an octree
  96808. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  96809. */
  96810. export class OctreeBlock<T> {
  96811. /**
  96812. * Gets the content of the current block
  96813. */
  96814. entries: T[];
  96815. /**
  96816. * Gets the list of block children
  96817. */
  96818. blocks: Array<OctreeBlock<T>>;
  96819. private _depth;
  96820. private _maxDepth;
  96821. private _capacity;
  96822. private _minPoint;
  96823. private _maxPoint;
  96824. private _boundingVectors;
  96825. private _creationFunc;
  96826. /**
  96827. * Creates a new block
  96828. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  96829. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  96830. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  96831. * @param depth defines the current depth of this block in the octree
  96832. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  96833. * @param creationFunc defines a callback to call when an element is added to the block
  96834. */
  96835. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  96836. /**
  96837. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  96838. */
  96839. readonly capacity: number;
  96840. /**
  96841. * Gets the minimum vector (in world space) of the block's bounding box
  96842. */
  96843. readonly minPoint: Vector3;
  96844. /**
  96845. * Gets the maximum vector (in world space) of the block's bounding box
  96846. */
  96847. readonly maxPoint: Vector3;
  96848. /**
  96849. * Add a new element to this block
  96850. * @param entry defines the element to add
  96851. */
  96852. addEntry(entry: T): void;
  96853. /**
  96854. * Remove an element from this block
  96855. * @param entry defines the element to remove
  96856. */
  96857. removeEntry(entry: T): void;
  96858. /**
  96859. * Add an array of elements to this block
  96860. * @param entries defines the array of elements to add
  96861. */
  96862. addEntries(entries: T[]): void;
  96863. /**
  96864. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  96865. * @param frustumPlanes defines the frustum planes to test
  96866. * @param selection defines the array to store current content if selection is positive
  96867. * @param allowDuplicate defines if the selection array can contains duplicated entries
  96868. */
  96869. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  96870. /**
  96871. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  96872. * @param sphereCenter defines the bounding sphere center
  96873. * @param sphereRadius defines the bounding sphere radius
  96874. * @param selection defines the array to store current content if selection is positive
  96875. * @param allowDuplicate defines if the selection array can contains duplicated entries
  96876. */
  96877. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  96878. /**
  96879. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  96880. * @param ray defines the ray to test with
  96881. * @param selection defines the array to store current content if selection is positive
  96882. */
  96883. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  96884. /**
  96885. * Subdivide the content into child blocks (this block will then be empty)
  96886. */
  96887. createInnerBlocks(): void;
  96888. /**
  96889. * @hidden
  96890. */
  96891. 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;
  96892. }
  96893. }
  96894. declare module BABYLON {
  96895. /**
  96896. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  96897. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  96898. */
  96899. export class Octree<T> {
  96900. /** 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.) */
  96901. maxDepth: number;
  96902. /**
  96903. * Blocks within the octree containing objects
  96904. */
  96905. blocks: Array<OctreeBlock<T>>;
  96906. /**
  96907. * Content stored in the octree
  96908. */
  96909. dynamicContent: T[];
  96910. private _maxBlockCapacity;
  96911. private _selectionContent;
  96912. private _creationFunc;
  96913. /**
  96914. * Creates a octree
  96915. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  96916. * @param creationFunc function to be used to instatiate the octree
  96917. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  96918. * @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.)
  96919. */
  96920. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  96921. /** 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.) */
  96922. maxDepth?: number);
  96923. /**
  96924. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  96925. * @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);
  96926. * @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);
  96927. * @param entries meshes to be added to the octree blocks
  96928. */
  96929. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  96930. /**
  96931. * Adds a mesh to the octree
  96932. * @param entry Mesh to add to the octree
  96933. */
  96934. addMesh(entry: T): void;
  96935. /**
  96936. * Remove an element from the octree
  96937. * @param entry defines the element to remove
  96938. */
  96939. removeMesh(entry: T): void;
  96940. /**
  96941. * Selects an array of meshes within the frustum
  96942. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  96943. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  96944. * @returns array of meshes within the frustum
  96945. */
  96946. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  96947. /**
  96948. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  96949. * @param sphereCenter defines the bounding sphere center
  96950. * @param sphereRadius defines the bounding sphere radius
  96951. * @param allowDuplicate defines if the selection array can contains duplicated entries
  96952. * @returns an array of objects that intersect the sphere
  96953. */
  96954. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  96955. /**
  96956. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  96957. * @param ray defines the ray to test with
  96958. * @returns array of intersected objects
  96959. */
  96960. intersectsRay(ray: Ray): SmartArray<T>;
  96961. /**
  96962. * Adds a mesh into the octree block if it intersects the block
  96963. */
  96964. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  96965. /**
  96966. * Adds a submesh into the octree block if it intersects the block
  96967. */
  96968. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  96969. }
  96970. }
  96971. declare module BABYLON {
  96972. interface Scene {
  96973. /**
  96974. * @hidden
  96975. * Backing Filed
  96976. */
  96977. _selectionOctree: Octree<AbstractMesh>;
  96978. /**
  96979. * Gets the octree used to boost mesh selection (picking)
  96980. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  96981. */
  96982. selectionOctree: Octree<AbstractMesh>;
  96983. /**
  96984. * Creates or updates the octree used to boost selection (picking)
  96985. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  96986. * @param maxCapacity defines the maximum capacity per leaf
  96987. * @param maxDepth defines the maximum depth of the octree
  96988. * @returns an octree of AbstractMesh
  96989. */
  96990. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  96991. }
  96992. interface AbstractMesh {
  96993. /**
  96994. * @hidden
  96995. * Backing Field
  96996. */
  96997. _submeshesOctree: Octree<SubMesh>;
  96998. /**
  96999. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  97000. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  97001. * @param maxCapacity defines the maximum size of each block (64 by default)
  97002. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  97003. * @returns the new octree
  97004. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  97005. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  97006. */
  97007. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  97008. }
  97009. /**
  97010. * Defines the octree scene component responsible to manage any octrees
  97011. * in a given scene.
  97012. */
  97013. export class OctreeSceneComponent {
  97014. /**
  97015. * The component name helpfull to identify the component in the list of scene components.
  97016. */
  97017. readonly name: string;
  97018. /**
  97019. * The scene the component belongs to.
  97020. */
  97021. scene: Scene;
  97022. /**
  97023. * Indicates if the meshes have been checked to make sure they are isEnabled()
  97024. */
  97025. readonly checksIsEnabled: boolean;
  97026. /**
  97027. * Creates a new instance of the component for the given scene
  97028. * @param scene Defines the scene to register the component in
  97029. */
  97030. constructor(scene: Scene);
  97031. /**
  97032. * Registers the component in a given scene
  97033. */
  97034. register(): void;
  97035. /**
  97036. * Return the list of active meshes
  97037. * @returns the list of active meshes
  97038. */
  97039. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  97040. /**
  97041. * Return the list of active sub meshes
  97042. * @param mesh The mesh to get the candidates sub meshes from
  97043. * @returns the list of active sub meshes
  97044. */
  97045. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  97046. private _tempRay;
  97047. /**
  97048. * Return the list of sub meshes intersecting with a given local ray
  97049. * @param mesh defines the mesh to find the submesh for
  97050. * @param localRay defines the ray in local space
  97051. * @returns the list of intersecting sub meshes
  97052. */
  97053. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  97054. /**
  97055. * Return the list of sub meshes colliding with a collider
  97056. * @param mesh defines the mesh to find the submesh for
  97057. * @param collider defines the collider to evaluate the collision against
  97058. * @returns the list of colliding sub meshes
  97059. */
  97060. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  97061. /**
  97062. * Rebuilds the elements related to this component in case of
  97063. * context lost for instance.
  97064. */
  97065. rebuild(): void;
  97066. /**
  97067. * Disposes the component and the associated ressources.
  97068. */
  97069. dispose(): void;
  97070. }
  97071. }
  97072. declare module BABYLON {
  97073. /**
  97074. * Class containing static functions to help procedurally build meshes
  97075. */
  97076. export class LinesBuilder {
  97077. /**
  97078. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  97079. * * 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
  97080. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  97081. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  97082. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  97083. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  97084. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  97085. * * 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
  97086. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  97087. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  97088. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  97089. * @param name defines the name of the new line system
  97090. * @param options defines the options used to create the line system
  97091. * @param scene defines the hosting scene
  97092. * @returns a new line system mesh
  97093. */
  97094. static CreateLineSystem(name: string, options: {
  97095. lines: Vector3[][];
  97096. updatable?: boolean;
  97097. instance?: Nullable<LinesMesh>;
  97098. colors?: Nullable<Color4[][]>;
  97099. useVertexAlpha?: boolean;
  97100. }, scene: Nullable<Scene>): LinesMesh;
  97101. /**
  97102. * Creates a line mesh
  97103. * 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
  97104. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  97105. * * The parameter `points` is an array successive Vector3
  97106. * * 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
  97107. * * The optional parameter `colors` is an array of successive Color4, one per line point
  97108. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  97109. * * When updating an instance, remember that only point positions can change, not the number of points
  97110. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  97111. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  97112. * @param name defines the name of the new line system
  97113. * @param options defines the options used to create the line system
  97114. * @param scene defines the hosting scene
  97115. * @returns a new line mesh
  97116. */
  97117. static CreateLines(name: string, options: {
  97118. points: Vector3[];
  97119. updatable?: boolean;
  97120. instance?: Nullable<LinesMesh>;
  97121. colors?: Color4[];
  97122. useVertexAlpha?: boolean;
  97123. }, scene?: Nullable<Scene>): LinesMesh;
  97124. /**
  97125. * Creates a dashed line mesh
  97126. * * 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
  97127. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  97128. * * The parameter `points` is an array successive Vector3
  97129. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  97130. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  97131. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  97132. * * 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
  97133. * * When updating an instance, remember that only point positions can change, not the number of points
  97134. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  97135. * @param name defines the name of the mesh
  97136. * @param options defines the options used to create the mesh
  97137. * @param scene defines the hosting scene
  97138. * @returns the dashed line mesh
  97139. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  97140. */
  97141. static CreateDashedLines(name: string, options: {
  97142. points: Vector3[];
  97143. dashSize?: number;
  97144. gapSize?: number;
  97145. dashNb?: number;
  97146. updatable?: boolean;
  97147. instance?: LinesMesh;
  97148. }, scene?: Nullable<Scene>): LinesMesh;
  97149. }
  97150. }
  97151. declare module BABYLON {
  97152. /**
  97153. * Renders a layer on top of an existing scene
  97154. */
  97155. export class UtilityLayerRenderer implements IDisposable {
  97156. /** the original scene that will be rendered on top of */
  97157. originalScene: Scene;
  97158. private _pointerCaptures;
  97159. private _lastPointerEvents;
  97160. private static _DefaultUtilityLayer;
  97161. private static _DefaultKeepDepthUtilityLayer;
  97162. /**
  97163. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  97164. */
  97165. pickUtilitySceneFirst: boolean;
  97166. /**
  97167. * 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)
  97168. */
  97169. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  97170. /**
  97171. * 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)
  97172. */
  97173. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  97174. /**
  97175. * The scene that is rendered on top of the original scene
  97176. */
  97177. utilityLayerScene: Scene;
  97178. /**
  97179. * If the utility layer should automatically be rendered on top of existing scene
  97180. */
  97181. shouldRender: boolean;
  97182. /**
  97183. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  97184. */
  97185. onlyCheckPointerDownEvents: boolean;
  97186. /**
  97187. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  97188. */
  97189. processAllEvents: boolean;
  97190. /**
  97191. * Observable raised when the pointer move from the utility layer scene to the main scene
  97192. */
  97193. onPointerOutObservable: Observable<number>;
  97194. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  97195. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  97196. private _afterRenderObserver;
  97197. private _sceneDisposeObserver;
  97198. private _originalPointerObserver;
  97199. /**
  97200. * Instantiates a UtilityLayerRenderer
  97201. * @param originalScene the original scene that will be rendered on top of
  97202. * @param handleEvents boolean indicating if the utility layer should handle events
  97203. */
  97204. constructor(
  97205. /** the original scene that will be rendered on top of */
  97206. originalScene: Scene, handleEvents?: boolean);
  97207. private _notifyObservers;
  97208. /**
  97209. * Renders the utility layers scene on top of the original scene
  97210. */
  97211. render(): void;
  97212. /**
  97213. * Disposes of the renderer
  97214. */
  97215. dispose(): void;
  97216. private _updateCamera;
  97217. }
  97218. }
  97219. declare module BABYLON {
  97220. /**
  97221. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  97222. */
  97223. export class Gizmo implements IDisposable {
  97224. /** The utility layer the gizmo will be added to */
  97225. gizmoLayer: UtilityLayerRenderer;
  97226. /**
  97227. * The root mesh of the gizmo
  97228. */
  97229. _rootMesh: Mesh;
  97230. private _attachedMesh;
  97231. /**
  97232. * Ratio for the scale of the gizmo (Default: 1)
  97233. */
  97234. scaleRatio: number;
  97235. private _tmpMatrix;
  97236. /**
  97237. * If a custom mesh has been set (Default: false)
  97238. */
  97239. protected _customMeshSet: boolean;
  97240. /**
  97241. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  97242. * * When set, interactions will be enabled
  97243. */
  97244. attachedMesh: Nullable<AbstractMesh>;
  97245. /**
  97246. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  97247. * @param mesh The mesh to replace the default mesh of the gizmo
  97248. */
  97249. setCustomMesh(mesh: Mesh): void;
  97250. /**
  97251. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  97252. */
  97253. updateGizmoRotationToMatchAttachedMesh: boolean;
  97254. /**
  97255. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  97256. */
  97257. updateGizmoPositionToMatchAttachedMesh: boolean;
  97258. /**
  97259. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  97260. */
  97261. protected _updateScale: boolean;
  97262. protected _interactionsEnabled: boolean;
  97263. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  97264. private _beforeRenderObserver;
  97265. /**
  97266. * Creates a gizmo
  97267. * @param gizmoLayer The utility layer the gizmo will be added to
  97268. */
  97269. constructor(
  97270. /** The utility layer the gizmo will be added to */
  97271. gizmoLayer?: UtilityLayerRenderer);
  97272. private _tempVector;
  97273. /**
  97274. * @hidden
  97275. * Updates the gizmo to match the attached mesh's position/rotation
  97276. */
  97277. protected _update(): void;
  97278. /**
  97279. * Disposes of the gizmo
  97280. */
  97281. dispose(): void;
  97282. }
  97283. }
  97284. declare module BABYLON {
  97285. /**
  97286. * Single axis drag gizmo
  97287. */
  97288. export class AxisDragGizmo extends Gizmo {
  97289. /**
  97290. * Drag behavior responsible for the gizmos dragging interactions
  97291. */
  97292. dragBehavior: PointerDragBehavior;
  97293. private _pointerObserver;
  97294. /**
  97295. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  97296. */
  97297. snapDistance: number;
  97298. /**
  97299. * Event that fires each time the gizmo snaps to a new location.
  97300. * * snapDistance is the the change in distance
  97301. */
  97302. onSnapObservable: Observable<{
  97303. snapDistance: number;
  97304. }>;
  97305. /** @hidden */
  97306. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  97307. /** @hidden */
  97308. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  97309. /**
  97310. * Creates an AxisDragGizmo
  97311. * @param gizmoLayer The utility layer the gizmo will be added to
  97312. * @param dragAxis The axis which the gizmo will be able to drag on
  97313. * @param color The color of the gizmo
  97314. */
  97315. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  97316. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  97317. /**
  97318. * Disposes of the gizmo
  97319. */
  97320. dispose(): void;
  97321. }
  97322. }
  97323. declare module BABYLON.Debug {
  97324. /**
  97325. * The Axes viewer will show 3 axes in a specific point in space
  97326. */
  97327. export class AxesViewer {
  97328. private _xAxis;
  97329. private _yAxis;
  97330. private _zAxis;
  97331. private _scaleLinesFactor;
  97332. private _instanced;
  97333. /**
  97334. * Gets the hosting scene
  97335. */
  97336. scene: Scene;
  97337. /**
  97338. * Gets or sets a number used to scale line length
  97339. */
  97340. scaleLines: number;
  97341. /** Gets the node hierarchy used to render x-axis */
  97342. readonly xAxis: TransformNode;
  97343. /** Gets the node hierarchy used to render y-axis */
  97344. readonly yAxis: TransformNode;
  97345. /** Gets the node hierarchy used to render z-axis */
  97346. readonly zAxis: TransformNode;
  97347. /**
  97348. * Creates a new AxesViewer
  97349. * @param scene defines the hosting scene
  97350. * @param scaleLines defines a number used to scale line length (1 by default)
  97351. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  97352. * @param xAxis defines the node hierarchy used to render the x-axis
  97353. * @param yAxis defines the node hierarchy used to render the y-axis
  97354. * @param zAxis defines the node hierarchy used to render the z-axis
  97355. */
  97356. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  97357. /**
  97358. * Force the viewer to update
  97359. * @param position defines the position of the viewer
  97360. * @param xaxis defines the x axis of the viewer
  97361. * @param yaxis defines the y axis of the viewer
  97362. * @param zaxis defines the z axis of the viewer
  97363. */
  97364. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  97365. /**
  97366. * Creates an instance of this axes viewer.
  97367. * @returns a new axes viewer with instanced meshes
  97368. */
  97369. createInstance(): AxesViewer;
  97370. /** Releases resources */
  97371. dispose(): void;
  97372. private static _SetRenderingGroupId;
  97373. }
  97374. }
  97375. declare module BABYLON.Debug {
  97376. /**
  97377. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  97378. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  97379. */
  97380. export class BoneAxesViewer extends AxesViewer {
  97381. /**
  97382. * Gets or sets the target mesh where to display the axes viewer
  97383. */
  97384. mesh: Nullable<Mesh>;
  97385. /**
  97386. * Gets or sets the target bone where to display the axes viewer
  97387. */
  97388. bone: Nullable<Bone>;
  97389. /** Gets current position */
  97390. pos: Vector3;
  97391. /** Gets direction of X axis */
  97392. xaxis: Vector3;
  97393. /** Gets direction of Y axis */
  97394. yaxis: Vector3;
  97395. /** Gets direction of Z axis */
  97396. zaxis: Vector3;
  97397. /**
  97398. * Creates a new BoneAxesViewer
  97399. * @param scene defines the hosting scene
  97400. * @param bone defines the target bone
  97401. * @param mesh defines the target mesh
  97402. * @param scaleLines defines a scaling factor for line length (1 by default)
  97403. */
  97404. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  97405. /**
  97406. * Force the viewer to update
  97407. */
  97408. update(): void;
  97409. /** Releases resources */
  97410. dispose(): void;
  97411. }
  97412. }
  97413. declare module BABYLON {
  97414. /**
  97415. * Interface used to define scene explorer extensibility option
  97416. */
  97417. export interface IExplorerExtensibilityOption {
  97418. /**
  97419. * Define the option label
  97420. */
  97421. label: string;
  97422. /**
  97423. * Defines the action to execute on click
  97424. */
  97425. action: (entity: any) => void;
  97426. }
  97427. /**
  97428. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  97429. */
  97430. export interface IExplorerExtensibilityGroup {
  97431. /**
  97432. * Defines a predicate to test if a given type mut be extended
  97433. */
  97434. predicate: (entity: any) => boolean;
  97435. /**
  97436. * Gets the list of options added to a type
  97437. */
  97438. entries: IExplorerExtensibilityOption[];
  97439. }
  97440. /**
  97441. * Interface used to define the options to use to create the Inspector
  97442. */
  97443. export interface IInspectorOptions {
  97444. /**
  97445. * Display in overlay mode (default: false)
  97446. */
  97447. overlay?: boolean;
  97448. /**
  97449. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  97450. */
  97451. globalRoot?: HTMLElement;
  97452. /**
  97453. * Display the Scene explorer
  97454. */
  97455. showExplorer?: boolean;
  97456. /**
  97457. * Display the property inspector
  97458. */
  97459. showInspector?: boolean;
  97460. /**
  97461. * Display in embed mode (both panes on the right)
  97462. */
  97463. embedMode?: boolean;
  97464. /**
  97465. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  97466. */
  97467. handleResize?: boolean;
  97468. /**
  97469. * Allow the panes to popup (default: true)
  97470. */
  97471. enablePopup?: boolean;
  97472. /**
  97473. * Allow the panes to be closed by users (default: true)
  97474. */
  97475. enableClose?: boolean;
  97476. /**
  97477. * Optional list of extensibility entries
  97478. */
  97479. explorerExtensibility?: IExplorerExtensibilityGroup[];
  97480. /**
  97481. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  97482. */
  97483. inspectorURL?: string;
  97484. }
  97485. interface Scene {
  97486. /**
  97487. * @hidden
  97488. * Backing field
  97489. */
  97490. _debugLayer: DebugLayer;
  97491. /**
  97492. * Gets the debug layer (aka Inspector) associated with the scene
  97493. * @see http://doc.babylonjs.com/features/playground_debuglayer
  97494. */
  97495. debugLayer: DebugLayer;
  97496. }
  97497. /**
  97498. * The debug layer (aka Inspector) is the go to tool in order to better understand
  97499. * what is happening in your scene
  97500. * @see http://doc.babylonjs.com/features/playground_debuglayer
  97501. */
  97502. export class DebugLayer {
  97503. /**
  97504. * Define the url to get the inspector script from.
  97505. * By default it uses the babylonjs CDN.
  97506. * @ignoreNaming
  97507. */
  97508. static InspectorURL: string;
  97509. private _scene;
  97510. private BJSINSPECTOR;
  97511. /**
  97512. * Observable triggered when a property is changed through the inspector.
  97513. */
  97514. onPropertyChangedObservable: Observable<{
  97515. object: any;
  97516. property: string;
  97517. value: any;
  97518. initialValue: any;
  97519. }>;
  97520. /**
  97521. * Instantiates a new debug layer.
  97522. * The debug layer (aka Inspector) is the go to tool in order to better understand
  97523. * what is happening in your scene
  97524. * @see http://doc.babylonjs.com/features/playground_debuglayer
  97525. * @param scene Defines the scene to inspect
  97526. */
  97527. constructor(scene: Scene);
  97528. /** Creates the inspector window. */
  97529. private _createInspector;
  97530. /**
  97531. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  97532. * @param entity defines the entity to select
  97533. * @param lineContainerTitle defines the specific block to highlight
  97534. */
  97535. select(entity: any, lineContainerTitle?: string): void;
  97536. /** Get the inspector from bundle or global */
  97537. private _getGlobalInspector;
  97538. /**
  97539. * Get if the inspector is visible or not.
  97540. * @returns true if visible otherwise, false
  97541. */
  97542. isVisible(): boolean;
  97543. /**
  97544. * Hide the inspector and close its window.
  97545. */
  97546. hide(): void;
  97547. /**
  97548. * Launch the debugLayer.
  97549. * @param config Define the configuration of the inspector
  97550. * @return a promise fulfilled when the debug layer is visible
  97551. */
  97552. show(config?: IInspectorOptions): Promise<DebugLayer>;
  97553. }
  97554. }
  97555. declare module BABYLON {
  97556. /**
  97557. * Class containing static functions to help procedurally build meshes
  97558. */
  97559. export class BoxBuilder {
  97560. /**
  97561. * Creates a box mesh
  97562. * * The parameter `size` sets the size (float) of each box side (default 1)
  97563. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  97564. * * 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)
  97565. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  97566. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  97567. * * If you create a double-sided mesh, you can choose what parts of 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
  97568. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  97569. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  97570. * @param name defines the name of the mesh
  97571. * @param options defines the options used to create the mesh
  97572. * @param scene defines the hosting scene
  97573. * @returns the box mesh
  97574. */
  97575. static CreateBox(name: string, options: {
  97576. size?: number;
  97577. width?: number;
  97578. height?: number;
  97579. depth?: number;
  97580. faceUV?: Vector4[];
  97581. faceColors?: Color4[];
  97582. sideOrientation?: number;
  97583. frontUVs?: Vector4;
  97584. backUVs?: Vector4;
  97585. updatable?: boolean;
  97586. }, scene?: Nullable<Scene>): Mesh;
  97587. }
  97588. }
  97589. declare module BABYLON {
  97590. /**
  97591. * Class containing static functions to help procedurally build meshes
  97592. */
  97593. export class SphereBuilder {
  97594. /**
  97595. * Creates a sphere mesh
  97596. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  97597. * * 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`)
  97598. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  97599. * * 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
  97600. * * 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)
  97601. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  97602. * * If you create a double-sided mesh, you can choose what parts of 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
  97603. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  97604. * @param name defines the name of the mesh
  97605. * @param options defines the options used to create the mesh
  97606. * @param scene defines the hosting scene
  97607. * @returns the sphere mesh
  97608. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  97609. */
  97610. static CreateSphere(name: string, options: {
  97611. segments?: number;
  97612. diameter?: number;
  97613. diameterX?: number;
  97614. diameterY?: number;
  97615. diameterZ?: number;
  97616. arc?: number;
  97617. slice?: number;
  97618. sideOrientation?: number;
  97619. frontUVs?: Vector4;
  97620. backUVs?: Vector4;
  97621. updatable?: boolean;
  97622. }, scene: any): Mesh;
  97623. }
  97624. }
  97625. declare module BABYLON.Debug {
  97626. /**
  97627. * Used to show the physics impostor around the specific mesh
  97628. */
  97629. export class PhysicsViewer {
  97630. /** @hidden */
  97631. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  97632. /** @hidden */
  97633. protected _meshes: Array<Nullable<AbstractMesh>>;
  97634. /** @hidden */
  97635. protected _scene: Nullable<Scene>;
  97636. /** @hidden */
  97637. protected _numMeshes: number;
  97638. /** @hidden */
  97639. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  97640. private _renderFunction;
  97641. private _utilityLayer;
  97642. private _debugBoxMesh;
  97643. private _debugSphereMesh;
  97644. private _debugMaterial;
  97645. /**
  97646. * Creates a new PhysicsViewer
  97647. * @param scene defines the hosting scene
  97648. */
  97649. constructor(scene: Scene);
  97650. /** @hidden */
  97651. protected _updateDebugMeshes(): void;
  97652. /**
  97653. * Renders a specified physic impostor
  97654. * @param impostor defines the impostor to render
  97655. * @returns the new debug mesh used to render the impostor
  97656. */
  97657. showImpostor(impostor: PhysicsImpostor): Nullable<AbstractMesh>;
  97658. /**
  97659. * Hides a specified physic impostor
  97660. * @param impostor defines the impostor to hide
  97661. */
  97662. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  97663. private _getDebugMaterial;
  97664. private _getDebugBoxMesh;
  97665. private _getDebugSphereMesh;
  97666. private _getDebugMesh;
  97667. /** Releases all resources */
  97668. dispose(): void;
  97669. }
  97670. }
  97671. declare module BABYLON {
  97672. /**
  97673. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  97674. * in order to better appreciate the issue one might have.
  97675. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  97676. */
  97677. export class RayHelper {
  97678. /**
  97679. * Defines the ray we are currently tryin to visualize.
  97680. */
  97681. ray: Nullable<Ray>;
  97682. private _renderPoints;
  97683. private _renderLine;
  97684. private _renderFunction;
  97685. private _scene;
  97686. private _updateToMeshFunction;
  97687. private _attachedToMesh;
  97688. private _meshSpaceDirection;
  97689. private _meshSpaceOrigin;
  97690. /**
  97691. * Helper function to create a colored helper in a scene in one line.
  97692. * @param ray Defines the ray we are currently tryin to visualize
  97693. * @param scene Defines the scene the ray is used in
  97694. * @param color Defines the color we want to see the ray in
  97695. * @returns The newly created ray helper.
  97696. */
  97697. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  97698. /**
  97699. * Instantiate a new ray helper.
  97700. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  97701. * in order to better appreciate the issue one might have.
  97702. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  97703. * @param ray Defines the ray we are currently tryin to visualize
  97704. */
  97705. constructor(ray: Ray);
  97706. /**
  97707. * Shows the ray we are willing to debug.
  97708. * @param scene Defines the scene the ray needs to be rendered in
  97709. * @param color Defines the color the ray needs to be rendered in
  97710. */
  97711. show(scene: Scene, color?: Color3): void;
  97712. /**
  97713. * Hides the ray we are debugging.
  97714. */
  97715. hide(): void;
  97716. private _render;
  97717. /**
  97718. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  97719. * @param mesh Defines the mesh we want the helper attached to
  97720. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  97721. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  97722. * @param length Defines the length of the ray
  97723. */
  97724. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  97725. /**
  97726. * Detach the ray helper from the mesh it has previously been attached to.
  97727. */
  97728. detachFromMesh(): void;
  97729. private _updateToMesh;
  97730. /**
  97731. * Dispose the helper and release its associated resources.
  97732. */
  97733. dispose(): void;
  97734. }
  97735. }
  97736. declare module BABYLON.Debug {
  97737. /**
  97738. * Class used to render a debug view of a given skeleton
  97739. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  97740. */
  97741. export class SkeletonViewer {
  97742. /** defines the skeleton to render */
  97743. skeleton: Skeleton;
  97744. /** defines the mesh attached to the skeleton */
  97745. mesh: AbstractMesh;
  97746. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  97747. autoUpdateBonesMatrices: boolean;
  97748. /** defines the rendering group id to use with the viewer */
  97749. renderingGroupId: number;
  97750. /** Gets or sets the color used to render the skeleton */
  97751. color: Color3;
  97752. private _scene;
  97753. private _debugLines;
  97754. private _debugMesh;
  97755. private _isEnabled;
  97756. private _renderFunction;
  97757. private _utilityLayer;
  97758. /**
  97759. * Returns the mesh used to render the bones
  97760. */
  97761. readonly debugMesh: Nullable<LinesMesh>;
  97762. /**
  97763. * Creates a new SkeletonViewer
  97764. * @param skeleton defines the skeleton to render
  97765. * @param mesh defines the mesh attached to the skeleton
  97766. * @param scene defines the hosting scene
  97767. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  97768. * @param renderingGroupId defines the rendering group id to use with the viewer
  97769. */
  97770. constructor(
  97771. /** defines the skeleton to render */
  97772. skeleton: Skeleton,
  97773. /** defines the mesh attached to the skeleton */
  97774. mesh: AbstractMesh, scene: Scene,
  97775. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  97776. autoUpdateBonesMatrices?: boolean,
  97777. /** defines the rendering group id to use with the viewer */
  97778. renderingGroupId?: number);
  97779. /** Gets or sets a boolean indicating if the viewer is enabled */
  97780. isEnabled: boolean;
  97781. private _getBonePosition;
  97782. private _getLinesForBonesWithLength;
  97783. private _getLinesForBonesNoLength;
  97784. /** Update the viewer to sync with current skeleton state */
  97785. update(): void;
  97786. /** Release associated resources */
  97787. dispose(): void;
  97788. }
  97789. }
  97790. declare module BABYLON {
  97791. /**
  97792. * Options to create the null engine
  97793. */
  97794. export class NullEngineOptions {
  97795. /**
  97796. * Render width (Default: 512)
  97797. */
  97798. renderWidth: number;
  97799. /**
  97800. * Render height (Default: 256)
  97801. */
  97802. renderHeight: number;
  97803. /**
  97804. * Texture size (Default: 512)
  97805. */
  97806. textureSize: number;
  97807. /**
  97808. * If delta time between frames should be constant
  97809. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  97810. */
  97811. deterministicLockstep: boolean;
  97812. /**
  97813. * Maximum about of steps between frames (Default: 4)
  97814. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  97815. */
  97816. lockstepMaxSteps: number;
  97817. }
  97818. /**
  97819. * The null engine class provides support for headless version of babylon.js.
  97820. * This can be used in server side scenario or for testing purposes
  97821. */
  97822. export class NullEngine extends Engine {
  97823. private _options;
  97824. /**
  97825. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  97826. */
  97827. isDeterministicLockStep(): boolean;
  97828. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  97829. getLockstepMaxSteps(): number;
  97830. /**
  97831. * Sets hardware scaling, used to save performance if needed
  97832. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  97833. */
  97834. getHardwareScalingLevel(): number;
  97835. constructor(options?: NullEngineOptions);
  97836. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  97837. createIndexBuffer(indices: IndicesArray): WebGLBuffer;
  97838. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  97839. getRenderWidth(useScreen?: boolean): number;
  97840. getRenderHeight(useScreen?: boolean): number;
  97841. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  97842. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  97843. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  97844. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  97845. bindSamplers(effect: Effect): void;
  97846. enableEffect(effect: Effect): void;
  97847. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  97848. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  97849. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  97850. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  97851. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  97852. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  97853. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  97854. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  97855. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  97856. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  97857. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  97858. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  97859. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  97860. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  97861. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  97862. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  97863. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  97864. setFloat(uniform: WebGLUniformLocation, value: number): void;
  97865. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  97866. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  97867. setBool(uniform: WebGLUniformLocation, bool: number): void;
  97868. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  97869. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  97870. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  97871. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  97872. bindBuffers(vertexBuffers: {
  97873. [key: string]: VertexBuffer;
  97874. }, indexBuffer: WebGLBuffer, effect: Effect): void;
  97875. wipeCaches(bruteForce?: boolean): void;
  97876. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  97877. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  97878. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  97879. /** @hidden */
  97880. _createTexture(): WebGLTexture;
  97881. /** @hidden */
  97882. _releaseTexture(texture: InternalTexture): void;
  97883. 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;
  97884. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  97885. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  97886. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  97887. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  97888. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  97889. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  97890. areAllEffectsReady(): boolean;
  97891. /**
  97892. * @hidden
  97893. * Get the current error code of the webGL context
  97894. * @returns the error code
  97895. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  97896. */
  97897. getError(): number;
  97898. /** @hidden */
  97899. _getUnpackAlignement(): number;
  97900. /** @hidden */
  97901. _unpackFlipY(value: boolean): void;
  97902. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  97903. /**
  97904. * Updates a dynamic vertex buffer.
  97905. * @param vertexBuffer the vertex buffer to update
  97906. * @param data the data used to update the vertex buffer
  97907. * @param byteOffset the byte offset of the data (optional)
  97908. * @param byteLength the byte length of the data (optional)
  97909. */
  97910. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  97911. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  97912. /** @hidden */
  97913. _bindTexture(channel: number, texture: InternalTexture): void;
  97914. /** @hidden */
  97915. _releaseBuffer(buffer: WebGLBuffer): boolean;
  97916. releaseEffects(): void;
  97917. displayLoadingUI(): void;
  97918. hideLoadingUI(): void;
  97919. /** @hidden */
  97920. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  97921. /** @hidden */
  97922. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  97923. /** @hidden */
  97924. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  97925. /** @hidden */
  97926. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  97927. }
  97928. }
  97929. declare module BABYLON {
  97930. /** @hidden */
  97931. export class _OcclusionDataStorage {
  97932. /** @hidden */
  97933. occlusionInternalRetryCounter: number;
  97934. /** @hidden */
  97935. isOcclusionQueryInProgress: boolean;
  97936. /** @hidden */
  97937. isOccluded: boolean;
  97938. /** @hidden */
  97939. occlusionRetryCount: number;
  97940. /** @hidden */
  97941. occlusionType: number;
  97942. /** @hidden */
  97943. occlusionQueryAlgorithmType: number;
  97944. }
  97945. interface Engine {
  97946. /**
  97947. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  97948. * @return the new query
  97949. */
  97950. createQuery(): WebGLQuery;
  97951. /**
  97952. * Delete and release a webGL query
  97953. * @param query defines the query to delete
  97954. * @return the current engine
  97955. */
  97956. deleteQuery(query: WebGLQuery): Engine;
  97957. /**
  97958. * Check if a given query has resolved and got its value
  97959. * @param query defines the query to check
  97960. * @returns true if the query got its value
  97961. */
  97962. isQueryResultAvailable(query: WebGLQuery): boolean;
  97963. /**
  97964. * Gets the value of a given query
  97965. * @param query defines the query to check
  97966. * @returns the value of the query
  97967. */
  97968. getQueryResult(query: WebGLQuery): number;
  97969. /**
  97970. * Initiates an occlusion query
  97971. * @param algorithmType defines the algorithm to use
  97972. * @param query defines the query to use
  97973. * @returns the current engine
  97974. * @see http://doc.babylonjs.com/features/occlusionquery
  97975. */
  97976. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  97977. /**
  97978. * Ends an occlusion query
  97979. * @see http://doc.babylonjs.com/features/occlusionquery
  97980. * @param algorithmType defines the algorithm to use
  97981. * @returns the current engine
  97982. */
  97983. endOcclusionQuery(algorithmType: number): Engine;
  97984. /**
  97985. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  97986. * Please note that only one query can be issued at a time
  97987. * @returns a time token used to track the time span
  97988. */
  97989. startTimeQuery(): Nullable<_TimeToken>;
  97990. /**
  97991. * Ends a time query
  97992. * @param token defines the token used to measure the time span
  97993. * @returns the time spent (in ns)
  97994. */
  97995. endTimeQuery(token: _TimeToken): int;
  97996. /** @hidden */
  97997. _currentNonTimestampToken: Nullable<_TimeToken>;
  97998. /** @hidden */
  97999. _createTimeQuery(): WebGLQuery;
  98000. /** @hidden */
  98001. _deleteTimeQuery(query: WebGLQuery): void;
  98002. /** @hidden */
  98003. _getGlAlgorithmType(algorithmType: number): number;
  98004. /** @hidden */
  98005. _getTimeQueryResult(query: WebGLQuery): any;
  98006. /** @hidden */
  98007. _getTimeQueryAvailability(query: WebGLQuery): any;
  98008. }
  98009. interface AbstractMesh {
  98010. /**
  98011. * Backing filed
  98012. * @hidden
  98013. */
  98014. __occlusionDataStorage: _OcclusionDataStorage;
  98015. /**
  98016. * Access property
  98017. * @hidden
  98018. */
  98019. _occlusionDataStorage: _OcclusionDataStorage;
  98020. /**
  98021. * 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.
  98022. * The default value is -1 which means don't break the query and wait till the result
  98023. * @see http://doc.babylonjs.com/features/occlusionquery
  98024. */
  98025. occlusionRetryCount: number;
  98026. /**
  98027. * 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:
  98028. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  98029. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  98030. * * 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.
  98031. * @see http://doc.babylonjs.com/features/occlusionquery
  98032. */
  98033. occlusionType: number;
  98034. /**
  98035. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  98036. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  98037. * * 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.
  98038. * @see http://doc.babylonjs.com/features/occlusionquery
  98039. */
  98040. occlusionQueryAlgorithmType: number;
  98041. /**
  98042. * 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
  98043. * @see http://doc.babylonjs.com/features/occlusionquery
  98044. */
  98045. isOccluded: boolean;
  98046. /**
  98047. * Flag to check the progress status of the query
  98048. * @see http://doc.babylonjs.com/features/occlusionquery
  98049. */
  98050. isOcclusionQueryInProgress: boolean;
  98051. }
  98052. }
  98053. declare module BABYLON {
  98054. /** @hidden */
  98055. export var _forceTransformFeedbackToBundle: boolean;
  98056. interface Engine {
  98057. /**
  98058. * Creates a webGL transform feedback object
  98059. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  98060. * @returns the webGL transform feedback object
  98061. */
  98062. createTransformFeedback(): WebGLTransformFeedback;
  98063. /**
  98064. * Delete a webGL transform feedback object
  98065. * @param value defines the webGL transform feedback object to delete
  98066. */
  98067. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  98068. /**
  98069. * Bind a webGL transform feedback object to the webgl context
  98070. * @param value defines the webGL transform feedback object to bind
  98071. */
  98072. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  98073. /**
  98074. * Begins a transform feedback operation
  98075. * @param usePoints defines if points or triangles must be used
  98076. */
  98077. beginTransformFeedback(usePoints: boolean): void;
  98078. /**
  98079. * Ends a transform feedback operation
  98080. */
  98081. endTransformFeedback(): void;
  98082. /**
  98083. * Specify the varyings to use with transform feedback
  98084. * @param program defines the associated webGL program
  98085. * @param value defines the list of strings representing the varying names
  98086. */
  98087. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  98088. /**
  98089. * Bind a webGL buffer for a transform feedback operation
  98090. * @param value defines the webGL buffer to bind
  98091. */
  98092. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  98093. }
  98094. }
  98095. declare module BABYLON {
  98096. /**
  98097. * Gather the list of clipboard event types as constants.
  98098. */
  98099. export class ClipboardEventTypes {
  98100. /**
  98101. * The clipboard event is fired when a copy command is active (pressed).
  98102. */
  98103. static readonly COPY: number;
  98104. /**
  98105. * The clipboard event is fired when a cut command is active (pressed).
  98106. */
  98107. static readonly CUT: number;
  98108. /**
  98109. * The clipboard event is fired when a paste command is active (pressed).
  98110. */
  98111. static readonly PASTE: number;
  98112. }
  98113. /**
  98114. * This class is used to store clipboard related info for the onClipboardObservable event.
  98115. */
  98116. export class ClipboardInfo {
  98117. /**
  98118. * Defines the type of event (BABYLON.ClipboardEventTypes)
  98119. */
  98120. type: number;
  98121. /**
  98122. * Defines the related dom event
  98123. */
  98124. event: ClipboardEvent;
  98125. /**
  98126. *Creates an instance of ClipboardInfo.
  98127. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  98128. * @param event Defines the related dom event
  98129. */
  98130. constructor(
  98131. /**
  98132. * Defines the type of event (BABYLON.ClipboardEventTypes)
  98133. */
  98134. type: number,
  98135. /**
  98136. * Defines the related dom event
  98137. */
  98138. event: ClipboardEvent);
  98139. /**
  98140. * Get the clipboard event's type from the keycode.
  98141. * @param keyCode Defines the keyCode for the current keyboard event.
  98142. * @return {number}
  98143. */
  98144. static GetTypeFromCharacter(keyCode: number): number;
  98145. }
  98146. }
  98147. declare module BABYLON {
  98148. /**
  98149. * Class used to represent data loading progression
  98150. */
  98151. export class SceneLoaderProgressEvent {
  98152. /** defines if data length to load can be evaluated */
  98153. readonly lengthComputable: boolean;
  98154. /** defines the loaded data length */
  98155. readonly loaded: number;
  98156. /** defines the data length to load */
  98157. readonly total: number;
  98158. /**
  98159. * Create a new progress event
  98160. * @param lengthComputable defines if data length to load can be evaluated
  98161. * @param loaded defines the loaded data length
  98162. * @param total defines the data length to load
  98163. */
  98164. constructor(
  98165. /** defines if data length to load can be evaluated */
  98166. lengthComputable: boolean,
  98167. /** defines the loaded data length */
  98168. loaded: number,
  98169. /** defines the data length to load */
  98170. total: number);
  98171. /**
  98172. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  98173. * @param event defines the source event
  98174. * @returns a new SceneLoaderProgressEvent
  98175. */
  98176. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  98177. }
  98178. /**
  98179. * Interface used by SceneLoader plugins to define supported file extensions
  98180. */
  98181. export interface ISceneLoaderPluginExtensions {
  98182. /**
  98183. * Defines the list of supported extensions
  98184. */
  98185. [extension: string]: {
  98186. isBinary: boolean;
  98187. };
  98188. }
  98189. /**
  98190. * Interface used by SceneLoader plugin factory
  98191. */
  98192. export interface ISceneLoaderPluginFactory {
  98193. /**
  98194. * Defines the name of the factory
  98195. */
  98196. name: string;
  98197. /**
  98198. * Function called to create a new plugin
  98199. * @return the new plugin
  98200. */
  98201. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  98202. /**
  98203. * Boolean indicating if the plugin can direct load specific data
  98204. */
  98205. canDirectLoad?: (data: string) => boolean;
  98206. }
  98207. /**
  98208. * Interface used to define a SceneLoader plugin
  98209. */
  98210. export interface ISceneLoaderPlugin {
  98211. /**
  98212. * The friendly name of this plugin.
  98213. */
  98214. name: string;
  98215. /**
  98216. * The file extensions supported by this plugin.
  98217. */
  98218. extensions: string | ISceneLoaderPluginExtensions;
  98219. /**
  98220. * Import meshes into a scene.
  98221. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  98222. * @param scene The scene to import into
  98223. * @param data The data to import
  98224. * @param rootUrl The root url for scene and resources
  98225. * @param meshes The meshes array to import into
  98226. * @param particleSystems The particle systems array to import into
  98227. * @param skeletons The skeletons array to import into
  98228. * @param onError The callback when import fails
  98229. * @returns True if successful or false otherwise
  98230. */
  98231. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  98232. /**
  98233. * Load into a scene.
  98234. * @param scene The scene to load into
  98235. * @param data The data to import
  98236. * @param rootUrl The root url for scene and resources
  98237. * @param onError The callback when import fails
  98238. * @returns true if successful or false otherwise
  98239. */
  98240. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  98241. /**
  98242. * The callback that returns true if the data can be directly loaded.
  98243. */
  98244. canDirectLoad?: (data: string) => boolean;
  98245. /**
  98246. * The callback that allows custom handling of the root url based on the response url.
  98247. */
  98248. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  98249. /**
  98250. * Load into an asset container.
  98251. * @param scene The scene to load into
  98252. * @param data The data to import
  98253. * @param rootUrl The root url for scene and resources
  98254. * @param onError The callback when import fails
  98255. * @returns The loaded asset container
  98256. */
  98257. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  98258. }
  98259. /**
  98260. * Interface used to define an async SceneLoader plugin
  98261. */
  98262. export interface ISceneLoaderPluginAsync {
  98263. /**
  98264. * The friendly name of this plugin.
  98265. */
  98266. name: string;
  98267. /**
  98268. * The file extensions supported by this plugin.
  98269. */
  98270. extensions: string | ISceneLoaderPluginExtensions;
  98271. /**
  98272. * Import meshes into a scene.
  98273. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  98274. * @param scene The scene to import into
  98275. * @param data The data to import
  98276. * @param rootUrl The root url for scene and resources
  98277. * @param onProgress The callback when the load progresses
  98278. * @param fileName Defines the name of the file to load
  98279. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  98280. */
  98281. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  98282. meshes: AbstractMesh[];
  98283. particleSystems: IParticleSystem[];
  98284. skeletons: Skeleton[];
  98285. animationGroups: AnimationGroup[];
  98286. }>;
  98287. /**
  98288. * Load into a scene.
  98289. * @param scene The scene to load into
  98290. * @param data The data to import
  98291. * @param rootUrl The root url for scene and resources
  98292. * @param onProgress The callback when the load progresses
  98293. * @param fileName Defines the name of the file to load
  98294. * @returns Nothing
  98295. */
  98296. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  98297. /**
  98298. * The callback that returns true if the data can be directly loaded.
  98299. */
  98300. canDirectLoad?: (data: string) => boolean;
  98301. /**
  98302. * The callback that allows custom handling of the root url based on the response url.
  98303. */
  98304. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  98305. /**
  98306. * Load into an asset container.
  98307. * @param scene The scene to load into
  98308. * @param data The data to import
  98309. * @param rootUrl The root url for scene and resources
  98310. * @param onProgress The callback when the load progresses
  98311. * @param fileName Defines the name of the file to load
  98312. * @returns The loaded asset container
  98313. */
  98314. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  98315. }
  98316. /**
  98317. * Class used to load scene from various file formats using registered plugins
  98318. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  98319. */
  98320. export class SceneLoader {
  98321. /**
  98322. * No logging while loading
  98323. */
  98324. static readonly NO_LOGGING: number;
  98325. /**
  98326. * Minimal logging while loading
  98327. */
  98328. static readonly MINIMAL_LOGGING: number;
  98329. /**
  98330. * Summary logging while loading
  98331. */
  98332. static readonly SUMMARY_LOGGING: number;
  98333. /**
  98334. * Detailled logging while loading
  98335. */
  98336. static readonly DETAILED_LOGGING: number;
  98337. /**
  98338. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  98339. */
  98340. static ForceFullSceneLoadingForIncremental: boolean;
  98341. /**
  98342. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  98343. */
  98344. static ShowLoadingScreen: boolean;
  98345. /**
  98346. * Defines the current logging level (while loading the scene)
  98347. * @ignorenaming
  98348. */
  98349. static loggingLevel: number;
  98350. /**
  98351. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  98352. */
  98353. static CleanBoneMatrixWeights: boolean;
  98354. /**
  98355. * Event raised when a plugin is used to load a scene
  98356. */
  98357. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  98358. private static _registeredPlugins;
  98359. private static _getDefaultPlugin;
  98360. private static _getPluginForExtension;
  98361. private static _getPluginForDirectLoad;
  98362. private static _getPluginForFilename;
  98363. private static _getDirectLoad;
  98364. private static _loadData;
  98365. private static _getFileInfo;
  98366. /**
  98367. * Gets a plugin that can load the given extension
  98368. * @param extension defines the extension to load
  98369. * @returns a plugin or null if none works
  98370. */
  98371. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  98372. /**
  98373. * Gets a boolean indicating that the given extension can be loaded
  98374. * @param extension defines the extension to load
  98375. * @returns true if the extension is supported
  98376. */
  98377. static IsPluginForExtensionAvailable(extension: string): boolean;
  98378. /**
  98379. * Adds a new plugin to the list of registered plugins
  98380. * @param plugin defines the plugin to add
  98381. */
  98382. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  98383. /**
  98384. * Import meshes into a scene
  98385. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  98386. * @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)
  98387. * @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)
  98388. * @param scene the instance of BABYLON.Scene to append to
  98389. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  98390. * @param onProgress a callback with a progress event for each file being loaded
  98391. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  98392. * @param pluginExtension the extension used to determine the plugin
  98393. * @returns The loaded plugin
  98394. */
  98395. 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>;
  98396. /**
  98397. * Import meshes into a scene
  98398. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  98399. * @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)
  98400. * @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)
  98401. * @param scene the instance of BABYLON.Scene to append to
  98402. * @param onProgress a callback with a progress event for each file being loaded
  98403. * @param pluginExtension the extension used to determine the plugin
  98404. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  98405. */
  98406. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  98407. meshes: AbstractMesh[];
  98408. particleSystems: IParticleSystem[];
  98409. skeletons: Skeleton[];
  98410. animationGroups: AnimationGroup[];
  98411. }>;
  98412. /**
  98413. * Load a scene
  98414. * @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)
  98415. * @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)
  98416. * @param engine is the instance of BABYLON.Engine to use to create the scene
  98417. * @param onSuccess a callback with the scene when import succeeds
  98418. * @param onProgress a callback with a progress event for each file being loaded
  98419. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  98420. * @param pluginExtension the extension used to determine the plugin
  98421. * @returns The loaded plugin
  98422. */
  98423. 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>;
  98424. /**
  98425. * Load a scene
  98426. * @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)
  98427. * @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)
  98428. * @param engine is the instance of BABYLON.Engine to use to create the scene
  98429. * @param onProgress a callback with a progress event for each file being loaded
  98430. * @param pluginExtension the extension used to determine the plugin
  98431. * @returns The loaded scene
  98432. */
  98433. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  98434. /**
  98435. * Append a scene
  98436. * @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)
  98437. * @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)
  98438. * @param scene is the instance of BABYLON.Scene to append to
  98439. * @param onSuccess a callback with the scene when import succeeds
  98440. * @param onProgress a callback with a progress event for each file being loaded
  98441. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  98442. * @param pluginExtension the extension used to determine the plugin
  98443. * @returns The loaded plugin
  98444. */
  98445. 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>;
  98446. /**
  98447. * Append a scene
  98448. * @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)
  98449. * @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)
  98450. * @param scene is the instance of BABYLON.Scene to append to
  98451. * @param onProgress a callback with a progress event for each file being loaded
  98452. * @param pluginExtension the extension used to determine the plugin
  98453. * @returns The given scene
  98454. */
  98455. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  98456. /**
  98457. * Load a scene into an asset container
  98458. * @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)
  98459. * @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)
  98460. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  98461. * @param onSuccess a callback with the scene when import succeeds
  98462. * @param onProgress a callback with a progress event for each file being loaded
  98463. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  98464. * @param pluginExtension the extension used to determine the plugin
  98465. * @returns The loaded plugin
  98466. */
  98467. 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>;
  98468. /**
  98469. * Load a scene into an asset container
  98470. * @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)
  98471. * @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)
  98472. * @param scene is the instance of Scene to append to
  98473. * @param onProgress a callback with a progress event for each file being loaded
  98474. * @param pluginExtension the extension used to determine the plugin
  98475. * @returns The loaded asset container
  98476. */
  98477. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  98478. }
  98479. }
  98480. declare module BABYLON {
  98481. /**
  98482. * Google Daydream controller
  98483. */
  98484. export class DaydreamController extends WebVRController {
  98485. /**
  98486. * Base Url for the controller model.
  98487. */
  98488. static MODEL_BASE_URL: string;
  98489. /**
  98490. * File name for the controller model.
  98491. */
  98492. static MODEL_FILENAME: string;
  98493. /**
  98494. * Gamepad Id prefix used to identify Daydream Controller.
  98495. */
  98496. static readonly GAMEPAD_ID_PREFIX: string;
  98497. /**
  98498. * Creates a new DaydreamController from a gamepad
  98499. * @param vrGamepad the gamepad that the controller should be created from
  98500. */
  98501. constructor(vrGamepad: any);
  98502. /**
  98503. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  98504. * @param scene scene in which to add meshes
  98505. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  98506. */
  98507. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  98508. /**
  98509. * Called once for each button that changed state since the last frame
  98510. * @param buttonIdx Which button index changed
  98511. * @param state New state of the button
  98512. * @param changes Which properties on the state changed since last frame
  98513. */
  98514. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  98515. }
  98516. }
  98517. declare module BABYLON {
  98518. /**
  98519. * Gear VR Controller
  98520. */
  98521. export class GearVRController extends WebVRController {
  98522. /**
  98523. * Base Url for the controller model.
  98524. */
  98525. static MODEL_BASE_URL: string;
  98526. /**
  98527. * File name for the controller model.
  98528. */
  98529. static MODEL_FILENAME: string;
  98530. /**
  98531. * Gamepad Id prefix used to identify this controller.
  98532. */
  98533. static readonly GAMEPAD_ID_PREFIX: string;
  98534. private readonly _buttonIndexToObservableNameMap;
  98535. /**
  98536. * Creates a new GearVRController from a gamepad
  98537. * @param vrGamepad the gamepad that the controller should be created from
  98538. */
  98539. constructor(vrGamepad: any);
  98540. /**
  98541. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  98542. * @param scene scene in which to add meshes
  98543. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  98544. */
  98545. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  98546. /**
  98547. * Called once for each button that changed state since the last frame
  98548. * @param buttonIdx Which button index changed
  98549. * @param state New state of the button
  98550. * @param changes Which properties on the state changed since last frame
  98551. */
  98552. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  98553. }
  98554. }
  98555. declare module BABYLON {
  98556. /**
  98557. * Generic Controller
  98558. */
  98559. export class GenericController extends WebVRController {
  98560. /**
  98561. * Base Url for the controller model.
  98562. */
  98563. static readonly MODEL_BASE_URL: string;
  98564. /**
  98565. * File name for the controller model.
  98566. */
  98567. static readonly MODEL_FILENAME: string;
  98568. /**
  98569. * Creates a new GenericController from a gamepad
  98570. * @param vrGamepad the gamepad that the controller should be created from
  98571. */
  98572. constructor(vrGamepad: any);
  98573. /**
  98574. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  98575. * @param scene scene in which to add meshes
  98576. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  98577. */
  98578. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  98579. /**
  98580. * Called once for each button that changed state since the last frame
  98581. * @param buttonIdx Which button index changed
  98582. * @param state New state of the button
  98583. * @param changes Which properties on the state changed since last frame
  98584. */
  98585. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  98586. }
  98587. }
  98588. declare module BABYLON {
  98589. /**
  98590. * Oculus Touch Controller
  98591. */
  98592. export class OculusTouchController extends WebVRController {
  98593. /**
  98594. * Base Url for the controller model.
  98595. */
  98596. static MODEL_BASE_URL: string;
  98597. /**
  98598. * File name for the left controller model.
  98599. */
  98600. static MODEL_LEFT_FILENAME: string;
  98601. /**
  98602. * File name for the right controller model.
  98603. */
  98604. static MODEL_RIGHT_FILENAME: string;
  98605. /**
  98606. * Fired when the secondary trigger on this controller is modified
  98607. */
  98608. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  98609. /**
  98610. * Fired when the thumb rest on this controller is modified
  98611. */
  98612. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  98613. /**
  98614. * Creates a new OculusTouchController from a gamepad
  98615. * @param vrGamepad the gamepad that the controller should be created from
  98616. */
  98617. constructor(vrGamepad: any);
  98618. /**
  98619. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  98620. * @param scene scene in which to add meshes
  98621. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  98622. */
  98623. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  98624. /**
  98625. * Fired when the A button on this controller is modified
  98626. */
  98627. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  98628. /**
  98629. * Fired when the B button on this controller is modified
  98630. */
  98631. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  98632. /**
  98633. * Fired when the X button on this controller is modified
  98634. */
  98635. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  98636. /**
  98637. * Fired when the Y button on this controller is modified
  98638. */
  98639. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  98640. /**
  98641. * Called once for each button that changed state since the last frame
  98642. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  98643. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  98644. * 2) secondary trigger (same)
  98645. * 3) A (right) X (left), touch, pressed = value
  98646. * 4) B / Y
  98647. * 5) thumb rest
  98648. * @param buttonIdx Which button index changed
  98649. * @param state New state of the button
  98650. * @param changes Which properties on the state changed since last frame
  98651. */
  98652. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  98653. }
  98654. }
  98655. declare module BABYLON {
  98656. /**
  98657. * Vive Controller
  98658. */
  98659. export class ViveController extends WebVRController {
  98660. /**
  98661. * Base Url for the controller model.
  98662. */
  98663. static MODEL_BASE_URL: string;
  98664. /**
  98665. * File name for the controller model.
  98666. */
  98667. static MODEL_FILENAME: string;
  98668. /**
  98669. * Creates a new ViveController from a gamepad
  98670. * @param vrGamepad the gamepad that the controller should be created from
  98671. */
  98672. constructor(vrGamepad: any);
  98673. /**
  98674. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  98675. * @param scene scene in which to add meshes
  98676. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  98677. */
  98678. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  98679. /**
  98680. * Fired when the left button on this controller is modified
  98681. */
  98682. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  98683. /**
  98684. * Fired when the right button on this controller is modified
  98685. */
  98686. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  98687. /**
  98688. * Fired when the menu button on this controller is modified
  98689. */
  98690. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  98691. /**
  98692. * Called once for each button that changed state since the last frame
  98693. * Vive mapping:
  98694. * 0: touchpad
  98695. * 1: trigger
  98696. * 2: left AND right buttons
  98697. * 3: menu button
  98698. * @param buttonIdx Which button index changed
  98699. * @param state New state of the button
  98700. * @param changes Which properties on the state changed since last frame
  98701. */
  98702. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  98703. }
  98704. }
  98705. declare module BABYLON {
  98706. /**
  98707. * Defines the WindowsMotionController object that the state of the windows motion controller
  98708. */
  98709. export class WindowsMotionController extends WebVRController {
  98710. /**
  98711. * The base url used to load the left and right controller models
  98712. */
  98713. static MODEL_BASE_URL: string;
  98714. /**
  98715. * The name of the left controller model file
  98716. */
  98717. static MODEL_LEFT_FILENAME: string;
  98718. /**
  98719. * The name of the right controller model file
  98720. */
  98721. static MODEL_RIGHT_FILENAME: string;
  98722. /**
  98723. * The controller name prefix for this controller type
  98724. */
  98725. static readonly GAMEPAD_ID_PREFIX: string;
  98726. /**
  98727. * The controller id pattern for this controller type
  98728. */
  98729. private static readonly GAMEPAD_ID_PATTERN;
  98730. private _loadedMeshInfo;
  98731. private readonly _mapping;
  98732. /**
  98733. * Fired when the trackpad on this controller is clicked
  98734. */
  98735. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  98736. /**
  98737. * Fired when the trackpad on this controller is modified
  98738. */
  98739. onTrackpadValuesChangedObservable: Observable<StickValues>;
  98740. /**
  98741. * The current x and y values of this controller's trackpad
  98742. */
  98743. trackpad: StickValues;
  98744. /**
  98745. * Creates a new WindowsMotionController from a gamepad
  98746. * @param vrGamepad the gamepad that the controller should be created from
  98747. */
  98748. constructor(vrGamepad: any);
  98749. /**
  98750. * Fired when the trigger on this controller is modified
  98751. */
  98752. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  98753. /**
  98754. * Fired when the menu button on this controller is modified
  98755. */
  98756. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  98757. /**
  98758. * Fired when the grip button on this controller is modified
  98759. */
  98760. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  98761. /**
  98762. * Fired when the thumbstick button on this controller is modified
  98763. */
  98764. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  98765. /**
  98766. * Fired when the touchpad button on this controller is modified
  98767. */
  98768. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  98769. /**
  98770. * Fired when the touchpad values on this controller are modified
  98771. */
  98772. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  98773. private _updateTrackpad;
  98774. /**
  98775. * Called once per frame by the engine.
  98776. */
  98777. update(): void;
  98778. /**
  98779. * Called once for each button that changed state since the last frame
  98780. * @param buttonIdx Which button index changed
  98781. * @param state New state of the button
  98782. * @param changes Which properties on the state changed since last frame
  98783. */
  98784. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  98785. /**
  98786. * Moves the buttons on the controller mesh based on their current state
  98787. * @param buttonName the name of the button to move
  98788. * @param buttonValue the value of the button which determines the buttons new position
  98789. */
  98790. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  98791. /**
  98792. * Moves the axis on the controller mesh based on its current state
  98793. * @param axis the index of the axis
  98794. * @param axisValue the value of the axis which determines the meshes new position
  98795. * @hidden
  98796. */
  98797. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  98798. /**
  98799. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  98800. * @param scene scene in which to add meshes
  98801. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  98802. */
  98803. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  98804. /**
  98805. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  98806. * can be transformed by button presses and axes values, based on this._mapping.
  98807. *
  98808. * @param scene scene in which the meshes exist
  98809. * @param meshes list of meshes that make up the controller model to process
  98810. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  98811. */
  98812. private processModel;
  98813. private createMeshInfo;
  98814. /**
  98815. * Gets the ray of the controller in the direction the controller is pointing
  98816. * @param length the length the resulting ray should be
  98817. * @returns a ray in the direction the controller is pointing
  98818. */
  98819. getForwardRay(length?: number): Ray;
  98820. /**
  98821. * Disposes of the controller
  98822. */
  98823. dispose(): void;
  98824. }
  98825. }
  98826. declare module BABYLON {
  98827. /**
  98828. * Single axis scale gizmo
  98829. */
  98830. export class AxisScaleGizmo extends Gizmo {
  98831. private _coloredMaterial;
  98832. /**
  98833. * Drag behavior responsible for the gizmos dragging interactions
  98834. */
  98835. dragBehavior: PointerDragBehavior;
  98836. private _pointerObserver;
  98837. /**
  98838. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  98839. */
  98840. snapDistance: number;
  98841. /**
  98842. * Event that fires each time the gizmo snaps to a new location.
  98843. * * snapDistance is the the change in distance
  98844. */
  98845. onSnapObservable: Observable<{
  98846. snapDistance: number;
  98847. }>;
  98848. /**
  98849. * If the scaling operation should be done on all axis (default: false)
  98850. */
  98851. uniformScaling: boolean;
  98852. /**
  98853. * Creates an AxisScaleGizmo
  98854. * @param gizmoLayer The utility layer the gizmo will be added to
  98855. * @param dragAxis The axis which the gizmo will be able to scale on
  98856. * @param color The color of the gizmo
  98857. */
  98858. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  98859. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  98860. /**
  98861. * Disposes of the gizmo
  98862. */
  98863. dispose(): void;
  98864. /**
  98865. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  98866. * @param mesh The mesh to replace the default mesh of the gizmo
  98867. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  98868. */
  98869. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  98870. }
  98871. }
  98872. declare module BABYLON {
  98873. /**
  98874. * Bounding box gizmo
  98875. */
  98876. export class BoundingBoxGizmo extends Gizmo {
  98877. private _lineBoundingBox;
  98878. private _rotateSpheresParent;
  98879. private _scaleBoxesParent;
  98880. private _boundingDimensions;
  98881. private _renderObserver;
  98882. private _pointerObserver;
  98883. private _scaleDragSpeed;
  98884. private _tmpQuaternion;
  98885. private _tmpVector;
  98886. private _tmpRotationMatrix;
  98887. /**
  98888. * 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)
  98889. */
  98890. ignoreChildren: boolean;
  98891. /**
  98892. * 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)
  98893. */
  98894. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  98895. /**
  98896. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  98897. */
  98898. rotationSphereSize: number;
  98899. /**
  98900. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  98901. */
  98902. scaleBoxSize: number;
  98903. /**
  98904. * 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)
  98905. */
  98906. fixedDragMeshScreenSize: boolean;
  98907. /**
  98908. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  98909. */
  98910. fixedDragMeshScreenSizeDistanceFactor: number;
  98911. /**
  98912. * Fired when a rotation sphere or scale box is dragged
  98913. */
  98914. onDragStartObservable: Observable<{}>;
  98915. /**
  98916. * Fired when a scale box is dragged
  98917. */
  98918. onScaleBoxDragObservable: Observable<{}>;
  98919. /**
  98920. * Fired when a scale box drag is ended
  98921. */
  98922. onScaleBoxDragEndObservable: Observable<{}>;
  98923. /**
  98924. * Fired when a rotation sphere is dragged
  98925. */
  98926. onRotationSphereDragObservable: Observable<{}>;
  98927. /**
  98928. * Fired when a rotation sphere drag is ended
  98929. */
  98930. onRotationSphereDragEndObservable: Observable<{}>;
  98931. /**
  98932. * 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)
  98933. */
  98934. scalePivot: Nullable<Vector3>;
  98935. private _anchorMesh;
  98936. private _existingMeshScale;
  98937. private _dragMesh;
  98938. private pointerDragBehavior;
  98939. private coloredMaterial;
  98940. private hoverColoredMaterial;
  98941. /**
  98942. * Sets the color of the bounding box gizmo
  98943. * @param color the color to set
  98944. */
  98945. setColor(color: Color3): void;
  98946. /**
  98947. * Creates an BoundingBoxGizmo
  98948. * @param gizmoLayer The utility layer the gizmo will be added to
  98949. * @param color The color of the gizmo
  98950. */
  98951. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  98952. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  98953. private _selectNode;
  98954. /**
  98955. * Updates the bounding box information for the Gizmo
  98956. */
  98957. updateBoundingBox(): void;
  98958. private _updateRotationSpheres;
  98959. private _updateScaleBoxes;
  98960. /**
  98961. * Enables rotation on the specified axis and disables rotation on the others
  98962. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  98963. */
  98964. setEnabledRotationAxis(axis: string): void;
  98965. /**
  98966. * Enables/disables scaling
  98967. * @param enable if scaling should be enabled
  98968. */
  98969. setEnabledScaling(enable: boolean): void;
  98970. private _updateDummy;
  98971. /**
  98972. * Enables a pointer drag behavior on the bounding box of the gizmo
  98973. */
  98974. enableDragBehavior(): void;
  98975. /**
  98976. * Disposes of the gizmo
  98977. */
  98978. dispose(): void;
  98979. /**
  98980. * 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)
  98981. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  98982. * @returns the bounding box mesh with the passed in mesh as a child
  98983. */
  98984. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  98985. /**
  98986. * CustomMeshes are not supported by this gizmo
  98987. * @param mesh The mesh to replace the default mesh of the gizmo
  98988. */
  98989. setCustomMesh(mesh: Mesh): void;
  98990. }
  98991. }
  98992. declare module BABYLON {
  98993. /**
  98994. * Single plane rotation gizmo
  98995. */
  98996. export class PlaneRotationGizmo extends Gizmo {
  98997. /**
  98998. * Drag behavior responsible for the gizmos dragging interactions
  98999. */
  99000. dragBehavior: PointerDragBehavior;
  99001. private _pointerObserver;
  99002. /**
  99003. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  99004. */
  99005. snapDistance: number;
  99006. /**
  99007. * Event that fires each time the gizmo snaps to a new location.
  99008. * * snapDistance is the the change in distance
  99009. */
  99010. onSnapObservable: Observable<{
  99011. snapDistance: number;
  99012. }>;
  99013. /**
  99014. * Creates a PlaneRotationGizmo
  99015. * @param gizmoLayer The utility layer the gizmo will be added to
  99016. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  99017. * @param color The color of the gizmo
  99018. * @param tessellation Amount of tessellation to be used when creating rotation circles
  99019. */
  99020. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  99021. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  99022. /**
  99023. * Disposes of the gizmo
  99024. */
  99025. dispose(): void;
  99026. }
  99027. }
  99028. declare module BABYLON {
  99029. /**
  99030. * Gizmo that enables rotating a mesh along 3 axis
  99031. */
  99032. export class RotationGizmo extends Gizmo {
  99033. /**
  99034. * Internal gizmo used for interactions on the x axis
  99035. */
  99036. xGizmo: PlaneRotationGizmo;
  99037. /**
  99038. * Internal gizmo used for interactions on the y axis
  99039. */
  99040. yGizmo: PlaneRotationGizmo;
  99041. /**
  99042. * Internal gizmo used for interactions on the z axis
  99043. */
  99044. zGizmo: PlaneRotationGizmo;
  99045. /** Fires an event when any of it's sub gizmos are dragged */
  99046. onDragStartObservable: Observable<{}>;
  99047. /** Fires an event when any of it's sub gizmos are released from dragging */
  99048. onDragEndObservable: Observable<{}>;
  99049. attachedMesh: Nullable<AbstractMesh>;
  99050. /**
  99051. * Creates a RotationGizmo
  99052. * @param gizmoLayer The utility layer the gizmo will be added to
  99053. * @param tessellation Amount of tessellation to be used when creating rotation circles
  99054. */
  99055. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  99056. updateGizmoRotationToMatchAttachedMesh: boolean;
  99057. /**
  99058. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  99059. */
  99060. snapDistance: number;
  99061. /**
  99062. * Ratio for the scale of the gizmo (Default: 1)
  99063. */
  99064. scaleRatio: number;
  99065. /**
  99066. * Disposes of the gizmo
  99067. */
  99068. dispose(): void;
  99069. /**
  99070. * CustomMeshes are not supported by this gizmo
  99071. * @param mesh The mesh to replace the default mesh of the gizmo
  99072. */
  99073. setCustomMesh(mesh: Mesh): void;
  99074. }
  99075. }
  99076. declare module BABYLON {
  99077. /**
  99078. * Gizmo that enables dragging a mesh along 3 axis
  99079. */
  99080. export class PositionGizmo extends Gizmo {
  99081. /**
  99082. * Internal gizmo used for interactions on the x axis
  99083. */
  99084. xGizmo: AxisDragGizmo;
  99085. /**
  99086. * Internal gizmo used for interactions on the y axis
  99087. */
  99088. yGizmo: AxisDragGizmo;
  99089. /**
  99090. * Internal gizmo used for interactions on the z axis
  99091. */
  99092. zGizmo: AxisDragGizmo;
  99093. /** Fires an event when any of it's sub gizmos are dragged */
  99094. onDragStartObservable: Observable<{}>;
  99095. /** Fires an event when any of it's sub gizmos are released from dragging */
  99096. onDragEndObservable: Observable<{}>;
  99097. attachedMesh: Nullable<AbstractMesh>;
  99098. /**
  99099. * Creates a PositionGizmo
  99100. * @param gizmoLayer The utility layer the gizmo will be added to
  99101. */
  99102. constructor(gizmoLayer?: UtilityLayerRenderer);
  99103. updateGizmoRotationToMatchAttachedMesh: boolean;
  99104. /**
  99105. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  99106. */
  99107. snapDistance: number;
  99108. /**
  99109. * Ratio for the scale of the gizmo (Default: 1)
  99110. */
  99111. scaleRatio: number;
  99112. /**
  99113. * Disposes of the gizmo
  99114. */
  99115. dispose(): void;
  99116. /**
  99117. * CustomMeshes are not supported by this gizmo
  99118. * @param mesh The mesh to replace the default mesh of the gizmo
  99119. */
  99120. setCustomMesh(mesh: Mesh): void;
  99121. }
  99122. }
  99123. declare module BABYLON {
  99124. /**
  99125. * Class containing static functions to help procedurally build meshes
  99126. */
  99127. export class PolyhedronBuilder {
  99128. /**
  99129. * Creates a polyhedron mesh
  99130. * * 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
  99131. * * The parameter `size` (positive float, default 1) sets the polygon size
  99132. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  99133. * * 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`
  99134. * * 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
  99135. * * 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)`)
  99136. * * 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
  99137. * * 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
  99138. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  99139. * * If you create a double-sided mesh, you can choose what parts of 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
  99140. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  99141. * @param name defines the name of the mesh
  99142. * @param options defines the options used to create the mesh
  99143. * @param scene defines the hosting scene
  99144. * @returns the polyhedron mesh
  99145. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  99146. */
  99147. static CreatePolyhedron(name: string, options: {
  99148. type?: number;
  99149. size?: number;
  99150. sizeX?: number;
  99151. sizeY?: number;
  99152. sizeZ?: number;
  99153. custom?: any;
  99154. faceUV?: Vector4[];
  99155. faceColors?: Color4[];
  99156. flat?: boolean;
  99157. updatable?: boolean;
  99158. sideOrientation?: number;
  99159. frontUVs?: Vector4;
  99160. backUVs?: Vector4;
  99161. }, scene: Scene): Mesh;
  99162. }
  99163. }
  99164. declare module BABYLON {
  99165. /**
  99166. * Gizmo that enables scaling a mesh along 3 axis
  99167. */
  99168. export class ScaleGizmo extends Gizmo {
  99169. /**
  99170. * Internal gizmo used for interactions on the x axis
  99171. */
  99172. xGizmo: AxisScaleGizmo;
  99173. /**
  99174. * Internal gizmo used for interactions on the y axis
  99175. */
  99176. yGizmo: AxisScaleGizmo;
  99177. /**
  99178. * Internal gizmo used for interactions on the z axis
  99179. */
  99180. zGizmo: AxisScaleGizmo;
  99181. /**
  99182. * Internal gizmo used to scale all axis equally
  99183. */
  99184. uniformScaleGizmo: AxisScaleGizmo;
  99185. /** Fires an event when any of it's sub gizmos are dragged */
  99186. onDragStartObservable: Observable<{}>;
  99187. /** Fires an event when any of it's sub gizmos are released from dragging */
  99188. onDragEndObservable: Observable<{}>;
  99189. attachedMesh: Nullable<AbstractMesh>;
  99190. /**
  99191. * Creates a ScaleGizmo
  99192. * @param gizmoLayer The utility layer the gizmo will be added to
  99193. */
  99194. constructor(gizmoLayer?: UtilityLayerRenderer);
  99195. updateGizmoRotationToMatchAttachedMesh: boolean;
  99196. /**
  99197. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  99198. */
  99199. snapDistance: number;
  99200. /**
  99201. * Ratio for the scale of the gizmo (Default: 1)
  99202. */
  99203. scaleRatio: number;
  99204. /**
  99205. * Disposes of the gizmo
  99206. */
  99207. dispose(): void;
  99208. }
  99209. }
  99210. declare module BABYLON {
  99211. /**
  99212. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  99213. */
  99214. export class GizmoManager implements IDisposable {
  99215. private scene;
  99216. /**
  99217. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  99218. */
  99219. gizmos: {
  99220. positionGizmo: Nullable<PositionGizmo>;
  99221. rotationGizmo: Nullable<RotationGizmo>;
  99222. scaleGizmo: Nullable<ScaleGizmo>;
  99223. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  99224. };
  99225. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  99226. clearGizmoOnEmptyPointerEvent: boolean;
  99227. /** Fires an event when the manager is attached to a mesh */
  99228. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  99229. private _gizmosEnabled;
  99230. private _pointerObserver;
  99231. private _attachedMesh;
  99232. private _boundingBoxColor;
  99233. private _defaultUtilityLayer;
  99234. private _defaultKeepDepthUtilityLayer;
  99235. /**
  99236. * When bounding box gizmo is enabled, this can be used to track drag/end events
  99237. */
  99238. boundingBoxDragBehavior: SixDofDragBehavior;
  99239. /**
  99240. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  99241. */
  99242. attachableMeshes: Nullable<Array<AbstractMesh>>;
  99243. /**
  99244. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  99245. */
  99246. usePointerToAttachGizmos: boolean;
  99247. /**
  99248. * Instatiates a gizmo manager
  99249. * @param scene the scene to overlay the gizmos on top of
  99250. */
  99251. constructor(scene: Scene);
  99252. /**
  99253. * Attaches a set of gizmos to the specified mesh
  99254. * @param mesh The mesh the gizmo's should be attached to
  99255. */
  99256. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  99257. /**
  99258. * If the position gizmo is enabled
  99259. */
  99260. positionGizmoEnabled: boolean;
  99261. /**
  99262. * If the rotation gizmo is enabled
  99263. */
  99264. rotationGizmoEnabled: boolean;
  99265. /**
  99266. * If the scale gizmo is enabled
  99267. */
  99268. scaleGizmoEnabled: boolean;
  99269. /**
  99270. * If the boundingBox gizmo is enabled
  99271. */
  99272. boundingBoxGizmoEnabled: boolean;
  99273. /**
  99274. * Disposes of the gizmo manager
  99275. */
  99276. dispose(): void;
  99277. }
  99278. }
  99279. declare module BABYLON {
  99280. /**
  99281. * Gizmo that enables viewing a light
  99282. */
  99283. export class LightGizmo extends Gizmo {
  99284. private _box;
  99285. /**
  99286. * Creates a LightGizmo
  99287. * @param gizmoLayer The utility layer the gizmo will be added to
  99288. */
  99289. constructor(gizmoLayer?: UtilityLayerRenderer);
  99290. private _light;
  99291. /**
  99292. * The light that the gizmo is attached to
  99293. */
  99294. light: Nullable<Light>;
  99295. /**
  99296. * @hidden
  99297. * Updates the gizmo to match the attached mesh's position/rotation
  99298. */
  99299. protected _update(): void;
  99300. }
  99301. }
  99302. declare module BABYLON {
  99303. /** @hidden */
  99304. export var backgroundFragmentDeclaration: {
  99305. name: string;
  99306. shader: string;
  99307. };
  99308. }
  99309. declare module BABYLON {
  99310. /** @hidden */
  99311. export var backgroundUboDeclaration: {
  99312. name: string;
  99313. shader: string;
  99314. };
  99315. }
  99316. declare module BABYLON {
  99317. /** @hidden */
  99318. export var backgroundPixelShader: {
  99319. name: string;
  99320. shader: string;
  99321. };
  99322. }
  99323. declare module BABYLON {
  99324. /** @hidden */
  99325. export var backgroundVertexDeclaration: {
  99326. name: string;
  99327. shader: string;
  99328. };
  99329. }
  99330. declare module BABYLON {
  99331. /** @hidden */
  99332. export var backgroundVertexShader: {
  99333. name: string;
  99334. shader: string;
  99335. };
  99336. }
  99337. declare module BABYLON {
  99338. /**
  99339. * Background material used to create an efficient environement around your scene.
  99340. */
  99341. export class BackgroundMaterial extends PushMaterial {
  99342. /**
  99343. * Standard reflectance value at parallel view angle.
  99344. */
  99345. static StandardReflectance0: number;
  99346. /**
  99347. * Standard reflectance value at grazing angle.
  99348. */
  99349. static StandardReflectance90: number;
  99350. protected _primaryColor: Color3;
  99351. /**
  99352. * Key light Color (multiply against the environement texture)
  99353. */
  99354. primaryColor: Color3;
  99355. protected __perceptualColor: Nullable<Color3>;
  99356. /**
  99357. * Experimental Internal Use Only.
  99358. *
  99359. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  99360. * This acts as a helper to set the primary color to a more "human friendly" value.
  99361. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  99362. * output color as close as possible from the chosen value.
  99363. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  99364. * part of lighting setup.)
  99365. */
  99366. _perceptualColor: Nullable<Color3>;
  99367. protected _primaryColorShadowLevel: float;
  99368. /**
  99369. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  99370. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  99371. */
  99372. primaryColorShadowLevel: float;
  99373. protected _primaryColorHighlightLevel: float;
  99374. /**
  99375. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  99376. * The primary color is used at the level chosen to define what the white area would look.
  99377. */
  99378. primaryColorHighlightLevel: float;
  99379. protected _reflectionTexture: Nullable<BaseTexture>;
  99380. /**
  99381. * Reflection Texture used in the material.
  99382. * Should be author in a specific way for the best result (refer to the documentation).
  99383. */
  99384. reflectionTexture: Nullable<BaseTexture>;
  99385. protected _reflectionBlur: float;
  99386. /**
  99387. * Reflection Texture level of blur.
  99388. *
  99389. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  99390. * texture twice.
  99391. */
  99392. reflectionBlur: float;
  99393. protected _diffuseTexture: Nullable<BaseTexture>;
  99394. /**
  99395. * Diffuse Texture used in the material.
  99396. * Should be author in a specific way for the best result (refer to the documentation).
  99397. */
  99398. diffuseTexture: Nullable<BaseTexture>;
  99399. protected _shadowLights: Nullable<IShadowLight[]>;
  99400. /**
  99401. * Specify the list of lights casting shadow on the material.
  99402. * All scene shadow lights will be included if null.
  99403. */
  99404. shadowLights: Nullable<IShadowLight[]>;
  99405. protected _shadowLevel: float;
  99406. /**
  99407. * Helps adjusting the shadow to a softer level if required.
  99408. * 0 means black shadows and 1 means no shadows.
  99409. */
  99410. shadowLevel: float;
  99411. protected _sceneCenter: Vector3;
  99412. /**
  99413. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  99414. * It is usually zero but might be interesting to modify according to your setup.
  99415. */
  99416. sceneCenter: Vector3;
  99417. protected _opacityFresnel: boolean;
  99418. /**
  99419. * This helps specifying that the material is falling off to the sky box at grazing angle.
  99420. * This helps ensuring a nice transition when the camera goes under the ground.
  99421. */
  99422. opacityFresnel: boolean;
  99423. protected _reflectionFresnel: boolean;
  99424. /**
  99425. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  99426. * This helps adding a mirror texture on the ground.
  99427. */
  99428. reflectionFresnel: boolean;
  99429. protected _reflectionFalloffDistance: number;
  99430. /**
  99431. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  99432. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  99433. */
  99434. reflectionFalloffDistance: number;
  99435. protected _reflectionAmount: number;
  99436. /**
  99437. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  99438. */
  99439. reflectionAmount: number;
  99440. protected _reflectionReflectance0: number;
  99441. /**
  99442. * This specifies the weight of the reflection at grazing angle.
  99443. */
  99444. reflectionReflectance0: number;
  99445. protected _reflectionReflectance90: number;
  99446. /**
  99447. * This specifies the weight of the reflection at a perpendicular point of view.
  99448. */
  99449. reflectionReflectance90: number;
  99450. /**
  99451. * Sets the reflection reflectance fresnel values according to the default standard
  99452. * empirically know to work well :-)
  99453. */
  99454. reflectionStandardFresnelWeight: number;
  99455. protected _useRGBColor: boolean;
  99456. /**
  99457. * Helps to directly use the maps channels instead of their level.
  99458. */
  99459. useRGBColor: boolean;
  99460. protected _enableNoise: boolean;
  99461. /**
  99462. * This helps reducing the banding effect that could occur on the background.
  99463. */
  99464. enableNoise: boolean;
  99465. /**
  99466. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  99467. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  99468. * Recommended to be keep at 1.0 except for special cases.
  99469. */
  99470. fovMultiplier: number;
  99471. private _fovMultiplier;
  99472. /**
  99473. * Enable the FOV adjustment feature controlled by fovMultiplier.
  99474. */
  99475. useEquirectangularFOV: boolean;
  99476. private _maxSimultaneousLights;
  99477. /**
  99478. * Number of Simultaneous lights allowed on the material.
  99479. */
  99480. maxSimultaneousLights: int;
  99481. /**
  99482. * Default configuration related to image processing available in the Background Material.
  99483. */
  99484. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  99485. /**
  99486. * Keep track of the image processing observer to allow dispose and replace.
  99487. */
  99488. private _imageProcessingObserver;
  99489. /**
  99490. * Attaches a new image processing configuration to the PBR Material.
  99491. * @param configuration (if null the scene configuration will be use)
  99492. */
  99493. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  99494. /**
  99495. * Gets the image processing configuration used either in this material.
  99496. */
  99497. /**
  99498. * Sets the Default image processing configuration used either in the this material.
  99499. *
  99500. * If sets to null, the scene one is in use.
  99501. */
  99502. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  99503. /**
  99504. * Gets wether the color curves effect is enabled.
  99505. */
  99506. /**
  99507. * Sets wether the color curves effect is enabled.
  99508. */
  99509. cameraColorCurvesEnabled: boolean;
  99510. /**
  99511. * Gets wether the color grading effect is enabled.
  99512. */
  99513. /**
  99514. * Gets wether the color grading effect is enabled.
  99515. */
  99516. cameraColorGradingEnabled: boolean;
  99517. /**
  99518. * Gets wether tonemapping is enabled or not.
  99519. */
  99520. /**
  99521. * Sets wether tonemapping is enabled or not
  99522. */
  99523. cameraToneMappingEnabled: boolean;
  99524. /**
  99525. * The camera exposure used on this material.
  99526. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  99527. * This corresponds to a photographic exposure.
  99528. */
  99529. /**
  99530. * The camera exposure used on this material.
  99531. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  99532. * This corresponds to a photographic exposure.
  99533. */
  99534. cameraExposure: float;
  99535. /**
  99536. * Gets The camera contrast used on this material.
  99537. */
  99538. /**
  99539. * Sets The camera contrast used on this material.
  99540. */
  99541. cameraContrast: float;
  99542. /**
  99543. * Gets the Color Grading 2D Lookup Texture.
  99544. */
  99545. /**
  99546. * Sets the Color Grading 2D Lookup Texture.
  99547. */
  99548. cameraColorGradingTexture: Nullable<BaseTexture>;
  99549. /**
  99550. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  99551. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  99552. * 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;
  99553. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  99554. */
  99555. /**
  99556. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  99557. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  99558. * 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;
  99559. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  99560. */
  99561. cameraColorCurves: Nullable<ColorCurves>;
  99562. /**
  99563. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  99564. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  99565. */
  99566. switchToBGR: boolean;
  99567. private _renderTargets;
  99568. private _reflectionControls;
  99569. private _white;
  99570. private _primaryShadowColor;
  99571. private _primaryHighlightColor;
  99572. /**
  99573. * Instantiates a Background Material in the given scene
  99574. * @param name The friendly name of the material
  99575. * @param scene The scene to add the material to
  99576. */
  99577. constructor(name: string, scene: Scene);
  99578. /**
  99579. * Gets a boolean indicating that current material needs to register RTT
  99580. */
  99581. readonly hasRenderTargetTextures: boolean;
  99582. /**
  99583. * The entire material has been created in order to prevent overdraw.
  99584. * @returns false
  99585. */
  99586. needAlphaTesting(): boolean;
  99587. /**
  99588. * The entire material has been created in order to prevent overdraw.
  99589. * @returns true if blending is enable
  99590. */
  99591. needAlphaBlending(): boolean;
  99592. /**
  99593. * Checks wether the material is ready to be rendered for a given mesh.
  99594. * @param mesh The mesh to render
  99595. * @param subMesh The submesh to check against
  99596. * @param useInstances Specify wether or not the material is used with instances
  99597. * @returns true if all the dependencies are ready (Textures, Effects...)
  99598. */
  99599. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  99600. /**
  99601. * Compute the primary color according to the chosen perceptual color.
  99602. */
  99603. private _computePrimaryColorFromPerceptualColor;
  99604. /**
  99605. * Compute the highlights and shadow colors according to their chosen levels.
  99606. */
  99607. private _computePrimaryColors;
  99608. /**
  99609. * Build the uniform buffer used in the material.
  99610. */
  99611. buildUniformLayout(): void;
  99612. /**
  99613. * Unbind the material.
  99614. */
  99615. unbind(): void;
  99616. /**
  99617. * Bind only the world matrix to the material.
  99618. * @param world The world matrix to bind.
  99619. */
  99620. bindOnlyWorldMatrix(world: Matrix): void;
  99621. /**
  99622. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  99623. * @param world The world matrix to bind.
  99624. * @param subMesh The submesh to bind for.
  99625. */
  99626. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  99627. /**
  99628. * Dispose the material.
  99629. * @param forceDisposeEffect Force disposal of the associated effect.
  99630. * @param forceDisposeTextures Force disposal of the associated textures.
  99631. */
  99632. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  99633. /**
  99634. * Clones the material.
  99635. * @param name The cloned name.
  99636. * @returns The cloned material.
  99637. */
  99638. clone(name: string): BackgroundMaterial;
  99639. /**
  99640. * Serializes the current material to its JSON representation.
  99641. * @returns The JSON representation.
  99642. */
  99643. serialize(): any;
  99644. /**
  99645. * Gets the class name of the material
  99646. * @returns "BackgroundMaterial"
  99647. */
  99648. getClassName(): string;
  99649. /**
  99650. * Parse a JSON input to create back a background material.
  99651. * @param source The JSON data to parse
  99652. * @param scene The scene to create the parsed material in
  99653. * @param rootUrl The root url of the assets the material depends upon
  99654. * @returns the instantiated BackgroundMaterial.
  99655. */
  99656. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  99657. }
  99658. }
  99659. declare module BABYLON {
  99660. /**
  99661. * Represents the different options available during the creation of
  99662. * a Environment helper.
  99663. *
  99664. * This can control the default ground, skybox and image processing setup of your scene.
  99665. */
  99666. export interface IEnvironmentHelperOptions {
  99667. /**
  99668. * Specifies wether or not to create a ground.
  99669. * True by default.
  99670. */
  99671. createGround: boolean;
  99672. /**
  99673. * Specifies the ground size.
  99674. * 15 by default.
  99675. */
  99676. groundSize: number;
  99677. /**
  99678. * The texture used on the ground for the main color.
  99679. * Comes from the BabylonJS CDN by default.
  99680. *
  99681. * Remarks: Can be either a texture or a url.
  99682. */
  99683. groundTexture: string | BaseTexture;
  99684. /**
  99685. * The color mixed in the ground texture by default.
  99686. * BabylonJS clearColor by default.
  99687. */
  99688. groundColor: Color3;
  99689. /**
  99690. * Specifies the ground opacity.
  99691. * 1 by default.
  99692. */
  99693. groundOpacity: number;
  99694. /**
  99695. * Enables the ground to receive shadows.
  99696. * True by default.
  99697. */
  99698. enableGroundShadow: boolean;
  99699. /**
  99700. * Helps preventing the shadow to be fully black on the ground.
  99701. * 0.5 by default.
  99702. */
  99703. groundShadowLevel: number;
  99704. /**
  99705. * Creates a mirror texture attach to the ground.
  99706. * false by default.
  99707. */
  99708. enableGroundMirror: boolean;
  99709. /**
  99710. * Specifies the ground mirror size ratio.
  99711. * 0.3 by default as the default kernel is 64.
  99712. */
  99713. groundMirrorSizeRatio: number;
  99714. /**
  99715. * Specifies the ground mirror blur kernel size.
  99716. * 64 by default.
  99717. */
  99718. groundMirrorBlurKernel: number;
  99719. /**
  99720. * Specifies the ground mirror visibility amount.
  99721. * 1 by default
  99722. */
  99723. groundMirrorAmount: number;
  99724. /**
  99725. * Specifies the ground mirror reflectance weight.
  99726. * This uses the standard weight of the background material to setup the fresnel effect
  99727. * of the mirror.
  99728. * 1 by default.
  99729. */
  99730. groundMirrorFresnelWeight: number;
  99731. /**
  99732. * Specifies the ground mirror Falloff distance.
  99733. * This can helps reducing the size of the reflection.
  99734. * 0 by Default.
  99735. */
  99736. groundMirrorFallOffDistance: number;
  99737. /**
  99738. * Specifies the ground mirror texture type.
  99739. * Unsigned Int by Default.
  99740. */
  99741. groundMirrorTextureType: number;
  99742. /**
  99743. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  99744. * the shown objects.
  99745. */
  99746. groundYBias: number;
  99747. /**
  99748. * Specifies wether or not to create a skybox.
  99749. * True by default.
  99750. */
  99751. createSkybox: boolean;
  99752. /**
  99753. * Specifies the skybox size.
  99754. * 20 by default.
  99755. */
  99756. skyboxSize: number;
  99757. /**
  99758. * The texture used on the skybox for the main color.
  99759. * Comes from the BabylonJS CDN by default.
  99760. *
  99761. * Remarks: Can be either a texture or a url.
  99762. */
  99763. skyboxTexture: string | BaseTexture;
  99764. /**
  99765. * The color mixed in the skybox texture by default.
  99766. * BabylonJS clearColor by default.
  99767. */
  99768. skyboxColor: Color3;
  99769. /**
  99770. * The background rotation around the Y axis of the scene.
  99771. * This helps aligning the key lights of your scene with the background.
  99772. * 0 by default.
  99773. */
  99774. backgroundYRotation: number;
  99775. /**
  99776. * Compute automatically the size of the elements to best fit with the scene.
  99777. */
  99778. sizeAuto: boolean;
  99779. /**
  99780. * Default position of the rootMesh if autoSize is not true.
  99781. */
  99782. rootPosition: Vector3;
  99783. /**
  99784. * Sets up the image processing in the scene.
  99785. * true by default.
  99786. */
  99787. setupImageProcessing: boolean;
  99788. /**
  99789. * The texture used as your environment texture in the scene.
  99790. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  99791. *
  99792. * Remarks: Can be either a texture or a url.
  99793. */
  99794. environmentTexture: string | BaseTexture;
  99795. /**
  99796. * The value of the exposure to apply to the scene.
  99797. * 0.6 by default if setupImageProcessing is true.
  99798. */
  99799. cameraExposure: number;
  99800. /**
  99801. * The value of the contrast to apply to the scene.
  99802. * 1.6 by default if setupImageProcessing is true.
  99803. */
  99804. cameraContrast: number;
  99805. /**
  99806. * Specifies wether or not tonemapping should be enabled in the scene.
  99807. * true by default if setupImageProcessing is true.
  99808. */
  99809. toneMappingEnabled: boolean;
  99810. }
  99811. /**
  99812. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  99813. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  99814. * It also helps with the default setup of your imageProcessing configuration.
  99815. */
  99816. export class EnvironmentHelper {
  99817. /**
  99818. * Default ground texture URL.
  99819. */
  99820. private static _groundTextureCDNUrl;
  99821. /**
  99822. * Default skybox texture URL.
  99823. */
  99824. private static _skyboxTextureCDNUrl;
  99825. /**
  99826. * Default environment texture URL.
  99827. */
  99828. private static _environmentTextureCDNUrl;
  99829. /**
  99830. * Creates the default options for the helper.
  99831. */
  99832. private static _getDefaultOptions;
  99833. private _rootMesh;
  99834. /**
  99835. * Gets the root mesh created by the helper.
  99836. */
  99837. readonly rootMesh: Mesh;
  99838. private _skybox;
  99839. /**
  99840. * Gets the skybox created by the helper.
  99841. */
  99842. readonly skybox: Nullable<Mesh>;
  99843. private _skyboxTexture;
  99844. /**
  99845. * Gets the skybox texture created by the helper.
  99846. */
  99847. readonly skyboxTexture: Nullable<BaseTexture>;
  99848. private _skyboxMaterial;
  99849. /**
  99850. * Gets the skybox material created by the helper.
  99851. */
  99852. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  99853. private _ground;
  99854. /**
  99855. * Gets the ground mesh created by the helper.
  99856. */
  99857. readonly ground: Nullable<Mesh>;
  99858. private _groundTexture;
  99859. /**
  99860. * Gets the ground texture created by the helper.
  99861. */
  99862. readonly groundTexture: Nullable<BaseTexture>;
  99863. private _groundMirror;
  99864. /**
  99865. * Gets the ground mirror created by the helper.
  99866. */
  99867. readonly groundMirror: Nullable<MirrorTexture>;
  99868. /**
  99869. * Gets the ground mirror render list to helps pushing the meshes
  99870. * you wish in the ground reflection.
  99871. */
  99872. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  99873. private _groundMaterial;
  99874. /**
  99875. * Gets the ground material created by the helper.
  99876. */
  99877. readonly groundMaterial: Nullable<BackgroundMaterial>;
  99878. /**
  99879. * Stores the creation options.
  99880. */
  99881. private readonly _scene;
  99882. private _options;
  99883. /**
  99884. * This observable will be notified with any error during the creation of the environment,
  99885. * mainly texture creation errors.
  99886. */
  99887. onErrorObservable: Observable<{
  99888. message?: string;
  99889. exception?: any;
  99890. }>;
  99891. /**
  99892. * constructor
  99893. * @param options Defines the options we want to customize the helper
  99894. * @param scene The scene to add the material to
  99895. */
  99896. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  99897. /**
  99898. * Updates the background according to the new options
  99899. * @param options
  99900. */
  99901. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  99902. /**
  99903. * Sets the primary color of all the available elements.
  99904. * @param color the main color to affect to the ground and the background
  99905. */
  99906. setMainColor(color: Color3): void;
  99907. /**
  99908. * Setup the image processing according to the specified options.
  99909. */
  99910. private _setupImageProcessing;
  99911. /**
  99912. * Setup the environment texture according to the specified options.
  99913. */
  99914. private _setupEnvironmentTexture;
  99915. /**
  99916. * Setup the background according to the specified options.
  99917. */
  99918. private _setupBackground;
  99919. /**
  99920. * Get the scene sizes according to the setup.
  99921. */
  99922. private _getSceneSize;
  99923. /**
  99924. * Setup the ground according to the specified options.
  99925. */
  99926. private _setupGround;
  99927. /**
  99928. * Setup the ground material according to the specified options.
  99929. */
  99930. private _setupGroundMaterial;
  99931. /**
  99932. * Setup the ground diffuse texture according to the specified options.
  99933. */
  99934. private _setupGroundDiffuseTexture;
  99935. /**
  99936. * Setup the ground mirror texture according to the specified options.
  99937. */
  99938. private _setupGroundMirrorTexture;
  99939. /**
  99940. * Setup the ground to receive the mirror texture.
  99941. */
  99942. private _setupMirrorInGroundMaterial;
  99943. /**
  99944. * Setup the skybox according to the specified options.
  99945. */
  99946. private _setupSkybox;
  99947. /**
  99948. * Setup the skybox material according to the specified options.
  99949. */
  99950. private _setupSkyboxMaterial;
  99951. /**
  99952. * Setup the skybox reflection texture according to the specified options.
  99953. */
  99954. private _setupSkyboxReflectionTexture;
  99955. private _errorHandler;
  99956. /**
  99957. * Dispose all the elements created by the Helper.
  99958. */
  99959. dispose(): void;
  99960. }
  99961. }
  99962. declare module BABYLON {
  99963. /**
  99964. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  99965. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  99966. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  99967. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  99968. */
  99969. export class PhotoDome extends TransformNode {
  99970. private _useDirectMapping;
  99971. /**
  99972. * The texture being displayed on the sphere
  99973. */
  99974. protected _photoTexture: Texture;
  99975. /**
  99976. * Gets or sets the texture being displayed on the sphere
  99977. */
  99978. photoTexture: Texture;
  99979. /**
  99980. * Observable raised when an error occured while loading the 360 image
  99981. */
  99982. onLoadErrorObservable: Observable<string>;
  99983. /**
  99984. * The skybox material
  99985. */
  99986. protected _material: BackgroundMaterial;
  99987. /**
  99988. * The surface used for the skybox
  99989. */
  99990. protected _mesh: Mesh;
  99991. /**
  99992. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  99993. * Also see the options.resolution property.
  99994. */
  99995. fovMultiplier: number;
  99996. /**
  99997. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  99998. * @param name Element's name, child elements will append suffixes for their own names.
  99999. * @param urlsOfPhoto defines the url of the photo to display
  100000. * @param options defines an object containing optional or exposed sub element properties
  100001. * @param onError defines a callback called when an error occured while loading the texture
  100002. */
  100003. constructor(name: string, urlOfPhoto: string, options: {
  100004. resolution?: number;
  100005. size?: number;
  100006. useDirectMapping?: boolean;
  100007. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  100008. /**
  100009. * Releases resources associated with this node.
  100010. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  100011. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  100012. */
  100013. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  100014. }
  100015. }
  100016. declare module BABYLON {
  100017. /**
  100018. * Class used to host texture specific utilities
  100019. */
  100020. export class TextureTools {
  100021. /**
  100022. * Uses the GPU to create a copy texture rescaled at a given size
  100023. * @param texture Texture to copy from
  100024. * @param width defines the desired width
  100025. * @param height defines the desired height
  100026. * @param useBilinearMode defines if bilinear mode has to be used
  100027. * @return the generated texture
  100028. */
  100029. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  100030. /**
  100031. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  100032. * @param scene defines the hosting scene
  100033. * @returns the environment BRDF texture
  100034. */
  100035. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  100036. private static _environmentBRDFBase64Texture;
  100037. }
  100038. }
  100039. declare module BABYLON {
  100040. /**
  100041. * @hidden
  100042. */
  100043. export interface IMaterialClearCoatDefines {
  100044. CLEARCOAT: boolean;
  100045. CLEARCOAT_DEFAULTIOR: boolean;
  100046. CLEARCOAT_TEXTURE: boolean;
  100047. CLEARCOAT_TEXTUREDIRECTUV: number;
  100048. CLEARCOAT_BUMP: boolean;
  100049. CLEARCOAT_BUMPDIRECTUV: number;
  100050. CLEARCOAT_TINT: boolean;
  100051. CLEARCOAT_TINT_TEXTURE: boolean;
  100052. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  100053. /** @hidden */
  100054. _areTexturesDirty: boolean;
  100055. }
  100056. /**
  100057. * Define the code related to the clear coat parameters of the pbr material.
  100058. */
  100059. export class PBRClearCoatConfiguration {
  100060. /**
  100061. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  100062. * The default fits with a polyurethane material.
  100063. */
  100064. private static readonly _DefaultIndiceOfRefraction;
  100065. private _isEnabled;
  100066. /**
  100067. * Defines if the clear coat is enabled in the material.
  100068. */
  100069. isEnabled: boolean;
  100070. /**
  100071. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  100072. */
  100073. intensity: number;
  100074. /**
  100075. * Defines the clear coat layer roughness.
  100076. */
  100077. roughness: number;
  100078. private _indiceOfRefraction;
  100079. /**
  100080. * Defines the indice of refraction of the clear coat.
  100081. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  100082. * The default fits with a polyurethane material.
  100083. * Changing the default value is more performance intensive.
  100084. */
  100085. indiceOfRefraction: number;
  100086. private _texture;
  100087. /**
  100088. * Stores the clear coat values in a texture.
  100089. */
  100090. texture: Nullable<BaseTexture>;
  100091. private _bumpTexture;
  100092. /**
  100093. * Define the clear coat specific bump texture.
  100094. */
  100095. bumpTexture: Nullable<BaseTexture>;
  100096. private _isTintEnabled;
  100097. /**
  100098. * Defines if the clear coat tint is enabled in the material.
  100099. */
  100100. isTintEnabled: boolean;
  100101. /**
  100102. * Defines if the clear coat tint is enabled in the material.
  100103. * This is only use if tint is enabled
  100104. */
  100105. tintColor: Color3;
  100106. /**
  100107. * Defines if the distance at which the tint color should be found in the
  100108. * clear coat media.
  100109. * This is only use if tint is enabled
  100110. */
  100111. tintColorAtDistance: number;
  100112. /**
  100113. * Defines the clear coat layer thickness.
  100114. * This is only use if tint is enabled
  100115. */
  100116. tintThickness: number;
  100117. private _tintTexture;
  100118. /**
  100119. * Stores the clear tint values in a texture.
  100120. * rgb is tint
  100121. * a is a thickness factor
  100122. */
  100123. tintTexture: Nullable<BaseTexture>;
  100124. /** @hidden */
  100125. private _internalMarkAllSubMeshesAsTexturesDirty;
  100126. /** @hidden */
  100127. _markAllSubMeshesAsTexturesDirty(): void;
  100128. /**
  100129. * Instantiate a new istance of clear coat configuration.
  100130. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  100131. */
  100132. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  100133. /**
  100134. * Specifies that the submesh is ready to be used.
  100135. * @param defines the list of "defines" to update.
  100136. * @param scene defines the scene the material belongs to.
  100137. * @param engine defines the engine the material belongs to.
  100138. * @param disableBumpMap defines wether the material disables bump or not.
  100139. * @returns - boolean indicating that the submesh is ready or not.
  100140. */
  100141. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  100142. /**
  100143. * Checks to see if a texture is used in the material.
  100144. * @param defines the list of "defines" to update.
  100145. * @param scene defines the scene to the material belongs to.
  100146. */
  100147. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  100148. /**
  100149. * Binds the material data.
  100150. * @param uniformBuffer defines the Uniform buffer to fill in.
  100151. * @param scene defines the scene the material belongs to.
  100152. * @param engine defines the engine the material belongs to.
  100153. * @param disableBumpMap defines wether the material disables bump or not.
  100154. * @param isFrozen defines wether the material is frozen or not.
  100155. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  100156. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  100157. */
  100158. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  100159. /**
  100160. * Checks to see if a texture is used in the material.
  100161. * @param texture - Base texture to use.
  100162. * @returns - Boolean specifying if a texture is used in the material.
  100163. */
  100164. hasTexture(texture: BaseTexture): boolean;
  100165. /**
  100166. * Returns an array of the actively used textures.
  100167. * @param activeTextures Array of BaseTextures
  100168. */
  100169. getActiveTextures(activeTextures: BaseTexture[]): void;
  100170. /**
  100171. * Returns the animatable textures.
  100172. * @param animatables Array of animatable textures.
  100173. */
  100174. getAnimatables(animatables: IAnimatable[]): void;
  100175. /**
  100176. * Disposes the resources of the material.
  100177. * @param forceDisposeTextures - Forces the disposal of all textures.
  100178. */
  100179. dispose(forceDisposeTextures?: boolean): void;
  100180. /**
  100181. * Get the current class name of the texture useful for serialization or dynamic coding.
  100182. * @returns "PBRClearCoatConfiguration"
  100183. */
  100184. getClassName(): string;
  100185. /**
  100186. * Makes a duplicate of the current configuration into another one.
  100187. * @param clearCoatConfiguration define the config where to copy the info
  100188. */
  100189. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  100190. /**
  100191. * Serializes this clear coat configuration.
  100192. * @returns - An object with the serialized config.
  100193. */
  100194. serialize(): any;
  100195. /**
  100196. * Parses a Clear Coat Configuration from a serialized object.
  100197. * @param source - Serialized object.
  100198. */
  100199. parse(source: any): void;
  100200. /**
  100201. * Add fallbacks to the effect fallbacks list.
  100202. * @param defines defines the Base texture to use.
  100203. * @param fallbacks defines the current fallback list.
  100204. * @param currentRank defines the current fallback rank.
  100205. * @returns the new fallback rank.
  100206. */
  100207. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  100208. /**
  100209. * Add the required uniforms to the current list.
  100210. * @param uniforms defines the current uniform list.
  100211. */
  100212. static AddUniforms(uniforms: string[]): void;
  100213. /**
  100214. * Add the required samplers to the current list.
  100215. * @param samplers defines the current sampler list.
  100216. */
  100217. static AddSamplers(samplers: string[]): void;
  100218. /**
  100219. * Add the required uniforms to the current buffer.
  100220. * @param uniformBuffer defines the current uniform buffer.
  100221. */
  100222. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  100223. }
  100224. }
  100225. declare module BABYLON {
  100226. /**
  100227. * @hidden
  100228. */
  100229. export interface IMaterialAnisotropicDefines {
  100230. ANISOTROPIC: boolean;
  100231. MAINUV1: boolean;
  100232. _areMiscDirty: boolean;
  100233. _needUVs: boolean;
  100234. }
  100235. /**
  100236. * Define the code related to the anisotropic parameters of the pbr material.
  100237. */
  100238. export class PBRAnisotropicConfiguration {
  100239. private _isEnabled;
  100240. /**
  100241. * Defines if the anisotropy is enabled in the material.
  100242. */
  100243. isEnabled: boolean;
  100244. /**
  100245. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  100246. */
  100247. intensity: number;
  100248. /**
  100249. * Defines if the effect is along the tangents or bitangents.
  100250. * By default, the effect is "strectching" the highlights along the tangents.
  100251. */
  100252. followTangents: boolean;
  100253. /** @hidden */
  100254. private _internalMarkAllSubMeshesAsMiscDirty;
  100255. /** @hidden */
  100256. _markAllSubMeshesAsMiscDirty(): void;
  100257. /**
  100258. * Instantiate a new istance of clear coat configuration.
  100259. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  100260. */
  100261. constructor(markAllSubMeshesAsMiscDirty: () => void);
  100262. /**
  100263. * Checks to see if a texture is used in the material.
  100264. * @param defines the list of "defines" to update.
  100265. * @param mesh the mesh we are preparing the defines for.
  100266. */
  100267. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh): void;
  100268. /**
  100269. * Binds the material data.
  100270. * @param uniformBuffer defines the Uniform buffer to fill in.
  100271. * @param isFrozen defines wether the material is frozen or not.
  100272. */
  100273. bindForSubMesh(uniformBuffer: UniformBuffer, isFrozen: boolean): void;
  100274. /**
  100275. * Get the current class name of the texture useful for serialization or dynamic coding.
  100276. * @returns "PBRAnisotropicConfiguration"
  100277. */
  100278. getClassName(): string;
  100279. /**
  100280. * Makes a duplicate of the current configuration into another one.
  100281. * @param anisotropicConfiguration define the config where to copy the info
  100282. */
  100283. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  100284. /**
  100285. * Serializes this clear coat configuration.
  100286. * @returns - An object with the serialized config.
  100287. */
  100288. serialize(): any;
  100289. /**
  100290. * Parses a Clear Coat Configuration from a serialized object.
  100291. * @param source - Serialized object.
  100292. */
  100293. parse(source: any): void;
  100294. /**
  100295. * Add fallbacks to the effect fallbacks list.
  100296. * @param defines defines the Base texture to use.
  100297. * @param fallbacks defines the current fallback list.
  100298. * @param currentRank defines the current fallback rank.
  100299. * @returns the new fallback rank.
  100300. */
  100301. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  100302. /**
  100303. * Add the required uniforms to the current list.
  100304. * @param uniforms defines the current uniform list.
  100305. */
  100306. static AddUniforms(uniforms: string[]): void;
  100307. /**
  100308. * Add the required uniforms to the current buffer.
  100309. * @param uniformBuffer defines the current uniform buffer.
  100310. */
  100311. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  100312. }
  100313. }
  100314. declare module BABYLON {
  100315. /**
  100316. * @hidden
  100317. */
  100318. export interface IMaterialBRDFDefines {
  100319. BRDF_V_HEIGHT_CORRELATED: boolean;
  100320. MS_BRDF_ENERGY_CONSERVATION: boolean;
  100321. /** @hidden */
  100322. _areMiscDirty: boolean;
  100323. }
  100324. /**
  100325. * Define the code related to the BRDF parameters of the pbr material.
  100326. */
  100327. export class PBRBRDFConfiguration {
  100328. private _useEnergyConservation;
  100329. /**
  100330. * Defines if the material uses energy conservation.
  100331. */
  100332. useEnergyConservation: boolean;
  100333. private _useSmithVisibilityHeightCorrelated;
  100334. /**
  100335. * LEGACY Mode set to false
  100336. * Defines if the material uses height smith correlated visibility term.
  100337. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  100338. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  100339. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  100340. * Not relying on height correlated will also disable energy conservation.
  100341. */
  100342. useSmithVisibilityHeightCorrelated: boolean;
  100343. /** @hidden */
  100344. private _internalMarkAllSubMeshesAsMiscDirty;
  100345. /** @hidden */
  100346. _markAllSubMeshesAsMiscDirty(): void;
  100347. /**
  100348. * Instantiate a new istance of clear coat configuration.
  100349. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  100350. */
  100351. constructor(markAllSubMeshesAsMiscDirty: () => void);
  100352. /**
  100353. * Checks to see if a texture is used in the material.
  100354. * @param defines the list of "defines" to update.
  100355. */
  100356. prepareDefines(defines: IMaterialBRDFDefines): void;
  100357. /**
  100358. * Get the current class name of the texture useful for serialization or dynamic coding.
  100359. * @returns "PBRClearCoatConfiguration"
  100360. */
  100361. getClassName(): string;
  100362. /**
  100363. * Makes a duplicate of the current configuration into another one.
  100364. * @param brdfConfiguration define the config where to copy the info
  100365. */
  100366. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  100367. /**
  100368. * Serializes this BRDF configuration.
  100369. * @returns - An object with the serialized config.
  100370. */
  100371. serialize(): any;
  100372. /**
  100373. * Parses a BRDF Configuration from a serialized object.
  100374. * @param source - Serialized object.
  100375. */
  100376. parse(source: any): void;
  100377. }
  100378. }
  100379. declare module BABYLON {
  100380. /** @hidden */
  100381. export var pbrFragmentDeclaration: {
  100382. name: string;
  100383. shader: string;
  100384. };
  100385. }
  100386. declare module BABYLON {
  100387. /** @hidden */
  100388. export var pbrUboDeclaration: {
  100389. name: string;
  100390. shader: string;
  100391. };
  100392. }
  100393. declare module BABYLON {
  100394. /** @hidden */
  100395. export var pbrFunctions: {
  100396. name: string;
  100397. shader: string;
  100398. };
  100399. }
  100400. declare module BABYLON {
  100401. /** @hidden */
  100402. export var harmonicsFunctions: {
  100403. name: string;
  100404. shader: string;
  100405. };
  100406. }
  100407. declare module BABYLON {
  100408. /** @hidden */
  100409. export var pbrPreLightingFunctions: {
  100410. name: string;
  100411. shader: string;
  100412. };
  100413. }
  100414. declare module BABYLON {
  100415. /** @hidden */
  100416. export var pbrFalloffLightingFunctions: {
  100417. name: string;
  100418. shader: string;
  100419. };
  100420. }
  100421. declare module BABYLON {
  100422. /** @hidden */
  100423. export var pbrLightingFunctions: {
  100424. name: string;
  100425. shader: string;
  100426. };
  100427. }
  100428. declare module BABYLON {
  100429. /** @hidden */
  100430. export var pbrDebug: {
  100431. name: string;
  100432. shader: string;
  100433. };
  100434. }
  100435. declare module BABYLON {
  100436. /** @hidden */
  100437. export var pbrPixelShader: {
  100438. name: string;
  100439. shader: string;
  100440. };
  100441. }
  100442. declare module BABYLON {
  100443. /** @hidden */
  100444. export var pbrVertexDeclaration: {
  100445. name: string;
  100446. shader: string;
  100447. };
  100448. }
  100449. declare module BABYLON {
  100450. /** @hidden */
  100451. export var pbrVertexShader: {
  100452. name: string;
  100453. shader: string;
  100454. };
  100455. }
  100456. declare module BABYLON {
  100457. /**
  100458. * The Physically based material base class of BJS.
  100459. *
  100460. * This offers the main features of a standard PBR material.
  100461. * For more information, please refer to the documentation :
  100462. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  100463. */
  100464. export abstract class PBRBaseMaterial extends PushMaterial {
  100465. /**
  100466. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  100467. */
  100468. static readonly PBRMATERIAL_OPAQUE: number;
  100469. /**
  100470. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  100471. */
  100472. static readonly PBRMATERIAL_ALPHATEST: number;
  100473. /**
  100474. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  100475. */
  100476. static readonly PBRMATERIAL_ALPHABLEND: number;
  100477. /**
  100478. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  100479. * They are also discarded below the alpha cutoff threshold to improve performances.
  100480. */
  100481. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  100482. /**
  100483. * Defines the default value of how much AO map is occluding the analytical lights
  100484. * (point spot...).
  100485. */
  100486. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  100487. /**
  100488. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  100489. */
  100490. static readonly LIGHTFALLOFF_PHYSICAL: number;
  100491. /**
  100492. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  100493. * to enhance interoperability with other engines.
  100494. */
  100495. static readonly LIGHTFALLOFF_GLTF: number;
  100496. /**
  100497. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  100498. * to enhance interoperability with other materials.
  100499. */
  100500. static readonly LIGHTFALLOFF_STANDARD: number;
  100501. /**
  100502. * Intensity of the direct lights e.g. the four lights available in your scene.
  100503. * This impacts both the direct diffuse and specular highlights.
  100504. */
  100505. protected _directIntensity: number;
  100506. /**
  100507. * Intensity of the emissive part of the material.
  100508. * This helps controlling the emissive effect without modifying the emissive color.
  100509. */
  100510. protected _emissiveIntensity: number;
  100511. /**
  100512. * Intensity of the environment e.g. how much the environment will light the object
  100513. * either through harmonics for rough material or through the refelction for shiny ones.
  100514. */
  100515. protected _environmentIntensity: number;
  100516. /**
  100517. * This is a special control allowing the reduction of the specular highlights coming from the
  100518. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  100519. */
  100520. protected _specularIntensity: number;
  100521. /**
  100522. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  100523. */
  100524. private _lightingInfos;
  100525. /**
  100526. * Debug Control allowing disabling the bump map on this material.
  100527. */
  100528. protected _disableBumpMap: boolean;
  100529. /**
  100530. * AKA Diffuse Texture in standard nomenclature.
  100531. */
  100532. protected _albedoTexture: BaseTexture;
  100533. /**
  100534. * AKA Occlusion Texture in other nomenclature.
  100535. */
  100536. protected _ambientTexture: BaseTexture;
  100537. /**
  100538. * AKA Occlusion Texture Intensity in other nomenclature.
  100539. */
  100540. protected _ambientTextureStrength: number;
  100541. /**
  100542. * Defines how much the AO map is occluding the analytical lights (point spot...).
  100543. * 1 means it completely occludes it
  100544. * 0 mean it has no impact
  100545. */
  100546. protected _ambientTextureImpactOnAnalyticalLights: number;
  100547. /**
  100548. * Stores the alpha values in a texture.
  100549. */
  100550. protected _opacityTexture: BaseTexture;
  100551. /**
  100552. * Stores the reflection values in a texture.
  100553. */
  100554. protected _reflectionTexture: BaseTexture;
  100555. /**
  100556. * Stores the refraction values in a texture.
  100557. */
  100558. protected _refractionTexture: BaseTexture;
  100559. /**
  100560. * Stores the emissive values in a texture.
  100561. */
  100562. protected _emissiveTexture: BaseTexture;
  100563. /**
  100564. * AKA Specular texture in other nomenclature.
  100565. */
  100566. protected _reflectivityTexture: BaseTexture;
  100567. /**
  100568. * Used to switch from specular/glossiness to metallic/roughness workflow.
  100569. */
  100570. protected _metallicTexture: BaseTexture;
  100571. /**
  100572. * Specifies the metallic scalar of the metallic/roughness workflow.
  100573. * Can also be used to scale the metalness values of the metallic texture.
  100574. */
  100575. protected _metallic: Nullable<number>;
  100576. /**
  100577. * Specifies the roughness scalar of the metallic/roughness workflow.
  100578. * Can also be used to scale the roughness values of the metallic texture.
  100579. */
  100580. protected _roughness: Nullable<number>;
  100581. /**
  100582. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  100583. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  100584. */
  100585. protected _microSurfaceTexture: BaseTexture;
  100586. /**
  100587. * Stores surface normal data used to displace a mesh in a texture.
  100588. */
  100589. protected _bumpTexture: BaseTexture;
  100590. /**
  100591. * Stores the pre-calculated light information of a mesh in a texture.
  100592. */
  100593. protected _lightmapTexture: BaseTexture;
  100594. /**
  100595. * The color of a material in ambient lighting.
  100596. */
  100597. protected _ambientColor: Color3;
  100598. /**
  100599. * AKA Diffuse Color in other nomenclature.
  100600. */
  100601. protected _albedoColor: Color3;
  100602. /**
  100603. * AKA Specular Color in other nomenclature.
  100604. */
  100605. protected _reflectivityColor: Color3;
  100606. /**
  100607. * The color applied when light is reflected from a material.
  100608. */
  100609. protected _reflectionColor: Color3;
  100610. /**
  100611. * The color applied when light is emitted from a material.
  100612. */
  100613. protected _emissiveColor: Color3;
  100614. /**
  100615. * AKA Glossiness in other nomenclature.
  100616. */
  100617. protected _microSurface: number;
  100618. /**
  100619. * source material index of refraction (IOR)' / 'destination material IOR.
  100620. */
  100621. protected _indexOfRefraction: number;
  100622. /**
  100623. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  100624. */
  100625. protected _invertRefractionY: boolean;
  100626. /**
  100627. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  100628. * Materials half opaque for instance using refraction could benefit from this control.
  100629. */
  100630. protected _linkRefractionWithTransparency: boolean;
  100631. /**
  100632. * Specifies that the material will use the light map as a show map.
  100633. */
  100634. protected _useLightmapAsShadowmap: boolean;
  100635. /**
  100636. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  100637. * makes the reflect vector face the model (under horizon).
  100638. */
  100639. protected _useHorizonOcclusion: boolean;
  100640. /**
  100641. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  100642. * too much the area relying on ambient texture to define their ambient occlusion.
  100643. */
  100644. protected _useRadianceOcclusion: boolean;
  100645. /**
  100646. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  100647. */
  100648. protected _useAlphaFromAlbedoTexture: boolean;
  100649. /**
  100650. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  100651. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  100652. */
  100653. protected _useSpecularOverAlpha: boolean;
  100654. /**
  100655. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  100656. */
  100657. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  100658. /**
  100659. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  100660. */
  100661. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  100662. /**
  100663. * Specifies if the metallic texture contains the roughness information in its green channel.
  100664. */
  100665. protected _useRoughnessFromMetallicTextureGreen: boolean;
  100666. /**
  100667. * Specifies if the metallic texture contains the metallness information in its blue channel.
  100668. */
  100669. protected _useMetallnessFromMetallicTextureBlue: boolean;
  100670. /**
  100671. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  100672. */
  100673. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  100674. /**
  100675. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  100676. */
  100677. protected _useAmbientInGrayScale: boolean;
  100678. /**
  100679. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  100680. * The material will try to infer what glossiness each pixel should be.
  100681. */
  100682. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  100683. /**
  100684. * Defines the falloff type used in this material.
  100685. * It by default is Physical.
  100686. */
  100687. protected _lightFalloff: number;
  100688. /**
  100689. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  100690. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  100691. */
  100692. protected _useRadianceOverAlpha: boolean;
  100693. /**
  100694. * Allows using an object space normal map (instead of tangent space).
  100695. */
  100696. protected _useObjectSpaceNormalMap: boolean;
  100697. /**
  100698. * Allows using the bump map in parallax mode.
  100699. */
  100700. protected _useParallax: boolean;
  100701. /**
  100702. * Allows using the bump map in parallax occlusion mode.
  100703. */
  100704. protected _useParallaxOcclusion: boolean;
  100705. /**
  100706. * Controls the scale bias of the parallax mode.
  100707. */
  100708. protected _parallaxScaleBias: number;
  100709. /**
  100710. * If sets to true, disables all the lights affecting the material.
  100711. */
  100712. protected _disableLighting: boolean;
  100713. /**
  100714. * Number of Simultaneous lights allowed on the material.
  100715. */
  100716. protected _maxSimultaneousLights: number;
  100717. /**
  100718. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  100719. */
  100720. protected _invertNormalMapX: boolean;
  100721. /**
  100722. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  100723. */
  100724. protected _invertNormalMapY: boolean;
  100725. /**
  100726. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  100727. */
  100728. protected _twoSidedLighting: boolean;
  100729. /**
  100730. * Defines the alpha limits in alpha test mode.
  100731. */
  100732. protected _alphaCutOff: number;
  100733. /**
  100734. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  100735. */
  100736. protected _forceAlphaTest: boolean;
  100737. /**
  100738. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  100739. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  100740. */
  100741. protected _useAlphaFresnel: boolean;
  100742. /**
  100743. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  100744. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  100745. */
  100746. protected _useLinearAlphaFresnel: boolean;
  100747. /**
  100748. * The transparency mode of the material.
  100749. */
  100750. protected _transparencyMode: Nullable<number>;
  100751. /**
  100752. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  100753. * from cos thetav and roughness:
  100754. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  100755. */
  100756. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  100757. /**
  100758. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  100759. */
  100760. protected _forceIrradianceInFragment: boolean;
  100761. /**
  100762. * Force normal to face away from face.
  100763. */
  100764. protected _forceNormalForward: boolean;
  100765. /**
  100766. * Enables specular anti aliasing in the PBR shader.
  100767. * It will both interacts on the Geometry for analytical and IBL lighting.
  100768. * It also prefilter the roughness map based on the bump values.
  100769. */
  100770. protected _enableSpecularAntiAliasing: boolean;
  100771. /**
  100772. * Default configuration related to image processing available in the PBR Material.
  100773. */
  100774. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  100775. /**
  100776. * Keep track of the image processing observer to allow dispose and replace.
  100777. */
  100778. private _imageProcessingObserver;
  100779. /**
  100780. * Attaches a new image processing configuration to the PBR Material.
  100781. * @param configuration
  100782. */
  100783. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  100784. /**
  100785. * Stores the available render targets.
  100786. */
  100787. private _renderTargets;
  100788. /**
  100789. * Sets the global ambient color for the material used in lighting calculations.
  100790. */
  100791. private _globalAmbientColor;
  100792. /**
  100793. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  100794. */
  100795. private _useLogarithmicDepth;
  100796. /**
  100797. * If set to true, no lighting calculations will be applied.
  100798. */
  100799. private _unlit;
  100800. private _debugMode;
  100801. /**
  100802. * @hidden
  100803. * This is reserved for the inspector.
  100804. * Defines the material debug mode.
  100805. * It helps seeing only some components of the material while troubleshooting.
  100806. */
  100807. debugMode: number;
  100808. /**
  100809. * @hidden
  100810. * This is reserved for the inspector.
  100811. * Specify from where on screen the debug mode should start.
  100812. * The value goes from -1 (full screen) to 1 (not visible)
  100813. * It helps with side by side comparison against the final render
  100814. * This defaults to -1
  100815. */
  100816. private debugLimit;
  100817. /**
  100818. * @hidden
  100819. * This is reserved for the inspector.
  100820. * As the default viewing range might not be enough (if the ambient is really small for instance)
  100821. * You can use the factor to better multiply the final value.
  100822. */
  100823. private debugFactor;
  100824. /**
  100825. * Defines the clear coat layer parameters for the material.
  100826. */
  100827. readonly clearCoat: PBRClearCoatConfiguration;
  100828. /**
  100829. * Defines the anisotropic parameters for the material.
  100830. */
  100831. readonly anisotropy: PBRAnisotropicConfiguration;
  100832. /**
  100833. * Defines the BRDF parameters for the material.
  100834. */
  100835. readonly brdf: PBRBRDFConfiguration;
  100836. /**
  100837. * Instantiates a new PBRMaterial instance.
  100838. *
  100839. * @param name The material name
  100840. * @param scene The scene the material will be use in.
  100841. */
  100842. constructor(name: string, scene: Scene);
  100843. /**
  100844. * Gets a boolean indicating that current material needs to register RTT
  100845. */
  100846. readonly hasRenderTargetTextures: boolean;
  100847. /**
  100848. * Gets the name of the material class.
  100849. */
  100850. getClassName(): string;
  100851. /**
  100852. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  100853. */
  100854. /**
  100855. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  100856. */
  100857. useLogarithmicDepth: boolean;
  100858. /**
  100859. * Gets the current transparency mode.
  100860. */
  100861. /**
  100862. * Sets the transparency mode of the material.
  100863. *
  100864. * | Value | Type | Description |
  100865. * | ----- | ----------------------------------- | ----------- |
  100866. * | 0 | OPAQUE | |
  100867. * | 1 | ALPHATEST | |
  100868. * | 2 | ALPHABLEND | |
  100869. * | 3 | ALPHATESTANDBLEND | |
  100870. *
  100871. */
  100872. transparencyMode: Nullable<number>;
  100873. /**
  100874. * Returns true if alpha blending should be disabled.
  100875. */
  100876. private readonly _disableAlphaBlending;
  100877. /**
  100878. * Specifies whether or not this material should be rendered in alpha blend mode.
  100879. */
  100880. needAlphaBlending(): boolean;
  100881. /**
  100882. * Specifies if the mesh will require alpha blending.
  100883. * @param mesh - BJS mesh.
  100884. */
  100885. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  100886. /**
  100887. * Specifies whether or not this material should be rendered in alpha test mode.
  100888. */
  100889. needAlphaTesting(): boolean;
  100890. /**
  100891. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  100892. */
  100893. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  100894. /**
  100895. * Gets the texture used for the alpha test.
  100896. */
  100897. getAlphaTestTexture(): BaseTexture;
  100898. /**
  100899. * Specifies that the submesh is ready to be used.
  100900. * @param mesh - BJS mesh.
  100901. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  100902. * @param useInstances - Specifies that instances should be used.
  100903. * @returns - boolean indicating that the submesh is ready or not.
  100904. */
  100905. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  100906. /**
  100907. * Specifies if the material uses metallic roughness workflow.
  100908. * @returns boolean specifiying if the material uses metallic roughness workflow.
  100909. */
  100910. isMetallicWorkflow(): boolean;
  100911. private _prepareEffect;
  100912. private _prepareDefines;
  100913. /**
  100914. * Force shader compilation
  100915. */
  100916. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  100917. clipPlane: boolean;
  100918. }>): void;
  100919. /**
  100920. * Initializes the uniform buffer layout for the shader.
  100921. */
  100922. buildUniformLayout(): void;
  100923. /**
  100924. * Unbinds the textures.
  100925. */
  100926. unbind(): void;
  100927. /**
  100928. * Binds the submesh data.
  100929. * @param world - The world matrix.
  100930. * @param mesh - The BJS mesh.
  100931. * @param subMesh - A submesh of the BJS mesh.
  100932. */
  100933. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  100934. /**
  100935. * Returns the animatable textures.
  100936. * @returns - Array of animatable textures.
  100937. */
  100938. getAnimatables(): IAnimatable[];
  100939. /**
  100940. * Returns the texture used for reflections.
  100941. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  100942. */
  100943. private _getReflectionTexture;
  100944. /**
  100945. * Returns the texture used for refraction or null if none is used.
  100946. * @returns - Refection texture if present. If no refraction texture and refraction
  100947. * is linked with transparency, returns environment texture. Otherwise, returns null.
  100948. */
  100949. private _getRefractionTexture;
  100950. /**
  100951. * Returns an array of the actively used textures.
  100952. * @returns - Array of BaseTextures
  100953. */
  100954. getActiveTextures(): BaseTexture[];
  100955. /**
  100956. * Checks to see if a texture is used in the material.
  100957. * @param texture - Base texture to use.
  100958. * @returns - Boolean specifying if a texture is used in the material.
  100959. */
  100960. hasTexture(texture: BaseTexture): boolean;
  100961. /**
  100962. * Disposes the resources of the material.
  100963. * @param forceDisposeEffect - Forces the disposal of effects.
  100964. * @param forceDisposeTextures - Forces the disposal of all textures.
  100965. */
  100966. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  100967. }
  100968. }
  100969. declare module BABYLON {
  100970. /**
  100971. * The Physically based material of BJS.
  100972. *
  100973. * This offers the main features of a standard PBR material.
  100974. * For more information, please refer to the documentation :
  100975. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  100976. */
  100977. export class PBRMaterial extends PBRBaseMaterial {
  100978. /**
  100979. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  100980. */
  100981. static readonly PBRMATERIAL_OPAQUE: number;
  100982. /**
  100983. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  100984. */
  100985. static readonly PBRMATERIAL_ALPHATEST: number;
  100986. /**
  100987. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  100988. */
  100989. static readonly PBRMATERIAL_ALPHABLEND: number;
  100990. /**
  100991. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  100992. * They are also discarded below the alpha cutoff threshold to improve performances.
  100993. */
  100994. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  100995. /**
  100996. * Defines the default value of how much AO map is occluding the analytical lights
  100997. * (point spot...).
  100998. */
  100999. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  101000. /**
  101001. * Intensity of the direct lights e.g. the four lights available in your scene.
  101002. * This impacts both the direct diffuse and specular highlights.
  101003. */
  101004. directIntensity: number;
  101005. /**
  101006. * Intensity of the emissive part of the material.
  101007. * This helps controlling the emissive effect without modifying the emissive color.
  101008. */
  101009. emissiveIntensity: number;
  101010. /**
  101011. * Intensity of the environment e.g. how much the environment will light the object
  101012. * either through harmonics for rough material or through the refelction for shiny ones.
  101013. */
  101014. environmentIntensity: number;
  101015. /**
  101016. * This is a special control allowing the reduction of the specular highlights coming from the
  101017. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  101018. */
  101019. specularIntensity: number;
  101020. /**
  101021. * Debug Control allowing disabling the bump map on this material.
  101022. */
  101023. disableBumpMap: boolean;
  101024. /**
  101025. * AKA Diffuse Texture in standard nomenclature.
  101026. */
  101027. albedoTexture: BaseTexture;
  101028. /**
  101029. * AKA Occlusion Texture in other nomenclature.
  101030. */
  101031. ambientTexture: BaseTexture;
  101032. /**
  101033. * AKA Occlusion Texture Intensity in other nomenclature.
  101034. */
  101035. ambientTextureStrength: number;
  101036. /**
  101037. * Defines how much the AO map is occluding the analytical lights (point spot...).
  101038. * 1 means it completely occludes it
  101039. * 0 mean it has no impact
  101040. */
  101041. ambientTextureImpactOnAnalyticalLights: number;
  101042. /**
  101043. * Stores the alpha values in a texture.
  101044. */
  101045. opacityTexture: BaseTexture;
  101046. /**
  101047. * Stores the reflection values in a texture.
  101048. */
  101049. reflectionTexture: Nullable<BaseTexture>;
  101050. /**
  101051. * Stores the emissive values in a texture.
  101052. */
  101053. emissiveTexture: BaseTexture;
  101054. /**
  101055. * AKA Specular texture in other nomenclature.
  101056. */
  101057. reflectivityTexture: BaseTexture;
  101058. /**
  101059. * Used to switch from specular/glossiness to metallic/roughness workflow.
  101060. */
  101061. metallicTexture: BaseTexture;
  101062. /**
  101063. * Specifies the metallic scalar of the metallic/roughness workflow.
  101064. * Can also be used to scale the metalness values of the metallic texture.
  101065. */
  101066. metallic: Nullable<number>;
  101067. /**
  101068. * Specifies the roughness scalar of the metallic/roughness workflow.
  101069. * Can also be used to scale the roughness values of the metallic texture.
  101070. */
  101071. roughness: Nullable<number>;
  101072. /**
  101073. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  101074. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  101075. */
  101076. microSurfaceTexture: BaseTexture;
  101077. /**
  101078. * Stores surface normal data used to displace a mesh in a texture.
  101079. */
  101080. bumpTexture: BaseTexture;
  101081. /**
  101082. * Stores the pre-calculated light information of a mesh in a texture.
  101083. */
  101084. lightmapTexture: BaseTexture;
  101085. /**
  101086. * Stores the refracted light information in a texture.
  101087. */
  101088. refractionTexture: BaseTexture;
  101089. /**
  101090. * The color of a material in ambient lighting.
  101091. */
  101092. ambientColor: Color3;
  101093. /**
  101094. * AKA Diffuse Color in other nomenclature.
  101095. */
  101096. albedoColor: Color3;
  101097. /**
  101098. * AKA Specular Color in other nomenclature.
  101099. */
  101100. reflectivityColor: Color3;
  101101. /**
  101102. * The color reflected from the material.
  101103. */
  101104. reflectionColor: Color3;
  101105. /**
  101106. * The color emitted from the material.
  101107. */
  101108. emissiveColor: Color3;
  101109. /**
  101110. * AKA Glossiness in other nomenclature.
  101111. */
  101112. microSurface: number;
  101113. /**
  101114. * source material index of refraction (IOR)' / 'destination material IOR.
  101115. */
  101116. indexOfRefraction: number;
  101117. /**
  101118. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  101119. */
  101120. invertRefractionY: boolean;
  101121. /**
  101122. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  101123. * Materials half opaque for instance using refraction could benefit from this control.
  101124. */
  101125. linkRefractionWithTransparency: boolean;
  101126. /**
  101127. * If true, the light map contains occlusion information instead of lighting info.
  101128. */
  101129. useLightmapAsShadowmap: boolean;
  101130. /**
  101131. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  101132. */
  101133. useAlphaFromAlbedoTexture: boolean;
  101134. /**
  101135. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  101136. */
  101137. forceAlphaTest: boolean;
  101138. /**
  101139. * Defines the alpha limits in alpha test mode.
  101140. */
  101141. alphaCutOff: number;
  101142. /**
  101143. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  101144. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  101145. */
  101146. useSpecularOverAlpha: boolean;
  101147. /**
  101148. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  101149. */
  101150. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  101151. /**
  101152. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  101153. */
  101154. useRoughnessFromMetallicTextureAlpha: boolean;
  101155. /**
  101156. * Specifies if the metallic texture contains the roughness information in its green channel.
  101157. */
  101158. useRoughnessFromMetallicTextureGreen: boolean;
  101159. /**
  101160. * Specifies if the metallic texture contains the metallness information in its blue channel.
  101161. */
  101162. useMetallnessFromMetallicTextureBlue: boolean;
  101163. /**
  101164. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  101165. */
  101166. useAmbientOcclusionFromMetallicTextureRed: boolean;
  101167. /**
  101168. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  101169. */
  101170. useAmbientInGrayScale: boolean;
  101171. /**
  101172. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  101173. * The material will try to infer what glossiness each pixel should be.
  101174. */
  101175. useAutoMicroSurfaceFromReflectivityMap: boolean;
  101176. /**
  101177. * BJS is using an harcoded light falloff based on a manually sets up range.
  101178. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  101179. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  101180. */
  101181. /**
  101182. * BJS is using an harcoded light falloff based on a manually sets up range.
  101183. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  101184. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  101185. */
  101186. usePhysicalLightFalloff: boolean;
  101187. /**
  101188. * In order to support the falloff compatibility with gltf, a special mode has been added
  101189. * to reproduce the gltf light falloff.
  101190. */
  101191. /**
  101192. * In order to support the falloff compatibility with gltf, a special mode has been added
  101193. * to reproduce the gltf light falloff.
  101194. */
  101195. useGLTFLightFalloff: boolean;
  101196. /**
  101197. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  101198. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  101199. */
  101200. useRadianceOverAlpha: boolean;
  101201. /**
  101202. * Allows using an object space normal map (instead of tangent space).
  101203. */
  101204. useObjectSpaceNormalMap: boolean;
  101205. /**
  101206. * Allows using the bump map in parallax mode.
  101207. */
  101208. useParallax: boolean;
  101209. /**
  101210. * Allows using the bump map in parallax occlusion mode.
  101211. */
  101212. useParallaxOcclusion: boolean;
  101213. /**
  101214. * Controls the scale bias of the parallax mode.
  101215. */
  101216. parallaxScaleBias: number;
  101217. /**
  101218. * If sets to true, disables all the lights affecting the material.
  101219. */
  101220. disableLighting: boolean;
  101221. /**
  101222. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  101223. */
  101224. forceIrradianceInFragment: boolean;
  101225. /**
  101226. * Number of Simultaneous lights allowed on the material.
  101227. */
  101228. maxSimultaneousLights: number;
  101229. /**
  101230. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  101231. */
  101232. invertNormalMapX: boolean;
  101233. /**
  101234. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  101235. */
  101236. invertNormalMapY: boolean;
  101237. /**
  101238. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  101239. */
  101240. twoSidedLighting: boolean;
  101241. /**
  101242. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  101243. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  101244. */
  101245. useAlphaFresnel: boolean;
  101246. /**
  101247. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  101248. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  101249. */
  101250. useLinearAlphaFresnel: boolean;
  101251. /**
  101252. * Let user defines the brdf lookup texture used for IBL.
  101253. * A default 8bit version is embedded but you could point at :
  101254. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.png
  101255. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  101256. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  101257. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  101258. */
  101259. environmentBRDFTexture: Nullable<BaseTexture>;
  101260. /**
  101261. * Force normal to face away from face.
  101262. */
  101263. forceNormalForward: boolean;
  101264. /**
  101265. * Enables specular anti aliasing in the PBR shader.
  101266. * It will both interacts on the Geometry for analytical and IBL lighting.
  101267. * It also prefilter the roughness map based on the bump values.
  101268. */
  101269. enableSpecularAntiAliasing: boolean;
  101270. /**
  101271. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  101272. * makes the reflect vector face the model (under horizon).
  101273. */
  101274. useHorizonOcclusion: boolean;
  101275. /**
  101276. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  101277. * too much the area relying on ambient texture to define their ambient occlusion.
  101278. */
  101279. useRadianceOcclusion: boolean;
  101280. /**
  101281. * If set to true, no lighting calculations will be applied.
  101282. */
  101283. unlit: boolean;
  101284. /**
  101285. * Gets the image processing configuration used either in this material.
  101286. */
  101287. /**
  101288. * Sets the Default image processing configuration used either in the this material.
  101289. *
  101290. * If sets to null, the scene one is in use.
  101291. */
  101292. imageProcessingConfiguration: ImageProcessingConfiguration;
  101293. /**
  101294. * Gets wether the color curves effect is enabled.
  101295. */
  101296. /**
  101297. * Sets wether the color curves effect is enabled.
  101298. */
  101299. cameraColorCurvesEnabled: boolean;
  101300. /**
  101301. * Gets wether the color grading effect is enabled.
  101302. */
  101303. /**
  101304. * Gets wether the color grading effect is enabled.
  101305. */
  101306. cameraColorGradingEnabled: boolean;
  101307. /**
  101308. * Gets wether tonemapping is enabled or not.
  101309. */
  101310. /**
  101311. * Sets wether tonemapping is enabled or not
  101312. */
  101313. cameraToneMappingEnabled: boolean;
  101314. /**
  101315. * The camera exposure used on this material.
  101316. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  101317. * This corresponds to a photographic exposure.
  101318. */
  101319. /**
  101320. * The camera exposure used on this material.
  101321. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  101322. * This corresponds to a photographic exposure.
  101323. */
  101324. cameraExposure: number;
  101325. /**
  101326. * Gets The camera contrast used on this material.
  101327. */
  101328. /**
  101329. * Sets The camera contrast used on this material.
  101330. */
  101331. cameraContrast: number;
  101332. /**
  101333. * Gets the Color Grading 2D Lookup Texture.
  101334. */
  101335. /**
  101336. * Sets the Color Grading 2D Lookup Texture.
  101337. */
  101338. cameraColorGradingTexture: Nullable<BaseTexture>;
  101339. /**
  101340. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  101341. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  101342. * 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;
  101343. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  101344. */
  101345. /**
  101346. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  101347. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  101348. * 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;
  101349. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  101350. */
  101351. cameraColorCurves: Nullable<ColorCurves>;
  101352. /**
  101353. * Instantiates a new PBRMaterial instance.
  101354. *
  101355. * @param name The material name
  101356. * @param scene The scene the material will be use in.
  101357. */
  101358. constructor(name: string, scene: Scene);
  101359. /**
  101360. * Returns the name of this material class.
  101361. */
  101362. getClassName(): string;
  101363. /**
  101364. * Makes a duplicate of the current material.
  101365. * @param name - name to use for the new material.
  101366. */
  101367. clone(name: string): PBRMaterial;
  101368. /**
  101369. * Serializes this PBR Material.
  101370. * @returns - An object with the serialized material.
  101371. */
  101372. serialize(): any;
  101373. /**
  101374. * Parses a PBR Material from a serialized object.
  101375. * @param source - Serialized object.
  101376. * @param scene - BJS scene instance.
  101377. * @param rootUrl - url for the scene object
  101378. * @returns - PBRMaterial
  101379. */
  101380. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  101381. }
  101382. }
  101383. declare module BABYLON {
  101384. /** @hidden */
  101385. export var _forceSceneHelpersToBundle: boolean;
  101386. interface Scene {
  101387. /**
  101388. * Creates a default light for the scene.
  101389. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  101390. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  101391. */
  101392. createDefaultLight(replace?: boolean): void;
  101393. /**
  101394. * Creates a default camera for the scene.
  101395. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  101396. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  101397. * @param replace has default false, when true replaces the active camera in the scene
  101398. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  101399. */
  101400. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  101401. /**
  101402. * Creates a default camera and a default light.
  101403. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  101404. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  101405. * @param replace has the default false, when true replaces the active camera/light in the scene
  101406. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  101407. */
  101408. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  101409. /**
  101410. * Creates a new sky box
  101411. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  101412. * @param environmentTexture defines the texture to use as environment texture
  101413. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  101414. * @param scale defines the overall scale of the skybox
  101415. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  101416. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  101417. * @returns a new mesh holding the sky box
  101418. */
  101419. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  101420. /**
  101421. * Creates a new environment
  101422. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  101423. * @param options defines the options you can use to configure the environment
  101424. * @returns the new EnvironmentHelper
  101425. */
  101426. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  101427. /**
  101428. * Creates a new VREXperienceHelper
  101429. * @see http://doc.babylonjs.com/how_to/webvr_helper
  101430. * @param webVROptions defines the options used to create the new VREXperienceHelper
  101431. * @returns a new VREXperienceHelper
  101432. */
  101433. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  101434. /**
  101435. * Creates a new XREXperienceHelper
  101436. * @see http://doc.babylonjs.com/how_to/webxr
  101437. * @returns a promise for a new XREXperienceHelper
  101438. */
  101439. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  101440. }
  101441. }
  101442. declare module BABYLON {
  101443. /**
  101444. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  101445. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  101446. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  101447. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  101448. */
  101449. export class VideoDome extends TransformNode {
  101450. /**
  101451. * Define the video source as a Monoscopic panoramic 360 video.
  101452. */
  101453. static readonly MODE_MONOSCOPIC: number;
  101454. /**
  101455. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  101456. */
  101457. static readonly MODE_TOPBOTTOM: number;
  101458. /**
  101459. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  101460. */
  101461. static readonly MODE_SIDEBYSIDE: number;
  101462. private _useDirectMapping;
  101463. /**
  101464. * The video texture being displayed on the sphere
  101465. */
  101466. protected _videoTexture: VideoTexture;
  101467. /**
  101468. * Gets the video texture being displayed on the sphere
  101469. */
  101470. readonly videoTexture: VideoTexture;
  101471. /**
  101472. * The skybox material
  101473. */
  101474. protected _material: BackgroundMaterial;
  101475. /**
  101476. * The surface used for the skybox
  101477. */
  101478. protected _mesh: Mesh;
  101479. /**
  101480. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  101481. * Also see the options.resolution property.
  101482. */
  101483. fovMultiplier: number;
  101484. private _videoMode;
  101485. /**
  101486. * Gets or set the current video mode for the video. It can be:
  101487. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  101488. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  101489. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  101490. */
  101491. videoMode: number;
  101492. /**
  101493. * Oberserver used in Stereoscopic VR Mode.
  101494. */
  101495. private _onBeforeCameraRenderObserver;
  101496. /**
  101497. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  101498. * @param name Element's name, child elements will append suffixes for their own names.
  101499. * @param urlsOrVideo defines the url(s) or the video element to use
  101500. * @param options An object containing optional or exposed sub element properties
  101501. */
  101502. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  101503. resolution?: number;
  101504. clickToPlay?: boolean;
  101505. autoPlay?: boolean;
  101506. loop?: boolean;
  101507. size?: number;
  101508. poster?: string;
  101509. useDirectMapping?: boolean;
  101510. }, scene: Scene);
  101511. private _changeVideoMode;
  101512. /**
  101513. * Releases resources associated with this node.
  101514. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  101515. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  101516. */
  101517. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  101518. }
  101519. }
  101520. declare module BABYLON {
  101521. /**
  101522. * This class can be used to get instrumentation data from a Babylon engine
  101523. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  101524. */
  101525. export class EngineInstrumentation implements IDisposable {
  101526. /**
  101527. * Define the instrumented engine.
  101528. */
  101529. engine: Engine;
  101530. private _captureGPUFrameTime;
  101531. private _gpuFrameTimeToken;
  101532. private _gpuFrameTime;
  101533. private _captureShaderCompilationTime;
  101534. private _shaderCompilationTime;
  101535. private _onBeginFrameObserver;
  101536. private _onEndFrameObserver;
  101537. private _onBeforeShaderCompilationObserver;
  101538. private _onAfterShaderCompilationObserver;
  101539. /**
  101540. * Gets the perf counter used for GPU frame time
  101541. */
  101542. readonly gpuFrameTimeCounter: PerfCounter;
  101543. /**
  101544. * Gets the GPU frame time capture status
  101545. */
  101546. /**
  101547. * Enable or disable the GPU frame time capture
  101548. */
  101549. captureGPUFrameTime: boolean;
  101550. /**
  101551. * Gets the perf counter used for shader compilation time
  101552. */
  101553. readonly shaderCompilationTimeCounter: PerfCounter;
  101554. /**
  101555. * Gets the shader compilation time capture status
  101556. */
  101557. /**
  101558. * Enable or disable the shader compilation time capture
  101559. */
  101560. captureShaderCompilationTime: boolean;
  101561. /**
  101562. * Instantiates a new engine instrumentation.
  101563. * This class can be used to get instrumentation data from a Babylon engine
  101564. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  101565. * @param engine Defines the engine to instrument
  101566. */
  101567. constructor(
  101568. /**
  101569. * Define the instrumented engine.
  101570. */
  101571. engine: Engine);
  101572. /**
  101573. * Dispose and release associated resources.
  101574. */
  101575. dispose(): void;
  101576. }
  101577. }
  101578. declare module BABYLON {
  101579. /**
  101580. * This class can be used to get instrumentation data from a Babylon engine
  101581. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  101582. */
  101583. export class SceneInstrumentation implements IDisposable {
  101584. /**
  101585. * Defines the scene to instrument
  101586. */
  101587. scene: Scene;
  101588. private _captureActiveMeshesEvaluationTime;
  101589. private _activeMeshesEvaluationTime;
  101590. private _captureRenderTargetsRenderTime;
  101591. private _renderTargetsRenderTime;
  101592. private _captureFrameTime;
  101593. private _frameTime;
  101594. private _captureRenderTime;
  101595. private _renderTime;
  101596. private _captureInterFrameTime;
  101597. private _interFrameTime;
  101598. private _captureParticlesRenderTime;
  101599. private _particlesRenderTime;
  101600. private _captureSpritesRenderTime;
  101601. private _spritesRenderTime;
  101602. private _capturePhysicsTime;
  101603. private _physicsTime;
  101604. private _captureAnimationsTime;
  101605. private _animationsTime;
  101606. private _captureCameraRenderTime;
  101607. private _cameraRenderTime;
  101608. private _onBeforeActiveMeshesEvaluationObserver;
  101609. private _onAfterActiveMeshesEvaluationObserver;
  101610. private _onBeforeRenderTargetsRenderObserver;
  101611. private _onAfterRenderTargetsRenderObserver;
  101612. private _onAfterRenderObserver;
  101613. private _onBeforeDrawPhaseObserver;
  101614. private _onAfterDrawPhaseObserver;
  101615. private _onBeforeAnimationsObserver;
  101616. private _onBeforeParticlesRenderingObserver;
  101617. private _onAfterParticlesRenderingObserver;
  101618. private _onBeforeSpritesRenderingObserver;
  101619. private _onAfterSpritesRenderingObserver;
  101620. private _onBeforePhysicsObserver;
  101621. private _onAfterPhysicsObserver;
  101622. private _onAfterAnimationsObserver;
  101623. private _onBeforeCameraRenderObserver;
  101624. private _onAfterCameraRenderObserver;
  101625. /**
  101626. * Gets the perf counter used for active meshes evaluation time
  101627. */
  101628. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  101629. /**
  101630. * Gets the active meshes evaluation time capture status
  101631. */
  101632. /**
  101633. * Enable or disable the active meshes evaluation time capture
  101634. */
  101635. captureActiveMeshesEvaluationTime: boolean;
  101636. /**
  101637. * Gets the perf counter used for render targets render time
  101638. */
  101639. readonly renderTargetsRenderTimeCounter: PerfCounter;
  101640. /**
  101641. * Gets the render targets render time capture status
  101642. */
  101643. /**
  101644. * Enable or disable the render targets render time capture
  101645. */
  101646. captureRenderTargetsRenderTime: boolean;
  101647. /**
  101648. * Gets the perf counter used for particles render time
  101649. */
  101650. readonly particlesRenderTimeCounter: PerfCounter;
  101651. /**
  101652. * Gets the particles render time capture status
  101653. */
  101654. /**
  101655. * Enable or disable the particles render time capture
  101656. */
  101657. captureParticlesRenderTime: boolean;
  101658. /**
  101659. * Gets the perf counter used for sprites render time
  101660. */
  101661. readonly spritesRenderTimeCounter: PerfCounter;
  101662. /**
  101663. * Gets the sprites render time capture status
  101664. */
  101665. /**
  101666. * Enable or disable the sprites render time capture
  101667. */
  101668. captureSpritesRenderTime: boolean;
  101669. /**
  101670. * Gets the perf counter used for physics time
  101671. */
  101672. readonly physicsTimeCounter: PerfCounter;
  101673. /**
  101674. * Gets the physics time capture status
  101675. */
  101676. /**
  101677. * Enable or disable the physics time capture
  101678. */
  101679. capturePhysicsTime: boolean;
  101680. /**
  101681. * Gets the perf counter used for animations time
  101682. */
  101683. readonly animationsTimeCounter: PerfCounter;
  101684. /**
  101685. * Gets the animations time capture status
  101686. */
  101687. /**
  101688. * Enable or disable the animations time capture
  101689. */
  101690. captureAnimationsTime: boolean;
  101691. /**
  101692. * Gets the perf counter used for frame time capture
  101693. */
  101694. readonly frameTimeCounter: PerfCounter;
  101695. /**
  101696. * Gets the frame time capture status
  101697. */
  101698. /**
  101699. * Enable or disable the frame time capture
  101700. */
  101701. captureFrameTime: boolean;
  101702. /**
  101703. * Gets the perf counter used for inter-frames time capture
  101704. */
  101705. readonly interFrameTimeCounter: PerfCounter;
  101706. /**
  101707. * Gets the inter-frames time capture status
  101708. */
  101709. /**
  101710. * Enable or disable the inter-frames time capture
  101711. */
  101712. captureInterFrameTime: boolean;
  101713. /**
  101714. * Gets the perf counter used for render time capture
  101715. */
  101716. readonly renderTimeCounter: PerfCounter;
  101717. /**
  101718. * Gets the render time capture status
  101719. */
  101720. /**
  101721. * Enable or disable the render time capture
  101722. */
  101723. captureRenderTime: boolean;
  101724. /**
  101725. * Gets the perf counter used for camera render time capture
  101726. */
  101727. readonly cameraRenderTimeCounter: PerfCounter;
  101728. /**
  101729. * Gets the camera render time capture status
  101730. */
  101731. /**
  101732. * Enable or disable the camera render time capture
  101733. */
  101734. captureCameraRenderTime: boolean;
  101735. /**
  101736. * Gets the perf counter used for draw calls
  101737. */
  101738. readonly drawCallsCounter: PerfCounter;
  101739. /**
  101740. * Gets the perf counter used for texture collisions
  101741. */
  101742. readonly textureCollisionsCounter: PerfCounter;
  101743. /**
  101744. * Instantiates a new scene instrumentation.
  101745. * This class can be used to get instrumentation data from a Babylon engine
  101746. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  101747. * @param scene Defines the scene to instrument
  101748. */
  101749. constructor(
  101750. /**
  101751. * Defines the scene to instrument
  101752. */
  101753. scene: Scene);
  101754. /**
  101755. * Dispose and release associated resources.
  101756. */
  101757. dispose(): void;
  101758. }
  101759. }
  101760. declare module BABYLON {
  101761. /** @hidden */
  101762. export var glowMapGenerationPixelShader: {
  101763. name: string;
  101764. shader: string;
  101765. };
  101766. }
  101767. declare module BABYLON {
  101768. /** @hidden */
  101769. export var glowMapGenerationVertexShader: {
  101770. name: string;
  101771. shader: string;
  101772. };
  101773. }
  101774. declare module BABYLON {
  101775. /**
  101776. * Effect layer options. This helps customizing the behaviour
  101777. * of the effect layer.
  101778. */
  101779. export interface IEffectLayerOptions {
  101780. /**
  101781. * Multiplication factor apply to the canvas size to compute the render target size
  101782. * used to generated the objects (the smaller the faster).
  101783. */
  101784. mainTextureRatio: number;
  101785. /**
  101786. * Enforces a fixed size texture to ensure effect stability across devices.
  101787. */
  101788. mainTextureFixedSize?: number;
  101789. /**
  101790. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  101791. */
  101792. alphaBlendingMode: number;
  101793. /**
  101794. * The camera attached to the layer.
  101795. */
  101796. camera: Nullable<Camera>;
  101797. /**
  101798. * The rendering group to draw the layer in.
  101799. */
  101800. renderingGroupId: number;
  101801. }
  101802. /**
  101803. * The effect layer Helps adding post process effect blended with the main pass.
  101804. *
  101805. * This can be for instance use to generate glow or higlight effects on the scene.
  101806. *
  101807. * The effect layer class can not be used directly and is intented to inherited from to be
  101808. * customized per effects.
  101809. */
  101810. export abstract class EffectLayer {
  101811. private _vertexBuffers;
  101812. private _indexBuffer;
  101813. private _cachedDefines;
  101814. private _effectLayerMapGenerationEffect;
  101815. private _effectLayerOptions;
  101816. private _mergeEffect;
  101817. protected _scene: Scene;
  101818. protected _engine: Engine;
  101819. protected _maxSize: number;
  101820. protected _mainTextureDesiredSize: ISize;
  101821. protected _mainTexture: RenderTargetTexture;
  101822. protected _shouldRender: boolean;
  101823. protected _postProcesses: PostProcess[];
  101824. protected _textures: BaseTexture[];
  101825. protected _emissiveTextureAndColor: {
  101826. texture: Nullable<BaseTexture>;
  101827. color: Color4;
  101828. };
  101829. /**
  101830. * The name of the layer
  101831. */
  101832. name: string;
  101833. /**
  101834. * The clear color of the texture used to generate the glow map.
  101835. */
  101836. neutralColor: Color4;
  101837. /**
  101838. * Specifies wether the highlight layer is enabled or not.
  101839. */
  101840. isEnabled: boolean;
  101841. /**
  101842. * Gets the camera attached to the layer.
  101843. */
  101844. readonly camera: Nullable<Camera>;
  101845. /**
  101846. * Gets the rendering group id the layer should render in.
  101847. */
  101848. readonly renderingGroupId: number;
  101849. /**
  101850. * An event triggered when the effect layer has been disposed.
  101851. */
  101852. onDisposeObservable: Observable<EffectLayer>;
  101853. /**
  101854. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  101855. */
  101856. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  101857. /**
  101858. * An event triggered when the generated texture is being merged in the scene.
  101859. */
  101860. onBeforeComposeObservable: Observable<EffectLayer>;
  101861. /**
  101862. * An event triggered when the generated texture has been merged in the scene.
  101863. */
  101864. onAfterComposeObservable: Observable<EffectLayer>;
  101865. /**
  101866. * An event triggered when the efffect layer changes its size.
  101867. */
  101868. onSizeChangedObservable: Observable<EffectLayer>;
  101869. /** @hidden */
  101870. static _SceneComponentInitialization: (scene: Scene) => void;
  101871. /**
  101872. * Instantiates a new effect Layer and references it in the scene.
  101873. * @param name The name of the layer
  101874. * @param scene The scene to use the layer in
  101875. */
  101876. constructor(
  101877. /** The Friendly of the effect in the scene */
  101878. name: string, scene: Scene);
  101879. /**
  101880. * Get the effect name of the layer.
  101881. * @return The effect name
  101882. */
  101883. abstract getEffectName(): string;
  101884. /**
  101885. * Checks for the readiness of the element composing the layer.
  101886. * @param subMesh the mesh to check for
  101887. * @param useInstances specify wether or not to use instances to render the mesh
  101888. * @return true if ready otherwise, false
  101889. */
  101890. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  101891. /**
  101892. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  101893. * @returns true if the effect requires stencil during the main canvas render pass.
  101894. */
  101895. abstract needStencil(): boolean;
  101896. /**
  101897. * Create the merge effect. This is the shader use to blit the information back
  101898. * to the main canvas at the end of the scene rendering.
  101899. * @returns The effect containing the shader used to merge the effect on the main canvas
  101900. */
  101901. protected abstract _createMergeEffect(): Effect;
  101902. /**
  101903. * Creates the render target textures and post processes used in the effect layer.
  101904. */
  101905. protected abstract _createTextureAndPostProcesses(): void;
  101906. /**
  101907. * Implementation specific of rendering the generating effect on the main canvas.
  101908. * @param effect The effect used to render through
  101909. */
  101910. protected abstract _internalRender(effect: Effect): void;
  101911. /**
  101912. * Sets the required values for both the emissive texture and and the main color.
  101913. */
  101914. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  101915. /**
  101916. * Free any resources and references associated to a mesh.
  101917. * Internal use
  101918. * @param mesh The mesh to free.
  101919. */
  101920. abstract _disposeMesh(mesh: Mesh): void;
  101921. /**
  101922. * Serializes this layer (Glow or Highlight for example)
  101923. * @returns a serialized layer object
  101924. */
  101925. abstract serialize?(): any;
  101926. /**
  101927. * Initializes the effect layer with the required options.
  101928. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  101929. */
  101930. protected _init(options: Partial<IEffectLayerOptions>): void;
  101931. /**
  101932. * Generates the index buffer of the full screen quad blending to the main canvas.
  101933. */
  101934. private _generateIndexBuffer;
  101935. /**
  101936. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  101937. */
  101938. private _genrateVertexBuffer;
  101939. /**
  101940. * Sets the main texture desired size which is the closest power of two
  101941. * of the engine canvas size.
  101942. */
  101943. private _setMainTextureSize;
  101944. /**
  101945. * Creates the main texture for the effect layer.
  101946. */
  101947. protected _createMainTexture(): void;
  101948. /**
  101949. * Adds specific effects defines.
  101950. * @param defines The defines to add specifics to.
  101951. */
  101952. protected _addCustomEffectDefines(defines: string[]): void;
  101953. /**
  101954. * Checks for the readiness of the element composing the layer.
  101955. * @param subMesh the mesh to check for
  101956. * @param useInstances specify wether or not to use instances to render the mesh
  101957. * @param emissiveTexture the associated emissive texture used to generate the glow
  101958. * @return true if ready otherwise, false
  101959. */
  101960. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  101961. /**
  101962. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  101963. */
  101964. render(): void;
  101965. /**
  101966. * Determine if a given mesh will be used in the current effect.
  101967. * @param mesh mesh to test
  101968. * @returns true if the mesh will be used
  101969. */
  101970. hasMesh(mesh: AbstractMesh): boolean;
  101971. /**
  101972. * Returns true if the layer contains information to display, otherwise false.
  101973. * @returns true if the glow layer should be rendered
  101974. */
  101975. shouldRender(): boolean;
  101976. /**
  101977. * Returns true if the mesh should render, otherwise false.
  101978. * @param mesh The mesh to render
  101979. * @returns true if it should render otherwise false
  101980. */
  101981. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  101982. /**
  101983. * Returns true if the mesh can be rendered, otherwise false.
  101984. * @param mesh The mesh to render
  101985. * @param material The material used on the mesh
  101986. * @returns true if it can be rendered otherwise false
  101987. */
  101988. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  101989. /**
  101990. * Returns true if the mesh should render, otherwise false.
  101991. * @param mesh The mesh to render
  101992. * @returns true if it should render otherwise false
  101993. */
  101994. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  101995. /**
  101996. * Renders the submesh passed in parameter to the generation map.
  101997. */
  101998. protected _renderSubMesh(subMesh: SubMesh): void;
  101999. /**
  102000. * Rebuild the required buffers.
  102001. * @hidden Internal use only.
  102002. */
  102003. _rebuild(): void;
  102004. /**
  102005. * Dispose only the render target textures and post process.
  102006. */
  102007. private _disposeTextureAndPostProcesses;
  102008. /**
  102009. * Dispose the highlight layer and free resources.
  102010. */
  102011. dispose(): void;
  102012. /**
  102013. * Gets the class name of the effect layer
  102014. * @returns the string with the class name of the effect layer
  102015. */
  102016. getClassName(): string;
  102017. /**
  102018. * Creates an effect layer from parsed effect layer data
  102019. * @param parsedEffectLayer defines effect layer data
  102020. * @param scene defines the current scene
  102021. * @param rootUrl defines the root URL containing the effect layer information
  102022. * @returns a parsed effect Layer
  102023. */
  102024. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  102025. }
  102026. }
  102027. declare module BABYLON {
  102028. interface AbstractScene {
  102029. /**
  102030. * The list of effect layers (highlights/glow) added to the scene
  102031. * @see http://doc.babylonjs.com/how_to/highlight_layer
  102032. * @see http://doc.babylonjs.com/how_to/glow_layer
  102033. */
  102034. effectLayers: Array<EffectLayer>;
  102035. /**
  102036. * Removes the given effect layer from this scene.
  102037. * @param toRemove defines the effect layer to remove
  102038. * @returns the index of the removed effect layer
  102039. */
  102040. removeEffectLayer(toRemove: EffectLayer): number;
  102041. /**
  102042. * Adds the given effect layer to this scene
  102043. * @param newEffectLayer defines the effect layer to add
  102044. */
  102045. addEffectLayer(newEffectLayer: EffectLayer): void;
  102046. }
  102047. /**
  102048. * Defines the layer scene component responsible to manage any effect layers
  102049. * in a given scene.
  102050. */
  102051. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  102052. /**
  102053. * The component name helpfull to identify the component in the list of scene components.
  102054. */
  102055. readonly name: string;
  102056. /**
  102057. * The scene the component belongs to.
  102058. */
  102059. scene: Scene;
  102060. private _engine;
  102061. private _renderEffects;
  102062. private _needStencil;
  102063. private _previousStencilState;
  102064. /**
  102065. * Creates a new instance of the component for the given scene
  102066. * @param scene Defines the scene to register the component in
  102067. */
  102068. constructor(scene: Scene);
  102069. /**
  102070. * Registers the component in a given scene
  102071. */
  102072. register(): void;
  102073. /**
  102074. * Rebuilds the elements related to this component in case of
  102075. * context lost for instance.
  102076. */
  102077. rebuild(): void;
  102078. /**
  102079. * Serializes the component data to the specified json object
  102080. * @param serializationObject The object to serialize to
  102081. */
  102082. serialize(serializationObject: any): void;
  102083. /**
  102084. * Adds all the element from the container to the scene
  102085. * @param container the container holding the elements
  102086. */
  102087. addFromContainer(container: AbstractScene): void;
  102088. /**
  102089. * Removes all the elements in the container from the scene
  102090. * @param container contains the elements to remove
  102091. */
  102092. removeFromContainer(container: AbstractScene): void;
  102093. /**
  102094. * Disposes the component and the associated ressources.
  102095. */
  102096. dispose(): void;
  102097. private _isReadyForMesh;
  102098. private _renderMainTexture;
  102099. private _setStencil;
  102100. private _setStencilBack;
  102101. private _draw;
  102102. private _drawCamera;
  102103. private _drawRenderingGroup;
  102104. }
  102105. }
  102106. declare module BABYLON {
  102107. /** @hidden */
  102108. export var glowMapMergePixelShader: {
  102109. name: string;
  102110. shader: string;
  102111. };
  102112. }
  102113. declare module BABYLON {
  102114. /** @hidden */
  102115. export var glowMapMergeVertexShader: {
  102116. name: string;
  102117. shader: string;
  102118. };
  102119. }
  102120. declare module BABYLON {
  102121. interface AbstractScene {
  102122. /**
  102123. * Return a the first highlight layer of the scene with a given name.
  102124. * @param name The name of the highlight layer to look for.
  102125. * @return The highlight layer if found otherwise null.
  102126. */
  102127. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  102128. }
  102129. /**
  102130. * Glow layer options. This helps customizing the behaviour
  102131. * of the glow layer.
  102132. */
  102133. export interface IGlowLayerOptions {
  102134. /**
  102135. * Multiplication factor apply to the canvas size to compute the render target size
  102136. * used to generated the glowing objects (the smaller the faster).
  102137. */
  102138. mainTextureRatio: number;
  102139. /**
  102140. * Enforces a fixed size texture to ensure resize independant blur.
  102141. */
  102142. mainTextureFixedSize?: number;
  102143. /**
  102144. * How big is the kernel of the blur texture.
  102145. */
  102146. blurKernelSize: number;
  102147. /**
  102148. * The camera attached to the layer.
  102149. */
  102150. camera: Nullable<Camera>;
  102151. /**
  102152. * Enable MSAA by chosing the number of samples.
  102153. */
  102154. mainTextureSamples?: number;
  102155. /**
  102156. * The rendering group to draw the layer in.
  102157. */
  102158. renderingGroupId: number;
  102159. }
  102160. /**
  102161. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  102162. *
  102163. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  102164. * glowy meshes to your scene.
  102165. *
  102166. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  102167. */
  102168. export class GlowLayer extends EffectLayer {
  102169. /**
  102170. * Effect Name of the layer.
  102171. */
  102172. static readonly EffectName: string;
  102173. /**
  102174. * The default blur kernel size used for the glow.
  102175. */
  102176. static DefaultBlurKernelSize: number;
  102177. /**
  102178. * The default texture size ratio used for the glow.
  102179. */
  102180. static DefaultTextureRatio: number;
  102181. /**
  102182. * Sets the kernel size of the blur.
  102183. */
  102184. /**
  102185. * Gets the kernel size of the blur.
  102186. */
  102187. blurKernelSize: number;
  102188. /**
  102189. * Sets the glow intensity.
  102190. */
  102191. /**
  102192. * Gets the glow intensity.
  102193. */
  102194. intensity: number;
  102195. private _options;
  102196. private _intensity;
  102197. private _horizontalBlurPostprocess1;
  102198. private _verticalBlurPostprocess1;
  102199. private _horizontalBlurPostprocess2;
  102200. private _verticalBlurPostprocess2;
  102201. private _blurTexture1;
  102202. private _blurTexture2;
  102203. private _postProcesses1;
  102204. private _postProcesses2;
  102205. private _includedOnlyMeshes;
  102206. private _excludedMeshes;
  102207. /**
  102208. * Callback used to let the user override the color selection on a per mesh basis
  102209. */
  102210. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  102211. /**
  102212. * Callback used to let the user override the texture selection on a per mesh basis
  102213. */
  102214. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  102215. /**
  102216. * Instantiates a new glow Layer and references it to the scene.
  102217. * @param name The name of the layer
  102218. * @param scene The scene to use the layer in
  102219. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  102220. */
  102221. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  102222. /**
  102223. * Get the effect name of the layer.
  102224. * @return The effect name
  102225. */
  102226. getEffectName(): string;
  102227. /**
  102228. * Create the merge effect. This is the shader use to blit the information back
  102229. * to the main canvas at the end of the scene rendering.
  102230. */
  102231. protected _createMergeEffect(): Effect;
  102232. /**
  102233. * Creates the render target textures and post processes used in the glow layer.
  102234. */
  102235. protected _createTextureAndPostProcesses(): void;
  102236. /**
  102237. * Checks for the readiness of the element composing the layer.
  102238. * @param subMesh the mesh to check for
  102239. * @param useInstances specify wether or not to use instances to render the mesh
  102240. * @param emissiveTexture the associated emissive texture used to generate the glow
  102241. * @return true if ready otherwise, false
  102242. */
  102243. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  102244. /**
  102245. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  102246. */
  102247. needStencil(): boolean;
  102248. /**
  102249. * Returns true if the mesh can be rendered, otherwise false.
  102250. * @param mesh The mesh to render
  102251. * @param material The material used on the mesh
  102252. * @returns true if it can be rendered otherwise false
  102253. */
  102254. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  102255. /**
  102256. * Implementation specific of rendering the generating effect on the main canvas.
  102257. * @param effect The effect used to render through
  102258. */
  102259. protected _internalRender(effect: Effect): void;
  102260. /**
  102261. * Sets the required values for both the emissive texture and and the main color.
  102262. */
  102263. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  102264. /**
  102265. * Returns true if the mesh should render, otherwise false.
  102266. * @param mesh The mesh to render
  102267. * @returns true if it should render otherwise false
  102268. */
  102269. protected _shouldRenderMesh(mesh: Mesh): boolean;
  102270. /**
  102271. * Adds specific effects defines.
  102272. * @param defines The defines to add specifics to.
  102273. */
  102274. protected _addCustomEffectDefines(defines: string[]): void;
  102275. /**
  102276. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  102277. * @param mesh The mesh to exclude from the glow layer
  102278. */
  102279. addExcludedMesh(mesh: Mesh): void;
  102280. /**
  102281. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  102282. * @param mesh The mesh to remove
  102283. */
  102284. removeExcludedMesh(mesh: Mesh): void;
  102285. /**
  102286. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  102287. * @param mesh The mesh to include in the glow layer
  102288. */
  102289. addIncludedOnlyMesh(mesh: Mesh): void;
  102290. /**
  102291. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  102292. * @param mesh The mesh to remove
  102293. */
  102294. removeIncludedOnlyMesh(mesh: Mesh): void;
  102295. /**
  102296. * Determine if a given mesh will be used in the glow layer
  102297. * @param mesh The mesh to test
  102298. * @returns true if the mesh will be highlighted by the current glow layer
  102299. */
  102300. hasMesh(mesh: AbstractMesh): boolean;
  102301. /**
  102302. * Free any resources and references associated to a mesh.
  102303. * Internal use
  102304. * @param mesh The mesh to free.
  102305. * @hidden
  102306. */
  102307. _disposeMesh(mesh: Mesh): void;
  102308. /**
  102309. * Gets the class name of the effect layer
  102310. * @returns the string with the class name of the effect layer
  102311. */
  102312. getClassName(): string;
  102313. /**
  102314. * Serializes this glow layer
  102315. * @returns a serialized glow layer object
  102316. */
  102317. serialize(): any;
  102318. /**
  102319. * Creates a Glow Layer from parsed glow layer data
  102320. * @param parsedGlowLayer defines glow layer data
  102321. * @param scene defines the current scene
  102322. * @param rootUrl defines the root URL containing the glow layer information
  102323. * @returns a parsed Glow Layer
  102324. */
  102325. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  102326. }
  102327. }
  102328. declare module BABYLON {
  102329. /** @hidden */
  102330. export var glowBlurPostProcessPixelShader: {
  102331. name: string;
  102332. shader: string;
  102333. };
  102334. }
  102335. declare module BABYLON {
  102336. interface AbstractScene {
  102337. /**
  102338. * Return a the first highlight layer of the scene with a given name.
  102339. * @param name The name of the highlight layer to look for.
  102340. * @return The highlight layer if found otherwise null.
  102341. */
  102342. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  102343. }
  102344. /**
  102345. * Highlight layer options. This helps customizing the behaviour
  102346. * of the highlight layer.
  102347. */
  102348. export interface IHighlightLayerOptions {
  102349. /**
  102350. * Multiplication factor apply to the canvas size to compute the render target size
  102351. * used to generated the glowing objects (the smaller the faster).
  102352. */
  102353. mainTextureRatio: number;
  102354. /**
  102355. * Enforces a fixed size texture to ensure resize independant blur.
  102356. */
  102357. mainTextureFixedSize?: number;
  102358. /**
  102359. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  102360. * of the picture to blur (the smaller the faster).
  102361. */
  102362. blurTextureSizeRatio: number;
  102363. /**
  102364. * How big in texel of the blur texture is the vertical blur.
  102365. */
  102366. blurVerticalSize: number;
  102367. /**
  102368. * How big in texel of the blur texture is the horizontal blur.
  102369. */
  102370. blurHorizontalSize: number;
  102371. /**
  102372. * Alpha blending mode used to apply the blur. Default is combine.
  102373. */
  102374. alphaBlendingMode: number;
  102375. /**
  102376. * The camera attached to the layer.
  102377. */
  102378. camera: Nullable<Camera>;
  102379. /**
  102380. * Should we display highlight as a solid stroke?
  102381. */
  102382. isStroke?: boolean;
  102383. /**
  102384. * The rendering group to draw the layer in.
  102385. */
  102386. renderingGroupId: number;
  102387. }
  102388. /**
  102389. * The highlight layer Helps adding a glow effect around a mesh.
  102390. *
  102391. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  102392. * glowy meshes to your scene.
  102393. *
  102394. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  102395. */
  102396. export class HighlightLayer extends EffectLayer {
  102397. name: string;
  102398. /**
  102399. * Effect Name of the highlight layer.
  102400. */
  102401. static readonly EffectName: string;
  102402. /**
  102403. * The neutral color used during the preparation of the glow effect.
  102404. * This is black by default as the blend operation is a blend operation.
  102405. */
  102406. static NeutralColor: Color4;
  102407. /**
  102408. * Stencil value used for glowing meshes.
  102409. */
  102410. static GlowingMeshStencilReference: number;
  102411. /**
  102412. * Stencil value used for the other meshes in the scene.
  102413. */
  102414. static NormalMeshStencilReference: number;
  102415. /**
  102416. * Specifies whether or not the inner glow is ACTIVE in the layer.
  102417. */
  102418. innerGlow: boolean;
  102419. /**
  102420. * Specifies whether or not the outer glow is ACTIVE in the layer.
  102421. */
  102422. outerGlow: boolean;
  102423. /**
  102424. * Specifies the horizontal size of the blur.
  102425. */
  102426. /**
  102427. * Gets the horizontal size of the blur.
  102428. */
  102429. blurHorizontalSize: number;
  102430. /**
  102431. * Specifies the vertical size of the blur.
  102432. */
  102433. /**
  102434. * Gets the vertical size of the blur.
  102435. */
  102436. blurVerticalSize: number;
  102437. /**
  102438. * An event triggered when the highlight layer is being blurred.
  102439. */
  102440. onBeforeBlurObservable: Observable<HighlightLayer>;
  102441. /**
  102442. * An event triggered when the highlight layer has been blurred.
  102443. */
  102444. onAfterBlurObservable: Observable<HighlightLayer>;
  102445. private _instanceGlowingMeshStencilReference;
  102446. private _options;
  102447. private _downSamplePostprocess;
  102448. private _horizontalBlurPostprocess;
  102449. private _verticalBlurPostprocess;
  102450. private _blurTexture;
  102451. private _meshes;
  102452. private _excludedMeshes;
  102453. /**
  102454. * Instantiates a new highlight Layer and references it to the scene..
  102455. * @param name The name of the layer
  102456. * @param scene The scene to use the layer in
  102457. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  102458. */
  102459. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  102460. /**
  102461. * Get the effect name of the layer.
  102462. * @return The effect name
  102463. */
  102464. getEffectName(): string;
  102465. /**
  102466. * Create the merge effect. This is the shader use to blit the information back
  102467. * to the main canvas at the end of the scene rendering.
  102468. */
  102469. protected _createMergeEffect(): Effect;
  102470. /**
  102471. * Creates the render target textures and post processes used in the highlight layer.
  102472. */
  102473. protected _createTextureAndPostProcesses(): void;
  102474. /**
  102475. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  102476. */
  102477. needStencil(): boolean;
  102478. /**
  102479. * Checks for the readiness of the element composing the layer.
  102480. * @param subMesh the mesh to check for
  102481. * @param useInstances specify wether or not to use instances to render the mesh
  102482. * @param emissiveTexture the associated emissive texture used to generate the glow
  102483. * @return true if ready otherwise, false
  102484. */
  102485. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  102486. /**
  102487. * Implementation specific of rendering the generating effect on the main canvas.
  102488. * @param effect The effect used to render through
  102489. */
  102490. protected _internalRender(effect: Effect): void;
  102491. /**
  102492. * Returns true if the layer contains information to display, otherwise false.
  102493. */
  102494. shouldRender(): boolean;
  102495. /**
  102496. * Returns true if the mesh should render, otherwise false.
  102497. * @param mesh The mesh to render
  102498. * @returns true if it should render otherwise false
  102499. */
  102500. protected _shouldRenderMesh(mesh: Mesh): boolean;
  102501. /**
  102502. * Sets the required values for both the emissive texture and and the main color.
  102503. */
  102504. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  102505. /**
  102506. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  102507. * @param mesh The mesh to exclude from the highlight layer
  102508. */
  102509. addExcludedMesh(mesh: Mesh): void;
  102510. /**
  102511. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  102512. * @param mesh The mesh to highlight
  102513. */
  102514. removeExcludedMesh(mesh: Mesh): void;
  102515. /**
  102516. * Determine if a given mesh will be highlighted by the current HighlightLayer
  102517. * @param mesh mesh to test
  102518. * @returns true if the mesh will be highlighted by the current HighlightLayer
  102519. */
  102520. hasMesh(mesh: AbstractMesh): boolean;
  102521. /**
  102522. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  102523. * @param mesh The mesh to highlight
  102524. * @param color The color of the highlight
  102525. * @param glowEmissiveOnly Extract the glow from the emissive texture
  102526. */
  102527. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  102528. /**
  102529. * Remove a mesh from the highlight layer in order to make it stop glowing.
  102530. * @param mesh The mesh to highlight
  102531. */
  102532. removeMesh(mesh: Mesh): void;
  102533. /**
  102534. * Force the stencil to the normal expected value for none glowing parts
  102535. */
  102536. private _defaultStencilReference;
  102537. /**
  102538. * Free any resources and references associated to a mesh.
  102539. * Internal use
  102540. * @param mesh The mesh to free.
  102541. * @hidden
  102542. */
  102543. _disposeMesh(mesh: Mesh): void;
  102544. /**
  102545. * Dispose the highlight layer and free resources.
  102546. */
  102547. dispose(): void;
  102548. /**
  102549. * Gets the class name of the effect layer
  102550. * @returns the string with the class name of the effect layer
  102551. */
  102552. getClassName(): string;
  102553. /**
  102554. * Serializes this Highlight layer
  102555. * @returns a serialized Highlight layer object
  102556. */
  102557. serialize(): any;
  102558. /**
  102559. * Creates a Highlight layer from parsed Highlight layer data
  102560. * @param parsedHightlightLayer defines the Highlight layer data
  102561. * @param scene defines the current scene
  102562. * @param rootUrl defines the root URL containing the Highlight layer information
  102563. * @returns a parsed Highlight layer
  102564. */
  102565. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  102566. }
  102567. }
  102568. declare module BABYLON {
  102569. /** @hidden */
  102570. export var lensFlarePixelShader: {
  102571. name: string;
  102572. shader: string;
  102573. };
  102574. }
  102575. declare module BABYLON {
  102576. /** @hidden */
  102577. export var lensFlareVertexShader: {
  102578. name: string;
  102579. shader: string;
  102580. };
  102581. }
  102582. declare module BABYLON {
  102583. /**
  102584. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  102585. * It is usually composed of several `lensFlare`.
  102586. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  102587. */
  102588. export class LensFlareSystem {
  102589. /**
  102590. * Define the name of the lens flare system
  102591. */
  102592. name: string;
  102593. /**
  102594. * List of lens flares used in this system.
  102595. */
  102596. lensFlares: LensFlare[];
  102597. /**
  102598. * Define a limit from the border the lens flare can be visible.
  102599. */
  102600. borderLimit: number;
  102601. /**
  102602. * Define a viewport border we do not want to see the lens flare in.
  102603. */
  102604. viewportBorder: number;
  102605. /**
  102606. * Define a predicate which could limit the list of meshes able to occlude the effect.
  102607. */
  102608. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  102609. /**
  102610. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  102611. */
  102612. layerMask: number;
  102613. /**
  102614. * Define the id of the lens flare system in the scene.
  102615. * (equal to name by default)
  102616. */
  102617. id: string;
  102618. private _scene;
  102619. private _emitter;
  102620. private _vertexBuffers;
  102621. private _indexBuffer;
  102622. private _effect;
  102623. private _positionX;
  102624. private _positionY;
  102625. private _isEnabled;
  102626. /** @hidden */
  102627. static _SceneComponentInitialization: (scene: Scene) => void;
  102628. /**
  102629. * Instantiates a lens flare system.
  102630. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  102631. * It is usually composed of several `lensFlare`.
  102632. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  102633. * @param name Define the name of the lens flare system in the scene
  102634. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  102635. * @param scene Define the scene the lens flare system belongs to
  102636. */
  102637. constructor(
  102638. /**
  102639. * Define the name of the lens flare system
  102640. */
  102641. name: string, emitter: any, scene: Scene);
  102642. /**
  102643. * Define if the lens flare system is enabled.
  102644. */
  102645. isEnabled: boolean;
  102646. /**
  102647. * Get the scene the effects belongs to.
  102648. * @returns the scene holding the lens flare system
  102649. */
  102650. getScene(): Scene;
  102651. /**
  102652. * Get the emitter of the lens flare system.
  102653. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  102654. * @returns the emitter of the lens flare system
  102655. */
  102656. getEmitter(): any;
  102657. /**
  102658. * Set the emitter of the lens flare system.
  102659. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  102660. * @param newEmitter Define the new emitter of the system
  102661. */
  102662. setEmitter(newEmitter: any): void;
  102663. /**
  102664. * Get the lens flare system emitter position.
  102665. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  102666. * @returns the position
  102667. */
  102668. getEmitterPosition(): Vector3;
  102669. /**
  102670. * @hidden
  102671. */
  102672. computeEffectivePosition(globalViewport: Viewport): boolean;
  102673. /** @hidden */
  102674. _isVisible(): boolean;
  102675. /**
  102676. * @hidden
  102677. */
  102678. render(): boolean;
  102679. /**
  102680. * Dispose and release the lens flare with its associated resources.
  102681. */
  102682. dispose(): void;
  102683. /**
  102684. * Parse a lens flare system from a JSON repressentation
  102685. * @param parsedLensFlareSystem Define the JSON to parse
  102686. * @param scene Define the scene the parsed system should be instantiated in
  102687. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  102688. * @returns the parsed system
  102689. */
  102690. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  102691. /**
  102692. * Serialize the current Lens Flare System into a JSON representation.
  102693. * @returns the serialized JSON
  102694. */
  102695. serialize(): any;
  102696. }
  102697. }
  102698. declare module BABYLON {
  102699. /**
  102700. * This represents one of the lens effect in a `lensFlareSystem`.
  102701. * It controls one of the indiviual texture used in the effect.
  102702. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  102703. */
  102704. export class LensFlare {
  102705. /**
  102706. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  102707. */
  102708. size: number;
  102709. /**
  102710. * 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.
  102711. */
  102712. position: number;
  102713. /**
  102714. * Define the lens color.
  102715. */
  102716. color: Color3;
  102717. /**
  102718. * Define the lens texture.
  102719. */
  102720. texture: Nullable<Texture>;
  102721. /**
  102722. * Define the alpha mode to render this particular lens.
  102723. */
  102724. alphaMode: number;
  102725. private _system;
  102726. /**
  102727. * Creates a new Lens Flare.
  102728. * This represents one of the lens effect in a `lensFlareSystem`.
  102729. * It controls one of the indiviual texture used in the effect.
  102730. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  102731. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  102732. * @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.
  102733. * @param color Define the lens color
  102734. * @param imgUrl Define the lens texture url
  102735. * @param system Define the `lensFlareSystem` this flare is part of
  102736. * @returns The newly created Lens Flare
  102737. */
  102738. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  102739. /**
  102740. * Instantiates a new Lens Flare.
  102741. * This represents one of the lens effect in a `lensFlareSystem`.
  102742. * It controls one of the indiviual texture used in the effect.
  102743. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  102744. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  102745. * @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.
  102746. * @param color Define the lens color
  102747. * @param imgUrl Define the lens texture url
  102748. * @param system Define the `lensFlareSystem` this flare is part of
  102749. */
  102750. constructor(
  102751. /**
  102752. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  102753. */
  102754. size: number,
  102755. /**
  102756. * 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.
  102757. */
  102758. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  102759. /**
  102760. * Dispose and release the lens flare with its associated resources.
  102761. */
  102762. dispose(): void;
  102763. }
  102764. }
  102765. declare module BABYLON {
  102766. interface AbstractScene {
  102767. /**
  102768. * The list of lens flare system added to the scene
  102769. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  102770. */
  102771. lensFlareSystems: Array<LensFlareSystem>;
  102772. /**
  102773. * Removes the given lens flare system from this scene.
  102774. * @param toRemove The lens flare system to remove
  102775. * @returns The index of the removed lens flare system
  102776. */
  102777. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  102778. /**
  102779. * Adds the given lens flare system to this scene
  102780. * @param newLensFlareSystem The lens flare system to add
  102781. */
  102782. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  102783. /**
  102784. * Gets a lens flare system using its name
  102785. * @param name defines the name to look for
  102786. * @returns the lens flare system or null if not found
  102787. */
  102788. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  102789. /**
  102790. * Gets a lens flare system using its id
  102791. * @param id defines the id to look for
  102792. * @returns the lens flare system or null if not found
  102793. */
  102794. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  102795. }
  102796. /**
  102797. * Defines the lens flare scene component responsible to manage any lens flares
  102798. * in a given scene.
  102799. */
  102800. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  102801. /**
  102802. * The component name helpfull to identify the component in the list of scene components.
  102803. */
  102804. readonly name: string;
  102805. /**
  102806. * The scene the component belongs to.
  102807. */
  102808. scene: Scene;
  102809. /**
  102810. * Creates a new instance of the component for the given scene
  102811. * @param scene Defines the scene to register the component in
  102812. */
  102813. constructor(scene: Scene);
  102814. /**
  102815. * Registers the component in a given scene
  102816. */
  102817. register(): void;
  102818. /**
  102819. * Rebuilds the elements related to this component in case of
  102820. * context lost for instance.
  102821. */
  102822. rebuild(): void;
  102823. /**
  102824. * Adds all the element from the container to the scene
  102825. * @param container the container holding the elements
  102826. */
  102827. addFromContainer(container: AbstractScene): void;
  102828. /**
  102829. * Removes all the elements in the container from the scene
  102830. * @param container contains the elements to remove
  102831. */
  102832. removeFromContainer(container: AbstractScene): void;
  102833. /**
  102834. * Serializes the component data to the specified json object
  102835. * @param serializationObject The object to serialize to
  102836. */
  102837. serialize(serializationObject: any): void;
  102838. /**
  102839. * Disposes the component and the associated ressources.
  102840. */
  102841. dispose(): void;
  102842. private _draw;
  102843. }
  102844. }
  102845. declare module BABYLON {
  102846. /**
  102847. * Defines the shadow generator component responsible to manage any shadow generators
  102848. * in a given scene.
  102849. */
  102850. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  102851. /**
  102852. * The component name helpfull to identify the component in the list of scene components.
  102853. */
  102854. readonly name: string;
  102855. /**
  102856. * The scene the component belongs to.
  102857. */
  102858. scene: Scene;
  102859. /**
  102860. * Creates a new instance of the component for the given scene
  102861. * @param scene Defines the scene to register the component in
  102862. */
  102863. constructor(scene: Scene);
  102864. /**
  102865. * Registers the component in a given scene
  102866. */
  102867. register(): void;
  102868. /**
  102869. * Rebuilds the elements related to this component in case of
  102870. * context lost for instance.
  102871. */
  102872. rebuild(): void;
  102873. /**
  102874. * Serializes the component data to the specified json object
  102875. * @param serializationObject The object to serialize to
  102876. */
  102877. serialize(serializationObject: any): void;
  102878. /**
  102879. * Adds all the element from the container to the scene
  102880. * @param container the container holding the elements
  102881. */
  102882. addFromContainer(container: AbstractScene): void;
  102883. /**
  102884. * Removes all the elements in the container from the scene
  102885. * @param container contains the elements to remove
  102886. */
  102887. removeFromContainer(container: AbstractScene): void;
  102888. /**
  102889. * Rebuilds the elements related to this component in case of
  102890. * context lost for instance.
  102891. */
  102892. dispose(): void;
  102893. private _gatherRenderTargets;
  102894. }
  102895. }
  102896. declare module BABYLON {
  102897. /**
  102898. * A directional light is defined by a direction (what a surprise!).
  102899. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  102900. * 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.
  102901. * Documentation: https://doc.babylonjs.com/babylon101/lights
  102902. */
  102903. export class DirectionalLight extends ShadowLight {
  102904. private _shadowFrustumSize;
  102905. /**
  102906. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  102907. */
  102908. /**
  102909. * Specifies a fix frustum size for the shadow generation.
  102910. */
  102911. shadowFrustumSize: number;
  102912. private _shadowOrthoScale;
  102913. /**
  102914. * Gets the shadow projection scale against the optimal computed one.
  102915. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  102916. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  102917. */
  102918. /**
  102919. * Sets the shadow projection scale against the optimal computed one.
  102920. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  102921. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  102922. */
  102923. shadowOrthoScale: number;
  102924. /**
  102925. * Automatically compute the projection matrix to best fit (including all the casters)
  102926. * on each frame.
  102927. */
  102928. autoUpdateExtends: boolean;
  102929. private _orthoLeft;
  102930. private _orthoRight;
  102931. private _orthoTop;
  102932. private _orthoBottom;
  102933. /**
  102934. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  102935. * The directional light is emitted from everywhere in the given direction.
  102936. * It can cast shadows.
  102937. * Documentation : https://doc.babylonjs.com/babylon101/lights
  102938. * @param name The friendly name of the light
  102939. * @param direction The direction of the light
  102940. * @param scene The scene the light belongs to
  102941. */
  102942. constructor(name: string, direction: Vector3, scene: Scene);
  102943. /**
  102944. * Returns the string "DirectionalLight".
  102945. * @return The class name
  102946. */
  102947. getClassName(): string;
  102948. /**
  102949. * Returns the integer 1.
  102950. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  102951. */
  102952. getTypeID(): number;
  102953. /**
  102954. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  102955. * Returns the DirectionalLight Shadow projection matrix.
  102956. */
  102957. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  102958. /**
  102959. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  102960. * Returns the DirectionalLight Shadow projection matrix.
  102961. */
  102962. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  102963. /**
  102964. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  102965. * Returns the DirectionalLight Shadow projection matrix.
  102966. */
  102967. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  102968. protected _buildUniformLayout(): void;
  102969. /**
  102970. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  102971. * @param effect The effect to update
  102972. * @param lightIndex The index of the light in the effect to update
  102973. * @returns The directional light
  102974. */
  102975. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  102976. /**
  102977. * Gets the minZ used for shadow according to both the scene and the light.
  102978. *
  102979. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  102980. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  102981. * @param activeCamera The camera we are returning the min for
  102982. * @returns the depth min z
  102983. */
  102984. getDepthMinZ(activeCamera: Camera): number;
  102985. /**
  102986. * Gets the maxZ used for shadow according to both the scene and the light.
  102987. *
  102988. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  102989. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  102990. * @param activeCamera The camera we are returning the max for
  102991. * @returns the depth max z
  102992. */
  102993. getDepthMaxZ(activeCamera: Camera): number;
  102994. /**
  102995. * Prepares the list of defines specific to the light type.
  102996. * @param defines the list of defines
  102997. * @param lightIndex defines the index of the light for the effect
  102998. */
  102999. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  103000. }
  103001. }
  103002. declare module BABYLON {
  103003. /**
  103004. * A point light is a light defined by an unique point in world space.
  103005. * The light is emitted in every direction from this point.
  103006. * A good example of a point light is a standard light bulb.
  103007. * Documentation: https://doc.babylonjs.com/babylon101/lights
  103008. */
  103009. export class PointLight extends ShadowLight {
  103010. private _shadowAngle;
  103011. /**
  103012. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  103013. * This specifies what angle the shadow will use to be created.
  103014. *
  103015. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  103016. */
  103017. /**
  103018. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  103019. * This specifies what angle the shadow will use to be created.
  103020. *
  103021. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  103022. */
  103023. shadowAngle: number;
  103024. /**
  103025. * Gets the direction if it has been set.
  103026. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  103027. */
  103028. /**
  103029. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  103030. */
  103031. direction: Vector3;
  103032. /**
  103033. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  103034. * A PointLight emits the light in every direction.
  103035. * It can cast shadows.
  103036. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  103037. * ```javascript
  103038. * var pointLight = new PointLight("pl", camera.position, scene);
  103039. * ```
  103040. * Documentation : https://doc.babylonjs.com/babylon101/lights
  103041. * @param name The light friendly name
  103042. * @param position The position of the point light in the scene
  103043. * @param scene The scene the lights belongs to
  103044. */
  103045. constructor(name: string, position: Vector3, scene: Scene);
  103046. /**
  103047. * Returns the string "PointLight"
  103048. * @returns the class name
  103049. */
  103050. getClassName(): string;
  103051. /**
  103052. * Returns the integer 0.
  103053. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  103054. */
  103055. getTypeID(): number;
  103056. /**
  103057. * Specifies wether or not the shadowmap should be a cube texture.
  103058. * @returns true if the shadowmap needs to be a cube texture.
  103059. */
  103060. needCube(): boolean;
  103061. /**
  103062. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  103063. * @param faceIndex The index of the face we are computed the direction to generate shadow
  103064. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  103065. */
  103066. getShadowDirection(faceIndex?: number): Vector3;
  103067. /**
  103068. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  103069. * - fov = PI / 2
  103070. * - aspect ratio : 1.0
  103071. * - z-near and far equal to the active camera minZ and maxZ.
  103072. * Returns the PointLight.
  103073. */
  103074. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  103075. protected _buildUniformLayout(): void;
  103076. /**
  103077. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  103078. * @param effect The effect to update
  103079. * @param lightIndex The index of the light in the effect to update
  103080. * @returns The point light
  103081. */
  103082. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  103083. /**
  103084. * Prepares the list of defines specific to the light type.
  103085. * @param defines the list of defines
  103086. * @param lightIndex defines the index of the light for the effect
  103087. */
  103088. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  103089. }
  103090. }
  103091. declare module BABYLON {
  103092. /**
  103093. * A spot light is defined by a position, a direction, an angle, and an exponent.
  103094. * These values define a cone of light starting from the position, emitting toward the direction.
  103095. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  103096. * and the exponent defines the speed of the decay of the light with distance (reach).
  103097. * Documentation: https://doc.babylonjs.com/babylon101/lights
  103098. */
  103099. export class SpotLight extends ShadowLight {
  103100. private _angle;
  103101. private _innerAngle;
  103102. private _cosHalfAngle;
  103103. private _lightAngleScale;
  103104. private _lightAngleOffset;
  103105. /**
  103106. * Gets the cone angle of the spot light in Radians.
  103107. */
  103108. /**
  103109. * Sets the cone angle of the spot light in Radians.
  103110. */
  103111. angle: number;
  103112. /**
  103113. * Only used in gltf falloff mode, this defines the angle where
  103114. * the directional falloff will start before cutting at angle which could be seen
  103115. * as outer angle.
  103116. */
  103117. /**
  103118. * Only used in gltf falloff mode, this defines the angle where
  103119. * the directional falloff will start before cutting at angle which could be seen
  103120. * as outer angle.
  103121. */
  103122. innerAngle: number;
  103123. private _shadowAngleScale;
  103124. /**
  103125. * Allows scaling the angle of the light for shadow generation only.
  103126. */
  103127. /**
  103128. * Allows scaling the angle of the light for shadow generation only.
  103129. */
  103130. shadowAngleScale: number;
  103131. /**
  103132. * The light decay speed with the distance from the emission spot.
  103133. */
  103134. exponent: number;
  103135. private _projectionTextureMatrix;
  103136. /**
  103137. * Allows reading the projecton texture
  103138. */
  103139. readonly projectionTextureMatrix: Matrix;
  103140. protected _projectionTextureLightNear: number;
  103141. /**
  103142. * Gets the near clip of the Spotlight for texture projection.
  103143. */
  103144. /**
  103145. * Sets the near clip of the Spotlight for texture projection.
  103146. */
  103147. projectionTextureLightNear: number;
  103148. protected _projectionTextureLightFar: number;
  103149. /**
  103150. * Gets the far clip of the Spotlight for texture projection.
  103151. */
  103152. /**
  103153. * Sets the far clip of the Spotlight for texture projection.
  103154. */
  103155. projectionTextureLightFar: number;
  103156. protected _projectionTextureUpDirection: Vector3;
  103157. /**
  103158. * Gets the Up vector of the Spotlight for texture projection.
  103159. */
  103160. /**
  103161. * Sets the Up vector of the Spotlight for texture projection.
  103162. */
  103163. projectionTextureUpDirection: Vector3;
  103164. private _projectionTexture;
  103165. /**
  103166. * Gets the projection texture of the light.
  103167. */
  103168. /**
  103169. * Sets the projection texture of the light.
  103170. */
  103171. projectionTexture: Nullable<BaseTexture>;
  103172. private _projectionTextureViewLightDirty;
  103173. private _projectionTextureProjectionLightDirty;
  103174. private _projectionTextureDirty;
  103175. private _projectionTextureViewTargetVector;
  103176. private _projectionTextureViewLightMatrix;
  103177. private _projectionTextureProjectionLightMatrix;
  103178. private _projectionTextureScalingMatrix;
  103179. /**
  103180. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  103181. * It can cast shadows.
  103182. * Documentation : https://doc.babylonjs.com/babylon101/lights
  103183. * @param name The light friendly name
  103184. * @param position The position of the spot light in the scene
  103185. * @param direction The direction of the light in the scene
  103186. * @param angle The cone angle of the light in Radians
  103187. * @param exponent The light decay speed with the distance from the emission spot
  103188. * @param scene The scene the lights belongs to
  103189. */
  103190. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  103191. /**
  103192. * Returns the string "SpotLight".
  103193. * @returns the class name
  103194. */
  103195. getClassName(): string;
  103196. /**
  103197. * Returns the integer 2.
  103198. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  103199. */
  103200. getTypeID(): number;
  103201. /**
  103202. * Overrides the direction setter to recompute the projection texture view light Matrix.
  103203. */
  103204. protected _setDirection(value: Vector3): void;
  103205. /**
  103206. * Overrides the position setter to recompute the projection texture view light Matrix.
  103207. */
  103208. protected _setPosition(value: Vector3): void;
  103209. /**
  103210. * 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.
  103211. * Returns the SpotLight.
  103212. */
  103213. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  103214. protected _computeProjectionTextureViewLightMatrix(): void;
  103215. protected _computeProjectionTextureProjectionLightMatrix(): void;
  103216. /**
  103217. * Main function for light texture projection matrix computing.
  103218. */
  103219. protected _computeProjectionTextureMatrix(): void;
  103220. protected _buildUniformLayout(): void;
  103221. private _computeAngleValues;
  103222. /**
  103223. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  103224. * @param effect The effect to update
  103225. * @param lightIndex The index of the light in the effect to update
  103226. * @returns The spot light
  103227. */
  103228. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  103229. /**
  103230. * Disposes the light and the associated resources.
  103231. */
  103232. dispose(): void;
  103233. /**
  103234. * Prepares the list of defines specific to the light type.
  103235. * @param defines the list of defines
  103236. * @param lightIndex defines the index of the light for the effect
  103237. */
  103238. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  103239. }
  103240. }
  103241. declare module BABYLON {
  103242. /**
  103243. * Header information of HDR texture files.
  103244. */
  103245. export interface HDRInfo {
  103246. /**
  103247. * The height of the texture in pixels.
  103248. */
  103249. height: number;
  103250. /**
  103251. * The width of the texture in pixels.
  103252. */
  103253. width: number;
  103254. /**
  103255. * The index of the beginning of the data in the binary file.
  103256. */
  103257. dataPosition: number;
  103258. }
  103259. /**
  103260. * This groups tools to convert HDR texture to native colors array.
  103261. */
  103262. export class HDRTools {
  103263. private static Ldexp;
  103264. private static Rgbe2float;
  103265. private static readStringLine;
  103266. /**
  103267. * Reads header information from an RGBE texture stored in a native array.
  103268. * More information on this format are available here:
  103269. * https://en.wikipedia.org/wiki/RGBE_image_format
  103270. *
  103271. * @param uint8array The binary file stored in native array.
  103272. * @return The header information.
  103273. */
  103274. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  103275. /**
  103276. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  103277. * This RGBE texture needs to store the information as a panorama.
  103278. *
  103279. * More information on this format are available here:
  103280. * https://en.wikipedia.org/wiki/RGBE_image_format
  103281. *
  103282. * @param buffer The binary file stored in an array buffer.
  103283. * @param size The expected size of the extracted cubemap.
  103284. * @return The Cube Map information.
  103285. */
  103286. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  103287. /**
  103288. * Returns the pixels data extracted from an RGBE texture.
  103289. * This pixels will be stored left to right up to down in the R G B order in one array.
  103290. *
  103291. * More information on this format are available here:
  103292. * https://en.wikipedia.org/wiki/RGBE_image_format
  103293. *
  103294. * @param uint8array The binary file stored in an array buffer.
  103295. * @param hdrInfo The header information of the file.
  103296. * @return The pixels data in RGB right to left up to down order.
  103297. */
  103298. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  103299. private static RGBE_ReadPixels_RLE;
  103300. }
  103301. }
  103302. declare module BABYLON {
  103303. /**
  103304. * This represents a texture coming from an HDR input.
  103305. *
  103306. * The only supported format is currently panorama picture stored in RGBE format.
  103307. * Example of such files can be found on HDRLib: http://hdrlib.com/
  103308. */
  103309. export class HDRCubeTexture extends BaseTexture {
  103310. private static _facesMapping;
  103311. private _generateHarmonics;
  103312. private _noMipmap;
  103313. private _textureMatrix;
  103314. private _size;
  103315. private _onLoad;
  103316. private _onError;
  103317. /**
  103318. * The texture URL.
  103319. */
  103320. url: string;
  103321. /**
  103322. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  103323. */
  103324. coordinatesMode: number;
  103325. protected _isBlocking: boolean;
  103326. /**
  103327. * Sets wether or not the texture is blocking during loading.
  103328. */
  103329. /**
  103330. * Gets wether or not the texture is blocking during loading.
  103331. */
  103332. isBlocking: boolean;
  103333. protected _rotationY: number;
  103334. /**
  103335. * Sets texture matrix rotation angle around Y axis in radians.
  103336. */
  103337. /**
  103338. * Gets texture matrix rotation angle around Y axis radians.
  103339. */
  103340. rotationY: number;
  103341. /**
  103342. * Gets or sets the center of the bounding box associated with the cube texture
  103343. * It must define where the camera used to render the texture was set
  103344. */
  103345. boundingBoxPosition: Vector3;
  103346. private _boundingBoxSize;
  103347. /**
  103348. * Gets or sets the size of the bounding box associated with the cube texture
  103349. * When defined, the cubemap will switch to local mode
  103350. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  103351. * @example https://www.babylonjs-playground.com/#RNASML
  103352. */
  103353. boundingBoxSize: Vector3;
  103354. /**
  103355. * Instantiates an HDRTexture from the following parameters.
  103356. *
  103357. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  103358. * @param scene The scene the texture will be used in
  103359. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  103360. * @param noMipmap Forces to not generate the mipmap if true
  103361. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  103362. * @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)
  103363. * @param reserved Reserved flag for internal use.
  103364. */
  103365. 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>);
  103366. /**
  103367. * Get the current class name of the texture useful for serialization or dynamic coding.
  103368. * @returns "HDRCubeTexture"
  103369. */
  103370. getClassName(): string;
  103371. /**
  103372. * Occurs when the file is raw .hdr file.
  103373. */
  103374. private loadTexture;
  103375. clone(): HDRCubeTexture;
  103376. delayLoad(): void;
  103377. /**
  103378. * Get the texture reflection matrix used to rotate/transform the reflection.
  103379. * @returns the reflection matrix
  103380. */
  103381. getReflectionTextureMatrix(): Matrix;
  103382. /**
  103383. * Set the texture reflection matrix used to rotate/transform the reflection.
  103384. * @param value Define the reflection matrix to set
  103385. */
  103386. setReflectionTextureMatrix(value: Matrix): void;
  103387. /**
  103388. * Parses a JSON representation of an HDR Texture in order to create the texture
  103389. * @param parsedTexture Define the JSON representation
  103390. * @param scene Define the scene the texture should be created in
  103391. * @param rootUrl Define the root url in case we need to load relative dependencies
  103392. * @returns the newly created texture after parsing
  103393. */
  103394. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  103395. serialize(): any;
  103396. }
  103397. }
  103398. declare module BABYLON {
  103399. /**
  103400. * Class used to control physics engine
  103401. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  103402. */
  103403. export class PhysicsEngine implements IPhysicsEngine {
  103404. private _physicsPlugin;
  103405. /**
  103406. * Global value used to control the smallest number supported by the simulation
  103407. */
  103408. static Epsilon: number;
  103409. private _impostors;
  103410. private _joints;
  103411. /**
  103412. * Gets the gravity vector used by the simulation
  103413. */
  103414. gravity: Vector3;
  103415. /**
  103416. * Factory used to create the default physics plugin.
  103417. * @returns The default physics plugin
  103418. */
  103419. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  103420. /**
  103421. * Creates a new Physics Engine
  103422. * @param gravity defines the gravity vector used by the simulation
  103423. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  103424. */
  103425. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  103426. /**
  103427. * Sets the gravity vector used by the simulation
  103428. * @param gravity defines the gravity vector to use
  103429. */
  103430. setGravity(gravity: Vector3): void;
  103431. /**
  103432. * Set the time step of the physics engine.
  103433. * Default is 1/60.
  103434. * To slow it down, enter 1/600 for example.
  103435. * To speed it up, 1/30
  103436. * @param newTimeStep defines the new timestep to apply to this world.
  103437. */
  103438. setTimeStep(newTimeStep?: number): void;
  103439. /**
  103440. * Get the time step of the physics engine.
  103441. * @returns the current time step
  103442. */
  103443. getTimeStep(): number;
  103444. /**
  103445. * Release all resources
  103446. */
  103447. dispose(): void;
  103448. /**
  103449. * Gets the name of the current physics plugin
  103450. * @returns the name of the plugin
  103451. */
  103452. getPhysicsPluginName(): string;
  103453. /**
  103454. * Adding a new impostor for the impostor tracking.
  103455. * This will be done by the impostor itself.
  103456. * @param impostor the impostor to add
  103457. */
  103458. addImpostor(impostor: PhysicsImpostor): void;
  103459. /**
  103460. * Remove an impostor from the engine.
  103461. * This impostor and its mesh will not longer be updated by the physics engine.
  103462. * @param impostor the impostor to remove
  103463. */
  103464. removeImpostor(impostor: PhysicsImpostor): void;
  103465. /**
  103466. * Add a joint to the physics engine
  103467. * @param mainImpostor defines the main impostor to which the joint is added.
  103468. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  103469. * @param joint defines the joint that will connect both impostors.
  103470. */
  103471. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  103472. /**
  103473. * Removes a joint from the simulation
  103474. * @param mainImpostor defines the impostor used with the joint
  103475. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  103476. * @param joint defines the joint to remove
  103477. */
  103478. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  103479. /**
  103480. * Called by the scene. No need to call it.
  103481. * @param delta defines the timespam between frames
  103482. */
  103483. _step(delta: number): void;
  103484. /**
  103485. * Gets the current plugin used to run the simulation
  103486. * @returns current plugin
  103487. */
  103488. getPhysicsPlugin(): IPhysicsEnginePlugin;
  103489. /**
  103490. * Gets the list of physic impostors
  103491. * @returns an array of PhysicsImpostor
  103492. */
  103493. getImpostors(): Array<PhysicsImpostor>;
  103494. /**
  103495. * Gets the impostor for a physics enabled object
  103496. * @param object defines the object impersonated by the impostor
  103497. * @returns the PhysicsImpostor or null if not found
  103498. */
  103499. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  103500. /**
  103501. * Gets the impostor for a physics body object
  103502. * @param body defines physics body used by the impostor
  103503. * @returns the PhysicsImpostor or null if not found
  103504. */
  103505. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  103506. }
  103507. }
  103508. declare module BABYLON {
  103509. /** @hidden */
  103510. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  103511. private _useDeltaForWorldStep;
  103512. world: any;
  103513. name: string;
  103514. private _physicsMaterials;
  103515. private _fixedTimeStep;
  103516. BJSCANNON: any;
  103517. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  103518. setGravity(gravity: Vector3): void;
  103519. setTimeStep(timeStep: number): void;
  103520. getTimeStep(): number;
  103521. executeStep(delta: number): void;
  103522. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  103523. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  103524. generatePhysicsBody(impostor: PhysicsImpostor): void;
  103525. private _processChildMeshes;
  103526. removePhysicsBody(impostor: PhysicsImpostor): void;
  103527. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  103528. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  103529. private _addMaterial;
  103530. private _checkWithEpsilon;
  103531. private _createShape;
  103532. private _createHeightmap;
  103533. private _minus90X;
  103534. private _plus90X;
  103535. private _tmpPosition;
  103536. private _tmpDeltaPosition;
  103537. private _tmpUnityRotation;
  103538. private _updatePhysicsBodyTransformation;
  103539. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  103540. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  103541. isSupported(): boolean;
  103542. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  103543. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  103544. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  103545. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  103546. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  103547. getBodyMass(impostor: PhysicsImpostor): number;
  103548. getBodyFriction(impostor: PhysicsImpostor): number;
  103549. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  103550. getBodyRestitution(impostor: PhysicsImpostor): number;
  103551. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  103552. sleepBody(impostor: PhysicsImpostor): void;
  103553. wakeUpBody(impostor: PhysicsImpostor): void;
  103554. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  103555. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  103556. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  103557. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  103558. getRadius(impostor: PhysicsImpostor): number;
  103559. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  103560. dispose(): void;
  103561. private _extendNamespace;
  103562. }
  103563. }
  103564. declare module BABYLON {
  103565. /** @hidden */
  103566. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  103567. world: any;
  103568. name: string;
  103569. BJSOIMO: any;
  103570. constructor(iterations?: number, oimoInjection?: any);
  103571. setGravity(gravity: Vector3): void;
  103572. setTimeStep(timeStep: number): void;
  103573. getTimeStep(): number;
  103574. private _tmpImpostorsArray;
  103575. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  103576. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  103577. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  103578. generatePhysicsBody(impostor: PhysicsImpostor): void;
  103579. private _tmpPositionVector;
  103580. removePhysicsBody(impostor: PhysicsImpostor): void;
  103581. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  103582. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  103583. isSupported(): boolean;
  103584. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  103585. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  103586. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  103587. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  103588. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  103589. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  103590. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  103591. getBodyMass(impostor: PhysicsImpostor): number;
  103592. getBodyFriction(impostor: PhysicsImpostor): number;
  103593. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  103594. getBodyRestitution(impostor: PhysicsImpostor): number;
  103595. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  103596. sleepBody(impostor: PhysicsImpostor): void;
  103597. wakeUpBody(impostor: PhysicsImpostor): void;
  103598. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  103599. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  103600. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  103601. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  103602. getRadius(impostor: PhysicsImpostor): number;
  103603. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  103604. dispose(): void;
  103605. }
  103606. }
  103607. declare module BABYLON {
  103608. interface AbstractScene {
  103609. /**
  103610. * The list of reflection probes added to the scene
  103611. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  103612. */
  103613. reflectionProbes: Array<ReflectionProbe>;
  103614. /**
  103615. * Removes the given reflection probe from this scene.
  103616. * @param toRemove The reflection probe to remove
  103617. * @returns The index of the removed reflection probe
  103618. */
  103619. removeReflectionProbe(toRemove: ReflectionProbe): number;
  103620. /**
  103621. * Adds the given reflection probe to this scene.
  103622. * @param newReflectionProbe The reflection probe to add
  103623. */
  103624. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  103625. }
  103626. /**
  103627. * Class used to generate realtime reflection / refraction cube textures
  103628. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  103629. */
  103630. export class ReflectionProbe {
  103631. /** defines the name of the probe */
  103632. name: string;
  103633. private _scene;
  103634. private _renderTargetTexture;
  103635. private _projectionMatrix;
  103636. private _viewMatrix;
  103637. private _target;
  103638. private _add;
  103639. private _attachedMesh;
  103640. private _invertYAxis;
  103641. /** Gets or sets probe position (center of the cube map) */
  103642. position: Vector3;
  103643. /**
  103644. * Creates a new reflection probe
  103645. * @param name defines the name of the probe
  103646. * @param size defines the texture resolution (for each face)
  103647. * @param scene defines the hosting scene
  103648. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  103649. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  103650. */
  103651. constructor(
  103652. /** defines the name of the probe */
  103653. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  103654. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  103655. samples: number;
  103656. /** Gets or sets the refresh rate to use (on every frame by default) */
  103657. refreshRate: number;
  103658. /**
  103659. * Gets the hosting scene
  103660. * @returns a Scene
  103661. */
  103662. getScene(): Scene;
  103663. /** Gets the internal CubeTexture used to render to */
  103664. readonly cubeTexture: RenderTargetTexture;
  103665. /** Gets the list of meshes to render */
  103666. readonly renderList: Nullable<AbstractMesh[]>;
  103667. /**
  103668. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  103669. * @param mesh defines the mesh to attach to
  103670. */
  103671. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  103672. /**
  103673. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  103674. * @param renderingGroupId The rendering group id corresponding to its index
  103675. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  103676. */
  103677. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  103678. /**
  103679. * Clean all associated resources
  103680. */
  103681. dispose(): void;
  103682. /**
  103683. * Converts the reflection probe information to a readable string for debug purpose.
  103684. * @param fullDetails Supports for multiple levels of logging within scene loading
  103685. * @returns the human readable reflection probe info
  103686. */
  103687. toString(fullDetails?: boolean): string;
  103688. /**
  103689. * Get the class name of the relfection probe.
  103690. * @returns "ReflectionProbe"
  103691. */
  103692. getClassName(): string;
  103693. /**
  103694. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  103695. * @returns The JSON representation of the texture
  103696. */
  103697. serialize(): any;
  103698. /**
  103699. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  103700. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  103701. * @param scene Define the scene the parsed reflection probe should be instantiated in
  103702. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  103703. * @returns The parsed reflection probe if successful
  103704. */
  103705. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  103706. }
  103707. }
  103708. declare module BABYLON {
  103709. /** @hidden */
  103710. export var _BabylonLoaderRegistered: boolean;
  103711. }
  103712. declare module BABYLON {
  103713. /**
  103714. * The Physically based simple base material of BJS.
  103715. *
  103716. * This enables better naming and convention enforcements on top of the pbrMaterial.
  103717. * It is used as the base class for both the specGloss and metalRough conventions.
  103718. */
  103719. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  103720. /**
  103721. * Number of Simultaneous lights allowed on the material.
  103722. */
  103723. maxSimultaneousLights: number;
  103724. /**
  103725. * If sets to true, disables all the lights affecting the material.
  103726. */
  103727. disableLighting: boolean;
  103728. /**
  103729. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  103730. */
  103731. environmentTexture: BaseTexture;
  103732. /**
  103733. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  103734. */
  103735. invertNormalMapX: boolean;
  103736. /**
  103737. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  103738. */
  103739. invertNormalMapY: boolean;
  103740. /**
  103741. * Normal map used in the model.
  103742. */
  103743. normalTexture: BaseTexture;
  103744. /**
  103745. * Emissivie color used to self-illuminate the model.
  103746. */
  103747. emissiveColor: Color3;
  103748. /**
  103749. * Emissivie texture used to self-illuminate the model.
  103750. */
  103751. emissiveTexture: BaseTexture;
  103752. /**
  103753. * Occlusion Channel Strenght.
  103754. */
  103755. occlusionStrength: number;
  103756. /**
  103757. * Occlusion Texture of the material (adding extra occlusion effects).
  103758. */
  103759. occlusionTexture: BaseTexture;
  103760. /**
  103761. * Defines the alpha limits in alpha test mode.
  103762. */
  103763. alphaCutOff: number;
  103764. /**
  103765. * Gets the current double sided mode.
  103766. */
  103767. /**
  103768. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  103769. */
  103770. doubleSided: boolean;
  103771. /**
  103772. * Stores the pre-calculated light information of a mesh in a texture.
  103773. */
  103774. lightmapTexture: BaseTexture;
  103775. /**
  103776. * If true, the light map contains occlusion information instead of lighting info.
  103777. */
  103778. useLightmapAsShadowmap: boolean;
  103779. /**
  103780. * Instantiates a new PBRMaterial instance.
  103781. *
  103782. * @param name The material name
  103783. * @param scene The scene the material will be use in.
  103784. */
  103785. constructor(name: string, scene: Scene);
  103786. getClassName(): string;
  103787. }
  103788. }
  103789. declare module BABYLON {
  103790. /**
  103791. * The PBR material of BJS following the metal roughness convention.
  103792. *
  103793. * This fits to the PBR convention in the GLTF definition:
  103794. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  103795. */
  103796. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  103797. /**
  103798. * The base color has two different interpretations depending on the value of metalness.
  103799. * When the material is a metal, the base color is the specific measured reflectance value
  103800. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  103801. * of the material.
  103802. */
  103803. baseColor: Color3;
  103804. /**
  103805. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  103806. * well as opacity information in the alpha channel.
  103807. */
  103808. baseTexture: BaseTexture;
  103809. /**
  103810. * Specifies the metallic scalar value of the material.
  103811. * Can also be used to scale the metalness values of the metallic texture.
  103812. */
  103813. metallic: number;
  103814. /**
  103815. * Specifies the roughness scalar value of the material.
  103816. * Can also be used to scale the roughness values of the metallic texture.
  103817. */
  103818. roughness: number;
  103819. /**
  103820. * Texture containing both the metallic value in the B channel and the
  103821. * roughness value in the G channel to keep better precision.
  103822. */
  103823. metallicRoughnessTexture: BaseTexture;
  103824. /**
  103825. * Instantiates a new PBRMetalRoughnessMaterial instance.
  103826. *
  103827. * @param name The material name
  103828. * @param scene The scene the material will be use in.
  103829. */
  103830. constructor(name: string, scene: Scene);
  103831. /**
  103832. * Return the currrent class name of the material.
  103833. */
  103834. getClassName(): string;
  103835. /**
  103836. * Makes a duplicate of the current material.
  103837. * @param name - name to use for the new material.
  103838. */
  103839. clone(name: string): PBRMetallicRoughnessMaterial;
  103840. /**
  103841. * Serialize the material to a parsable JSON object.
  103842. */
  103843. serialize(): any;
  103844. /**
  103845. * Parses a JSON object correponding to the serialize function.
  103846. */
  103847. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  103848. }
  103849. }
  103850. declare module BABYLON {
  103851. /**
  103852. * The PBR material of BJS following the specular glossiness convention.
  103853. *
  103854. * This fits to the PBR convention in the GLTF definition:
  103855. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  103856. */
  103857. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  103858. /**
  103859. * Specifies the diffuse color of the material.
  103860. */
  103861. diffuseColor: Color3;
  103862. /**
  103863. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  103864. * channel.
  103865. */
  103866. diffuseTexture: BaseTexture;
  103867. /**
  103868. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  103869. */
  103870. specularColor: Color3;
  103871. /**
  103872. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  103873. */
  103874. glossiness: number;
  103875. /**
  103876. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  103877. */
  103878. specularGlossinessTexture: BaseTexture;
  103879. /**
  103880. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  103881. *
  103882. * @param name The material name
  103883. * @param scene The scene the material will be use in.
  103884. */
  103885. constructor(name: string, scene: Scene);
  103886. /**
  103887. * Return the currrent class name of the material.
  103888. */
  103889. getClassName(): string;
  103890. /**
  103891. * Makes a duplicate of the current material.
  103892. * @param name - name to use for the new material.
  103893. */
  103894. clone(name: string): PBRSpecularGlossinessMaterial;
  103895. /**
  103896. * Serialize the material to a parsable JSON object.
  103897. */
  103898. serialize(): any;
  103899. /**
  103900. * Parses a JSON object correponding to the serialize function.
  103901. */
  103902. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  103903. }
  103904. }
  103905. declare module BABYLON {
  103906. /**
  103907. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  103908. * It can help converting any input color in a desired output one. This can then be used to create effects
  103909. * from sepia, black and white to sixties or futuristic rendering...
  103910. *
  103911. * The only supported format is currently 3dl.
  103912. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  103913. */
  103914. export class ColorGradingTexture extends BaseTexture {
  103915. /**
  103916. * The current texture matrix. (will always be identity in color grading texture)
  103917. */
  103918. private _textureMatrix;
  103919. /**
  103920. * The texture URL.
  103921. */
  103922. url: string;
  103923. /**
  103924. * Empty line regex stored for GC.
  103925. */
  103926. private static _noneEmptyLineRegex;
  103927. private _engine;
  103928. /**
  103929. * Instantiates a ColorGradingTexture from the following parameters.
  103930. *
  103931. * @param url The location of the color gradind data (currently only supporting 3dl)
  103932. * @param scene The scene the texture will be used in
  103933. */
  103934. constructor(url: string, scene: Scene);
  103935. /**
  103936. * Returns the texture matrix used in most of the material.
  103937. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  103938. */
  103939. getTextureMatrix(): Matrix;
  103940. /**
  103941. * Occurs when the file being loaded is a .3dl LUT file.
  103942. */
  103943. private load3dlTexture;
  103944. /**
  103945. * Starts the loading process of the texture.
  103946. */
  103947. private loadTexture;
  103948. /**
  103949. * Clones the color gradind texture.
  103950. */
  103951. clone(): ColorGradingTexture;
  103952. /**
  103953. * Called during delayed load for textures.
  103954. */
  103955. delayLoad(): void;
  103956. /**
  103957. * Parses a color grading texture serialized by Babylon.
  103958. * @param parsedTexture The texture information being parsedTexture
  103959. * @param scene The scene to load the texture in
  103960. * @param rootUrl The root url of the data assets to load
  103961. * @return A color gradind texture
  103962. */
  103963. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  103964. /**
  103965. * Serializes the LUT texture to json format.
  103966. */
  103967. serialize(): any;
  103968. }
  103969. }
  103970. declare module BABYLON {
  103971. /**
  103972. * Direct draw surface info
  103973. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  103974. */
  103975. export interface DDSInfo {
  103976. /**
  103977. * Width of the texture
  103978. */
  103979. width: number;
  103980. /**
  103981. * Width of the texture
  103982. */
  103983. height: number;
  103984. /**
  103985. * Number of Mipmaps for the texture
  103986. * @see https://en.wikipedia.org/wiki/Mipmap
  103987. */
  103988. mipmapCount: number;
  103989. /**
  103990. * If the textures format is a known fourCC format
  103991. * @see https://www.fourcc.org/
  103992. */
  103993. isFourCC: boolean;
  103994. /**
  103995. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  103996. */
  103997. isRGB: boolean;
  103998. /**
  103999. * If the texture is a lumincance format
  104000. */
  104001. isLuminance: boolean;
  104002. /**
  104003. * If this is a cube texture
  104004. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  104005. */
  104006. isCube: boolean;
  104007. /**
  104008. * If the texture is a compressed format eg. FOURCC_DXT1
  104009. */
  104010. isCompressed: boolean;
  104011. /**
  104012. * The dxgiFormat of the texture
  104013. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  104014. */
  104015. dxgiFormat: number;
  104016. /**
  104017. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  104018. */
  104019. textureType: number;
  104020. /**
  104021. * Sphericle polynomial created for the dds texture
  104022. */
  104023. sphericalPolynomial?: SphericalPolynomial;
  104024. }
  104025. /**
  104026. * Class used to provide DDS decompression tools
  104027. */
  104028. export class DDSTools {
  104029. /**
  104030. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  104031. */
  104032. static StoreLODInAlphaChannel: boolean;
  104033. /**
  104034. * Gets DDS information from an array buffer
  104035. * @param arrayBuffer defines the array buffer to read data from
  104036. * @returns the DDS information
  104037. */
  104038. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  104039. private static _FloatView;
  104040. private static _Int32View;
  104041. private static _ToHalfFloat;
  104042. private static _FromHalfFloat;
  104043. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  104044. private static _GetHalfFloatRGBAArrayBuffer;
  104045. private static _GetFloatRGBAArrayBuffer;
  104046. private static _GetFloatAsUIntRGBAArrayBuffer;
  104047. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  104048. private static _GetRGBAArrayBuffer;
  104049. private static _ExtractLongWordOrder;
  104050. private static _GetRGBArrayBuffer;
  104051. private static _GetLuminanceArrayBuffer;
  104052. /**
  104053. * Uploads DDS Levels to a Babylon Texture
  104054. * @hidden
  104055. */
  104056. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  104057. }
  104058. interface Engine {
  104059. /**
  104060. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  104061. * @param rootUrl defines the url where the file to load is located
  104062. * @param scene defines the current scene
  104063. * @param lodScale defines scale to apply to the mip map selection
  104064. * @param lodOffset defines offset to apply to the mip map selection
  104065. * @param onLoad defines an optional callback raised when the texture is loaded
  104066. * @param onError defines an optional callback raised if there is an issue to load the texture
  104067. * @param format defines the format of the data
  104068. * @param forcedExtension defines the extension to use to pick the right loader
  104069. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  104070. * @returns the cube texture as an InternalTexture
  104071. */
  104072. 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;
  104073. }
  104074. }
  104075. declare module BABYLON {
  104076. /**
  104077. * Implementation of the DDS Texture Loader.
  104078. * @hidden
  104079. */
  104080. export class _DDSTextureLoader implements IInternalTextureLoader {
  104081. /**
  104082. * Defines wether the loader supports cascade loading the different faces.
  104083. */
  104084. readonly supportCascades: boolean;
  104085. /**
  104086. * This returns if the loader support the current file information.
  104087. * @param extension defines the file extension of the file being loaded
  104088. * @param textureFormatInUse defines the current compressed format in use iun the engine
  104089. * @param fallback defines the fallback internal texture if any
  104090. * @param isBase64 defines whether the texture is encoded as a base64
  104091. * @param isBuffer defines whether the texture data are stored as a buffer
  104092. * @returns true if the loader can load the specified file
  104093. */
  104094. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  104095. /**
  104096. * Transform the url before loading if required.
  104097. * @param rootUrl the url of the texture
  104098. * @param textureFormatInUse defines the current compressed format in use iun the engine
  104099. * @returns the transformed texture
  104100. */
  104101. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  104102. /**
  104103. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  104104. * @param rootUrl the url of the texture
  104105. * @param textureFormatInUse defines the current compressed format in use iun the engine
  104106. * @returns the fallback texture
  104107. */
  104108. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  104109. /**
  104110. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  104111. * @param data contains the texture data
  104112. * @param texture defines the BabylonJS internal texture
  104113. * @param createPolynomials will be true if polynomials have been requested
  104114. * @param onLoad defines the callback to trigger once the texture is ready
  104115. * @param onError defines the callback to trigger in case of error
  104116. */
  104117. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  104118. /**
  104119. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  104120. * @param data contains the texture data
  104121. * @param texture defines the BabylonJS internal texture
  104122. * @param callback defines the method to call once ready to upload
  104123. */
  104124. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  104125. }
  104126. }
  104127. declare module BABYLON {
  104128. /** @hidden */
  104129. export var rgbdEncodePixelShader: {
  104130. name: string;
  104131. shader: string;
  104132. };
  104133. }
  104134. declare module BABYLON {
  104135. /** @hidden */
  104136. export var rgbdDecodePixelShader: {
  104137. name: string;
  104138. shader: string;
  104139. };
  104140. }
  104141. declare module BABYLON {
  104142. /**
  104143. * Raw texture data and descriptor sufficient for WebGL texture upload
  104144. */
  104145. export interface EnvironmentTextureInfo {
  104146. /**
  104147. * Version of the environment map
  104148. */
  104149. version: number;
  104150. /**
  104151. * Width of image
  104152. */
  104153. width: number;
  104154. /**
  104155. * Irradiance information stored in the file.
  104156. */
  104157. irradiance: any;
  104158. /**
  104159. * Specular information stored in the file.
  104160. */
  104161. specular: any;
  104162. }
  104163. /**
  104164. * Sets of helpers addressing the serialization and deserialization of environment texture
  104165. * stored in a BabylonJS env file.
  104166. * Those files are usually stored as .env files.
  104167. */
  104168. export class EnvironmentTextureTools {
  104169. /**
  104170. * Magic number identifying the env file.
  104171. */
  104172. private static _MagicBytes;
  104173. /**
  104174. * Gets the environment info from an env file.
  104175. * @param data The array buffer containing the .env bytes.
  104176. * @returns the environment file info (the json header) if successfully parsed.
  104177. */
  104178. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  104179. /**
  104180. * Creates an environment texture from a loaded cube texture.
  104181. * @param texture defines the cube texture to convert in env file
  104182. * @return a promise containing the environment data if succesfull.
  104183. */
  104184. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  104185. /**
  104186. * Creates a JSON representation of the spherical data.
  104187. * @param texture defines the texture containing the polynomials
  104188. * @return the JSON representation of the spherical info
  104189. */
  104190. private static _CreateEnvTextureIrradiance;
  104191. /**
  104192. * Uploads the texture info contained in the env file to the GPU.
  104193. * @param texture defines the internal texture to upload to
  104194. * @param arrayBuffer defines the buffer cotaining the data to load
  104195. * @param info defines the texture info retrieved through the GetEnvInfo method
  104196. * @returns a promise
  104197. */
  104198. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  104199. /**
  104200. * Uploads the levels of image data to the GPU.
  104201. * @param texture defines the internal texture to upload to
  104202. * @param imageData defines the array buffer views of image data [mipmap][face]
  104203. * @returns a promise
  104204. */
  104205. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  104206. /**
  104207. * Uploads spherical polynomials information to the texture.
  104208. * @param texture defines the texture we are trying to upload the information to
  104209. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  104210. */
  104211. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  104212. /** @hidden */
  104213. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  104214. }
  104215. }
  104216. declare module BABYLON {
  104217. /**
  104218. * Implementation of the ENV Texture Loader.
  104219. * @hidden
  104220. */
  104221. export class _ENVTextureLoader implements IInternalTextureLoader {
  104222. /**
  104223. * Defines wether the loader supports cascade loading the different faces.
  104224. */
  104225. readonly supportCascades: boolean;
  104226. /**
  104227. * This returns if the loader support the current file information.
  104228. * @param extension defines the file extension of the file being loaded
  104229. * @param textureFormatInUse defines the current compressed format in use iun the engine
  104230. * @param fallback defines the fallback internal texture if any
  104231. * @param isBase64 defines whether the texture is encoded as a base64
  104232. * @param isBuffer defines whether the texture data are stored as a buffer
  104233. * @returns true if the loader can load the specified file
  104234. */
  104235. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  104236. /**
  104237. * Transform the url before loading if required.
  104238. * @param rootUrl the url of the texture
  104239. * @param textureFormatInUse defines the current compressed format in use iun the engine
  104240. * @returns the transformed texture
  104241. */
  104242. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  104243. /**
  104244. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  104245. * @param rootUrl the url of the texture
  104246. * @param textureFormatInUse defines the current compressed format in use iun the engine
  104247. * @returns the fallback texture
  104248. */
  104249. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  104250. /**
  104251. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  104252. * @param data contains the texture data
  104253. * @param texture defines the BabylonJS internal texture
  104254. * @param createPolynomials will be true if polynomials have been requested
  104255. * @param onLoad defines the callback to trigger once the texture is ready
  104256. * @param onError defines the callback to trigger in case of error
  104257. */
  104258. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  104259. /**
  104260. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  104261. * @param data contains the texture data
  104262. * @param texture defines the BabylonJS internal texture
  104263. * @param callback defines the method to call once ready to upload
  104264. */
  104265. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  104266. }
  104267. }
  104268. declare module BABYLON {
  104269. /**
  104270. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  104271. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  104272. */
  104273. export class KhronosTextureContainer {
  104274. /** contents of the KTX container file */
  104275. arrayBuffer: any;
  104276. private static HEADER_LEN;
  104277. private static COMPRESSED_2D;
  104278. private static COMPRESSED_3D;
  104279. private static TEX_2D;
  104280. private static TEX_3D;
  104281. /**
  104282. * Gets the openGL type
  104283. */
  104284. glType: number;
  104285. /**
  104286. * Gets the openGL type size
  104287. */
  104288. glTypeSize: number;
  104289. /**
  104290. * Gets the openGL format
  104291. */
  104292. glFormat: number;
  104293. /**
  104294. * Gets the openGL internal format
  104295. */
  104296. glInternalFormat: number;
  104297. /**
  104298. * Gets the base internal format
  104299. */
  104300. glBaseInternalFormat: number;
  104301. /**
  104302. * Gets image width in pixel
  104303. */
  104304. pixelWidth: number;
  104305. /**
  104306. * Gets image height in pixel
  104307. */
  104308. pixelHeight: number;
  104309. /**
  104310. * Gets image depth in pixels
  104311. */
  104312. pixelDepth: number;
  104313. /**
  104314. * Gets the number of array elements
  104315. */
  104316. numberOfArrayElements: number;
  104317. /**
  104318. * Gets the number of faces
  104319. */
  104320. numberOfFaces: number;
  104321. /**
  104322. * Gets the number of mipmap levels
  104323. */
  104324. numberOfMipmapLevels: number;
  104325. /**
  104326. * Gets the bytes of key value data
  104327. */
  104328. bytesOfKeyValueData: number;
  104329. /**
  104330. * Gets the load type
  104331. */
  104332. loadType: number;
  104333. /**
  104334. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  104335. */
  104336. isInvalid: boolean;
  104337. /**
  104338. * Creates a new KhronosTextureContainer
  104339. * @param arrayBuffer contents of the KTX container file
  104340. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  104341. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  104342. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  104343. */
  104344. constructor(
  104345. /** contents of the KTX container file */
  104346. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  104347. /**
  104348. * Uploads KTX content to a Babylon Texture.
  104349. * It is assumed that the texture has already been created & is currently bound
  104350. * @hidden
  104351. */
  104352. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  104353. private _upload2DCompressedLevels;
  104354. }
  104355. }
  104356. declare module BABYLON {
  104357. /**
  104358. * Implementation of the KTX Texture Loader.
  104359. * @hidden
  104360. */
  104361. export class _KTXTextureLoader implements IInternalTextureLoader {
  104362. /**
  104363. * Defines wether the loader supports cascade loading the different faces.
  104364. */
  104365. readonly supportCascades: boolean;
  104366. /**
  104367. * This returns if the loader support the current file information.
  104368. * @param extension defines the file extension of the file being loaded
  104369. * @param textureFormatInUse defines the current compressed format in use iun the engine
  104370. * @param fallback defines the fallback internal texture if any
  104371. * @param isBase64 defines whether the texture is encoded as a base64
  104372. * @param isBuffer defines whether the texture data are stored as a buffer
  104373. * @returns true if the loader can load the specified file
  104374. */
  104375. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  104376. /**
  104377. * Transform the url before loading if required.
  104378. * @param rootUrl the url of the texture
  104379. * @param textureFormatInUse defines the current compressed format in use iun the engine
  104380. * @returns the transformed texture
  104381. */
  104382. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  104383. /**
  104384. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  104385. * @param rootUrl the url of the texture
  104386. * @param textureFormatInUse defines the current compressed format in use iun the engine
  104387. * @returns the fallback texture
  104388. */
  104389. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  104390. /**
  104391. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  104392. * @param data contains the texture data
  104393. * @param texture defines the BabylonJS internal texture
  104394. * @param createPolynomials will be true if polynomials have been requested
  104395. * @param onLoad defines the callback to trigger once the texture is ready
  104396. * @param onError defines the callback to trigger in case of error
  104397. */
  104398. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  104399. /**
  104400. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  104401. * @param data contains the texture data
  104402. * @param texture defines the BabylonJS internal texture
  104403. * @param callback defines the method to call once ready to upload
  104404. */
  104405. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  104406. }
  104407. }
  104408. declare module BABYLON {
  104409. /**
  104410. * Based on jsTGALoader - Javascript loader for TGA file
  104411. * By Vincent Thibault
  104412. * @see http://blog.robrowser.com/javascript-tga-loader.html
  104413. */
  104414. export class TGATools {
  104415. private static _TYPE_INDEXED;
  104416. private static _TYPE_RGB;
  104417. private static _TYPE_GREY;
  104418. private static _TYPE_RLE_INDEXED;
  104419. private static _TYPE_RLE_RGB;
  104420. private static _TYPE_RLE_GREY;
  104421. private static _ORIGIN_MASK;
  104422. private static _ORIGIN_SHIFT;
  104423. private static _ORIGIN_BL;
  104424. private static _ORIGIN_BR;
  104425. private static _ORIGIN_UL;
  104426. private static _ORIGIN_UR;
  104427. /**
  104428. * Gets the header of a TGA file
  104429. * @param data defines the TGA data
  104430. * @returns the header
  104431. */
  104432. static GetTGAHeader(data: Uint8Array): any;
  104433. /**
  104434. * Uploads TGA content to a Babylon Texture
  104435. * @hidden
  104436. */
  104437. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  104438. /** @hidden */
  104439. 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;
  104440. /** @hidden */
  104441. 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;
  104442. /** @hidden */
  104443. 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;
  104444. /** @hidden */
  104445. 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;
  104446. /** @hidden */
  104447. 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;
  104448. /** @hidden */
  104449. 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;
  104450. }
  104451. }
  104452. declare module BABYLON {
  104453. /**
  104454. * Implementation of the TGA Texture Loader.
  104455. * @hidden
  104456. */
  104457. export class _TGATextureLoader implements IInternalTextureLoader {
  104458. /**
  104459. * Defines wether the loader supports cascade loading the different faces.
  104460. */
  104461. readonly supportCascades: boolean;
  104462. /**
  104463. * This returns if the loader support the current file information.
  104464. * @param extension defines the file extension of the file being loaded
  104465. * @param textureFormatInUse defines the current compressed format in use iun the engine
  104466. * @param fallback defines the fallback internal texture if any
  104467. * @param isBase64 defines whether the texture is encoded as a base64
  104468. * @param isBuffer defines whether the texture data are stored as a buffer
  104469. * @returns true if the loader can load the specified file
  104470. */
  104471. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  104472. /**
  104473. * Transform the url before loading if required.
  104474. * @param rootUrl the url of the texture
  104475. * @param textureFormatInUse defines the current compressed format in use iun the engine
  104476. * @returns the transformed texture
  104477. */
  104478. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  104479. /**
  104480. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  104481. * @param rootUrl the url of the texture
  104482. * @param textureFormatInUse defines the current compressed format in use iun the engine
  104483. * @returns the fallback texture
  104484. */
  104485. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  104486. /**
  104487. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  104488. * @param data contains the texture data
  104489. * @param texture defines the BabylonJS internal texture
  104490. * @param createPolynomials will be true if polynomials have been requested
  104491. * @param onLoad defines the callback to trigger once the texture is ready
  104492. * @param onError defines the callback to trigger in case of error
  104493. */
  104494. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  104495. /**
  104496. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  104497. * @param data contains the texture data
  104498. * @param texture defines the BabylonJS internal texture
  104499. * @param callback defines the method to call once ready to upload
  104500. */
  104501. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  104502. }
  104503. }
  104504. declare module BABYLON {
  104505. /**
  104506. * Procedural texturing is a way to programmatically create a texture. There are 2 types of procedural textures: code-only, and code that references some classic 2D images, sometimes called 'refMaps' or 'sampler' images.
  104507. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  104508. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  104509. */
  104510. export class CustomProceduralTexture extends ProceduralTexture {
  104511. private _animate;
  104512. private _time;
  104513. private _config;
  104514. private _texturePath;
  104515. /**
  104516. * Instantiates a new Custom Procedural Texture.
  104517. * 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.
  104518. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  104519. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  104520. * @param name Define the name of the texture
  104521. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  104522. * @param size Define the size of the texture to create
  104523. * @param scene Define the scene the texture belongs to
  104524. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  104525. * @param generateMipMaps Define if the texture should creates mip maps or not
  104526. */
  104527. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  104528. private _loadJson;
  104529. /**
  104530. * Is the texture ready to be used ? (rendered at least once)
  104531. * @returns true if ready, otherwise, false.
  104532. */
  104533. isReady(): boolean;
  104534. /**
  104535. * Render the texture to its associated render target.
  104536. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  104537. */
  104538. render(useCameraPostProcess?: boolean): void;
  104539. /**
  104540. * Update the list of dependant textures samplers in the shader.
  104541. */
  104542. updateTextures(): void;
  104543. /**
  104544. * Update the uniform values of the procedural texture in the shader.
  104545. */
  104546. updateShaderUniforms(): void;
  104547. /**
  104548. * Define if the texture animates or not.
  104549. */
  104550. animate: boolean;
  104551. }
  104552. }
  104553. declare module BABYLON {
  104554. /** @hidden */
  104555. export var noisePixelShader: {
  104556. name: string;
  104557. shader: string;
  104558. };
  104559. }
  104560. declare module BABYLON {
  104561. /**
  104562. * Class used to generate noise procedural textures
  104563. */
  104564. export class NoiseProceduralTexture extends ProceduralTexture {
  104565. private _time;
  104566. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  104567. brightness: number;
  104568. /** Defines the number of octaves to process */
  104569. octaves: number;
  104570. /** Defines the level of persistence (0.8 by default) */
  104571. persistence: number;
  104572. /** Gets or sets animation speed factor (default is 1) */
  104573. animationSpeedFactor: number;
  104574. /**
  104575. * Creates a new NoiseProceduralTexture
  104576. * @param name defines the name fo the texture
  104577. * @param size defines the size of the texture (default is 256)
  104578. * @param scene defines the hosting scene
  104579. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  104580. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  104581. */
  104582. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  104583. private _updateShaderUniforms;
  104584. protected _getDefines(): string;
  104585. /** Generate the current state of the procedural texture */
  104586. render(useCameraPostProcess?: boolean): void;
  104587. /**
  104588. * Serializes this noise procedural texture
  104589. * @returns a serialized noise procedural texture object
  104590. */
  104591. serialize(): any;
  104592. /**
  104593. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  104594. * @param parsedTexture defines parsed texture data
  104595. * @param scene defines the current scene
  104596. * @param rootUrl defines the root URL containing noise procedural texture information
  104597. * @returns a parsed NoiseProceduralTexture
  104598. */
  104599. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  104600. }
  104601. }
  104602. declare module BABYLON {
  104603. /**
  104604. * Raw cube texture where the raw buffers are passed in
  104605. */
  104606. export class RawCubeTexture extends CubeTexture {
  104607. /**
  104608. * Creates a cube texture where the raw buffers are passed in.
  104609. * @param scene defines the scene the texture is attached to
  104610. * @param data defines the array of data to use to create each face
  104611. * @param size defines the size of the textures
  104612. * @param format defines the format of the data
  104613. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  104614. * @param generateMipMaps defines if the engine should generate the mip levels
  104615. * @param invertY defines if data must be stored with Y axis inverted
  104616. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  104617. * @param compression defines the compression used (null by default)
  104618. */
  104619. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  104620. /**
  104621. * Updates the raw cube texture.
  104622. * @param data defines the data to store
  104623. * @param format defines the data format
  104624. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  104625. * @param invertY defines if data must be stored with Y axis inverted
  104626. * @param compression defines the compression used (null by default)
  104627. * @param level defines which level of the texture to update
  104628. */
  104629. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  104630. /**
  104631. * Updates a raw cube texture with RGBD encoded data.
  104632. * @param data defines the array of data [mipmap][face] to use to create each face
  104633. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  104634. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  104635. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  104636. * @returns a promsie that resolves when the operation is complete
  104637. */
  104638. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  104639. /**
  104640. * Clones the raw cube texture.
  104641. * @return a new cube texture
  104642. */
  104643. clone(): CubeTexture;
  104644. /** @hidden */
  104645. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  104646. }
  104647. }
  104648. declare module BABYLON {
  104649. /**
  104650. * Class used to store 3D textures containing user data
  104651. */
  104652. export class RawTexture3D extends Texture {
  104653. /** Gets or sets the texture format to use */
  104654. format: number;
  104655. private _engine;
  104656. /**
  104657. * Create a new RawTexture3D
  104658. * @param data defines the data of the texture
  104659. * @param width defines the width of the texture
  104660. * @param height defines the height of the texture
  104661. * @param depth defines the depth of the texture
  104662. * @param format defines the texture format to use
  104663. * @param scene defines the hosting scene
  104664. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  104665. * @param invertY defines if texture must be stored with Y axis inverted
  104666. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  104667. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  104668. */
  104669. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  104670. /** Gets or sets the texture format to use */
  104671. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  104672. /**
  104673. * Update the texture with new data
  104674. * @param data defines the data to store in the texture
  104675. */
  104676. update(data: ArrayBufferView): void;
  104677. }
  104678. }
  104679. declare module BABYLON {
  104680. /**
  104681. * Creates a refraction texture used by refraction channel of the standard material.
  104682. * It is like a mirror but to see through a material.
  104683. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  104684. */
  104685. export class RefractionTexture extends RenderTargetTexture {
  104686. /**
  104687. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  104688. * 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.
  104689. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  104690. */
  104691. refractionPlane: Plane;
  104692. /**
  104693. * Define how deep under the surface we should see.
  104694. */
  104695. depth: number;
  104696. /**
  104697. * Creates a refraction texture used by refraction channel of the standard material.
  104698. * It is like a mirror but to see through a material.
  104699. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  104700. * @param name Define the texture name
  104701. * @param size Define the size of the underlying texture
  104702. * @param scene Define the scene the refraction belongs to
  104703. * @param generateMipMaps Define if we need to generate mips level for the refraction
  104704. */
  104705. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  104706. /**
  104707. * Clone the refraction texture.
  104708. * @returns the cloned texture
  104709. */
  104710. clone(): RefractionTexture;
  104711. /**
  104712. * Serialize the texture to a JSON representation you could use in Parse later on
  104713. * @returns the serialized JSON representation
  104714. */
  104715. serialize(): any;
  104716. }
  104717. }
  104718. declare module BABYLON {
  104719. /**
  104720. * Configuration for Draco compression
  104721. */
  104722. export interface IDracoCompressionConfiguration {
  104723. /**
  104724. * Configuration for the decoder.
  104725. */
  104726. decoder?: {
  104727. /**
  104728. * The url to the WebAssembly module.
  104729. */
  104730. wasmUrl?: string;
  104731. /**
  104732. * The url to the WebAssembly binary.
  104733. */
  104734. wasmBinaryUrl?: string;
  104735. /**
  104736. * The url to the fallback JavaScript module.
  104737. */
  104738. fallbackUrl?: string;
  104739. };
  104740. }
  104741. /**
  104742. * Draco compression (https://google.github.io/draco/)
  104743. *
  104744. * This class wraps the Draco module.
  104745. *
  104746. * **Encoder**
  104747. *
  104748. * The encoder is not currently implemented.
  104749. *
  104750. * **Decoder**
  104751. *
  104752. * 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.
  104753. *
  104754. * To update the configuration, use the following code:
  104755. * ```javascript
  104756. * DracoCompression.Configuration = {
  104757. * decoder: {
  104758. * wasmUrl: "<url to the WebAssembly library>",
  104759. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  104760. * fallbackUrl: "<url to the fallback JavaScript library>",
  104761. * }
  104762. * };
  104763. * ```
  104764. *
  104765. * 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.
  104766. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  104767. * Use `DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  104768. *
  104769. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  104770. * ```javascript
  104771. * var dracoCompression = new DracoCompression();
  104772. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  104773. * [VertexBuffer.PositionKind]: 0
  104774. * });
  104775. * ```
  104776. *
  104777. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  104778. */
  104779. export class DracoCompression implements IDisposable {
  104780. private static _DecoderModulePromise;
  104781. /**
  104782. * The configuration. Defaults to the following urls:
  104783. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  104784. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  104785. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  104786. */
  104787. static Configuration: IDracoCompressionConfiguration;
  104788. /**
  104789. * Returns true if the decoder is available.
  104790. */
  104791. static readonly DecoderAvailable: boolean;
  104792. /**
  104793. * Constructor
  104794. */
  104795. constructor();
  104796. /**
  104797. * Stop all async operations and release resources.
  104798. */
  104799. dispose(): void;
  104800. /**
  104801. * Decode Draco compressed mesh data to vertex data.
  104802. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  104803. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  104804. * @returns A promise that resolves with the decoded vertex data
  104805. */
  104806. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes: {
  104807. [kind: string]: number;
  104808. }): Promise<VertexData>;
  104809. private static _GetDecoderModule;
  104810. private static _LoadScriptAsync;
  104811. private static _LoadFileAsync;
  104812. }
  104813. }
  104814. declare module BABYLON {
  104815. /**
  104816. * Class for building Constructive Solid Geometry
  104817. */
  104818. export class CSG {
  104819. private polygons;
  104820. /**
  104821. * The world matrix
  104822. */
  104823. matrix: Matrix;
  104824. /**
  104825. * Stores the position
  104826. */
  104827. position: Vector3;
  104828. /**
  104829. * Stores the rotation
  104830. */
  104831. rotation: Vector3;
  104832. /**
  104833. * Stores the rotation quaternion
  104834. */
  104835. rotationQuaternion: Nullable<Quaternion>;
  104836. /**
  104837. * Stores the scaling vector
  104838. */
  104839. scaling: Vector3;
  104840. /**
  104841. * Convert the Mesh to CSG
  104842. * @param mesh The Mesh to convert to CSG
  104843. * @returns A new CSG from the Mesh
  104844. */
  104845. static FromMesh(mesh: Mesh): CSG;
  104846. /**
  104847. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  104848. * @param polygons Polygons used to construct a CSG solid
  104849. */
  104850. private static FromPolygons;
  104851. /**
  104852. * Clones, or makes a deep copy, of the CSG
  104853. * @returns A new CSG
  104854. */
  104855. clone(): CSG;
  104856. /**
  104857. * Unions this CSG with another CSG
  104858. * @param csg The CSG to union against this CSG
  104859. * @returns The unioned CSG
  104860. */
  104861. union(csg: CSG): CSG;
  104862. /**
  104863. * Unions this CSG with another CSG in place
  104864. * @param csg The CSG to union against this CSG
  104865. */
  104866. unionInPlace(csg: CSG): void;
  104867. /**
  104868. * Subtracts this CSG with another CSG
  104869. * @param csg The CSG to subtract against this CSG
  104870. * @returns A new CSG
  104871. */
  104872. subtract(csg: CSG): CSG;
  104873. /**
  104874. * Subtracts this CSG with another CSG in place
  104875. * @param csg The CSG to subtact against this CSG
  104876. */
  104877. subtractInPlace(csg: CSG): void;
  104878. /**
  104879. * Intersect this CSG with another CSG
  104880. * @param csg The CSG to intersect against this CSG
  104881. * @returns A new CSG
  104882. */
  104883. intersect(csg: CSG): CSG;
  104884. /**
  104885. * Intersects this CSG with another CSG in place
  104886. * @param csg The CSG to intersect against this CSG
  104887. */
  104888. intersectInPlace(csg: CSG): void;
  104889. /**
  104890. * Return a new CSG solid with solid and empty space switched. This solid is
  104891. * not modified.
  104892. * @returns A new CSG solid with solid and empty space switched
  104893. */
  104894. inverse(): CSG;
  104895. /**
  104896. * Inverses the CSG in place
  104897. */
  104898. inverseInPlace(): void;
  104899. /**
  104900. * This is used to keep meshes transformations so they can be restored
  104901. * when we build back a Babylon Mesh
  104902. * NB : All CSG operations are performed in world coordinates
  104903. * @param csg The CSG to copy the transform attributes from
  104904. * @returns This CSG
  104905. */
  104906. copyTransformAttributes(csg: CSG): CSG;
  104907. /**
  104908. * Build Raw mesh from CSG
  104909. * Coordinates here are in world space
  104910. * @param name The name of the mesh geometry
  104911. * @param scene The Scene
  104912. * @param keepSubMeshes Specifies if the submeshes should be kept
  104913. * @returns A new Mesh
  104914. */
  104915. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  104916. /**
  104917. * Build Mesh from CSG taking material and transforms into account
  104918. * @param name The name of the Mesh
  104919. * @param material The material of the Mesh
  104920. * @param scene The Scene
  104921. * @param keepSubMeshes Specifies if submeshes should be kept
  104922. * @returns The new Mesh
  104923. */
  104924. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  104925. }
  104926. }
  104927. declare module BABYLON {
  104928. /**
  104929. * Class used to create a trail following a mesh
  104930. */
  104931. export class TrailMesh extends Mesh {
  104932. private _generator;
  104933. private _autoStart;
  104934. private _running;
  104935. private _diameter;
  104936. private _length;
  104937. private _sectionPolygonPointsCount;
  104938. private _sectionVectors;
  104939. private _sectionNormalVectors;
  104940. private _beforeRenderObserver;
  104941. /**
  104942. * @constructor
  104943. * @param name The value used by scene.getMeshByName() to do a lookup.
  104944. * @param generator The mesh to generate a trail.
  104945. * @param scene The scene to add this mesh to.
  104946. * @param diameter Diameter of trailing mesh. Default is 1.
  104947. * @param length Length of trailing mesh. Default is 60.
  104948. * @param autoStart Automatically start trailing mesh. Default true.
  104949. */
  104950. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  104951. /**
  104952. * "TrailMesh"
  104953. * @returns "TrailMesh"
  104954. */
  104955. getClassName(): string;
  104956. private _createMesh;
  104957. /**
  104958. * Start trailing mesh.
  104959. */
  104960. start(): void;
  104961. /**
  104962. * Stop trailing mesh.
  104963. */
  104964. stop(): void;
  104965. /**
  104966. * Update trailing mesh geometry.
  104967. */
  104968. update(): void;
  104969. /**
  104970. * Returns a new TrailMesh object.
  104971. * @param name is a string, the name given to the new mesh
  104972. * @param newGenerator use new generator object for cloned trail mesh
  104973. * @returns a new mesh
  104974. */
  104975. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  104976. /**
  104977. * Serializes this trail mesh
  104978. * @param serializationObject object to write serialization to
  104979. */
  104980. serialize(serializationObject: any): void;
  104981. /**
  104982. * Parses a serialized trail mesh
  104983. * @param parsedMesh the serialized mesh
  104984. * @param scene the scene to create the trail mesh in
  104985. * @returns the created trail mesh
  104986. */
  104987. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  104988. }
  104989. }
  104990. declare module BABYLON {
  104991. /**
  104992. * Class containing static functions to help procedurally build meshes
  104993. */
  104994. export class RibbonBuilder {
  104995. /**
  104996. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  104997. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  104998. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  104999. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  105000. * * 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
  105001. * * 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
  105002. * * 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
  105003. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105004. * * If you create a double-sided mesh, you can choose what parts of 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
  105005. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  105006. * * 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
  105007. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  105008. * * 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
  105009. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  105010. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105011. * @param name defines the name of the mesh
  105012. * @param options defines the options used to create the mesh
  105013. * @param scene defines the hosting scene
  105014. * @returns the ribbon mesh
  105015. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  105016. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  105017. */
  105018. static CreateRibbon(name: string, options: {
  105019. pathArray: Vector3[][];
  105020. closeArray?: boolean;
  105021. closePath?: boolean;
  105022. offset?: number;
  105023. updatable?: boolean;
  105024. sideOrientation?: number;
  105025. frontUVs?: Vector4;
  105026. backUVs?: Vector4;
  105027. instance?: Mesh;
  105028. invertUV?: boolean;
  105029. uvs?: Vector2[];
  105030. colors?: Color4[];
  105031. }, scene?: Nullable<Scene>): Mesh;
  105032. }
  105033. }
  105034. declare module BABYLON {
  105035. /**
  105036. * Class containing static functions to help procedurally build meshes
  105037. */
  105038. export class TorusKnotBuilder {
  105039. /**
  105040. * Creates a torus knot mesh
  105041. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  105042. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  105043. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  105044. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  105045. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105046. * * If you create a double-sided mesh, you can choose what parts of 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
  105047. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  105048. * @param name defines the name of the mesh
  105049. * @param options defines the options used to create the mesh
  105050. * @param scene defines the hosting scene
  105051. * @returns the torus knot mesh
  105052. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  105053. */
  105054. static CreateTorusKnot(name: string, options: {
  105055. radius?: number;
  105056. tube?: number;
  105057. radialSegments?: number;
  105058. tubularSegments?: number;
  105059. p?: number;
  105060. q?: number;
  105061. updatable?: boolean;
  105062. sideOrientation?: number;
  105063. frontUVs?: Vector4;
  105064. backUVs?: Vector4;
  105065. }, scene: any): Mesh;
  105066. }
  105067. }
  105068. declare module BABYLON {
  105069. /**
  105070. * Polygon
  105071. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  105072. */
  105073. export class Polygon {
  105074. /**
  105075. * Creates a rectangle
  105076. * @param xmin bottom X coord
  105077. * @param ymin bottom Y coord
  105078. * @param xmax top X coord
  105079. * @param ymax top Y coord
  105080. * @returns points that make the resulting rectation
  105081. */
  105082. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  105083. /**
  105084. * Creates a circle
  105085. * @param radius radius of circle
  105086. * @param cx scale in x
  105087. * @param cy scale in y
  105088. * @param numberOfSides number of sides that make up the circle
  105089. * @returns points that make the resulting circle
  105090. */
  105091. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  105092. /**
  105093. * Creates a polygon from input string
  105094. * @param input Input polygon data
  105095. * @returns the parsed points
  105096. */
  105097. static Parse(input: string): Vector2[];
  105098. /**
  105099. * Starts building a polygon from x and y coordinates
  105100. * @param x x coordinate
  105101. * @param y y coordinate
  105102. * @returns the started path2
  105103. */
  105104. static StartingAt(x: number, y: number): Path2;
  105105. }
  105106. /**
  105107. * Builds a polygon
  105108. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  105109. */
  105110. export class PolygonMeshBuilder {
  105111. private _points;
  105112. private _outlinepoints;
  105113. private _holes;
  105114. private _name;
  105115. private _scene;
  105116. private _epoints;
  105117. private _eholes;
  105118. private _addToepoint;
  105119. /**
  105120. * Babylon reference to the earcut plugin.
  105121. */
  105122. bjsEarcut: any;
  105123. /**
  105124. * Creates a PolygonMeshBuilder
  105125. * @param name name of the builder
  105126. * @param contours Path of the polygon
  105127. * @param scene scene to add to
  105128. * @param earcutInjection can be used to inject your own earcut reference
  105129. */
  105130. constructor(name: string, contours: Path2 | Vector2[] | any, scene: Scene, earcutInjection?: any);
  105131. /**
  105132. * Adds a whole within the polygon
  105133. * @param hole Array of points defining the hole
  105134. * @returns this
  105135. */
  105136. addHole(hole: Vector2[]): PolygonMeshBuilder;
  105137. /**
  105138. * Creates the polygon
  105139. * @param updatable If the mesh should be updatable
  105140. * @param depth The depth of the mesh created
  105141. * @returns the created mesh
  105142. */
  105143. build(updatable?: boolean, depth?: number): Mesh;
  105144. /**
  105145. * Adds a side to the polygon
  105146. * @param positions points that make the polygon
  105147. * @param normals normals of the polygon
  105148. * @param uvs uvs of the polygon
  105149. * @param indices indices of the polygon
  105150. * @param bounds bounds of the polygon
  105151. * @param points points of the polygon
  105152. * @param depth depth of the polygon
  105153. * @param flip flip of the polygon
  105154. */
  105155. private addSide;
  105156. }
  105157. }
  105158. declare module BABYLON {
  105159. /**
  105160. * Class containing static functions to help procedurally build meshes
  105161. */
  105162. export class PolygonBuilder {
  105163. /**
  105164. * Creates a polygon mesh
  105165. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  105166. * * 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
  105167. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  105168. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  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)
  105170. * * Remember you can only change the shape positions, not their number when updating a polygon
  105171. * @param name defines the name of the mesh
  105172. * @param options defines the options used to create the mesh
  105173. * @param scene defines the hosting scene
  105174. * @param earcutInjection can be used to inject your own earcut reference
  105175. * @returns the polygon mesh
  105176. */
  105177. static CreatePolygon(name: string, options: {
  105178. shape: Vector3[];
  105179. holes?: Vector3[][];
  105180. depth?: number;
  105181. faceUV?: Vector4[];
  105182. faceColors?: Color4[];
  105183. updatable?: boolean;
  105184. sideOrientation?: number;
  105185. frontUVs?: Vector4;
  105186. backUVs?: Vector4;
  105187. }, scene: Scene, earcutInjection?: any): Mesh;
  105188. /**
  105189. * Creates an extruded polygon mesh, with depth in the Y direction.
  105190. * * 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)
  105191. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  105192. * @param name defines the name of the mesh
  105193. * @param options defines the options used to create the mesh
  105194. * @param scene defines the hosting scene
  105195. * @param earcutInjection can be used to inject your own earcut reference
  105196. * @returns the polygon mesh
  105197. */
  105198. static ExtrudePolygon(name: string, options: {
  105199. shape: Vector3[];
  105200. holes?: Vector3[][];
  105201. depth?: number;
  105202. faceUV?: Vector4[];
  105203. faceColors?: Color4[];
  105204. updatable?: boolean;
  105205. sideOrientation?: number;
  105206. frontUVs?: Vector4;
  105207. backUVs?: Vector4;
  105208. }, scene: Scene, earcutInjection?: any): Mesh;
  105209. }
  105210. }
  105211. declare module BABYLON {
  105212. /**
  105213. * Class containing static functions to help procedurally build meshes
  105214. */
  105215. export class ShapeBuilder {
  105216. /**
  105217. * 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.
  105218. * * 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.
  105219. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  105220. * * 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.
  105221. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  105222. * * 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
  105223. * * 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
  105224. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  105225. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105226. * * If you create a double-sided mesh, you can choose what parts of 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
  105227. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  105228. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  105229. * @param name defines the name of the mesh
  105230. * @param options defines the options used to create the mesh
  105231. * @param scene defines the hosting scene
  105232. * @returns the extruded shape mesh
  105233. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  105234. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  105235. */
  105236. static ExtrudeShape(name: string, options: {
  105237. shape: Vector3[];
  105238. path: Vector3[];
  105239. scale?: number;
  105240. rotation?: number;
  105241. cap?: number;
  105242. updatable?: boolean;
  105243. sideOrientation?: number;
  105244. frontUVs?: Vector4;
  105245. backUVs?: Vector4;
  105246. instance?: Mesh;
  105247. invertUV?: boolean;
  105248. }, scene?: Nullable<Scene>): Mesh;
  105249. /**
  105250. * Creates an custom extruded shape mesh.
  105251. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  105252. * * 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.
  105253. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  105254. * * 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
  105255. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  105256. * * 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
  105257. * * It must returns a float value that will be the scale value applied to the shape on each path point
  105258. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  105259. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  105260. * * 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
  105261. * * 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
  105262. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  105263. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105264. * * If you create a double-sided mesh, you can choose what parts of 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
  105265. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  105266. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105267. * @param name defines the name of the mesh
  105268. * @param options defines the options used to create the mesh
  105269. * @param scene defines the hosting scene
  105270. * @returns the custom extruded shape mesh
  105271. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  105272. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  105273. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  105274. */
  105275. static ExtrudeShapeCustom(name: string, options: {
  105276. shape: Vector3[];
  105277. path: Vector3[];
  105278. scaleFunction?: any;
  105279. rotationFunction?: any;
  105280. ribbonCloseArray?: boolean;
  105281. ribbonClosePath?: boolean;
  105282. cap?: number;
  105283. updatable?: boolean;
  105284. sideOrientation?: number;
  105285. frontUVs?: Vector4;
  105286. backUVs?: Vector4;
  105287. instance?: Mesh;
  105288. invertUV?: boolean;
  105289. }, scene: Scene): Mesh;
  105290. private static _ExtrudeShapeGeneric;
  105291. }
  105292. }
  105293. declare module BABYLON {
  105294. /**
  105295. * Class containing static functions to help procedurally build meshes
  105296. */
  105297. export class LatheBuilder {
  105298. /**
  105299. * Creates lathe mesh.
  105300. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  105301. * * 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
  105302. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  105303. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  105304. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  105305. * * 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
  105306. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  105307. * * 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
  105308. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105309. * * If you create a double-sided mesh, you can choose what parts of 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
  105310. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  105311. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105312. * @param name defines the name of the mesh
  105313. * @param options defines the options used to create the mesh
  105314. * @param scene defines the hosting scene
  105315. * @returns the lathe mesh
  105316. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  105317. */
  105318. static CreateLathe(name: string, options: {
  105319. shape: Vector3[];
  105320. radius?: number;
  105321. tessellation?: number;
  105322. clip?: number;
  105323. arc?: number;
  105324. closed?: boolean;
  105325. updatable?: boolean;
  105326. sideOrientation?: number;
  105327. frontUVs?: Vector4;
  105328. backUVs?: Vector4;
  105329. cap?: number;
  105330. invertUV?: boolean;
  105331. }, scene: Scene): Mesh;
  105332. }
  105333. }
  105334. declare module BABYLON {
  105335. /**
  105336. * Class containing static functions to help procedurally build meshes
  105337. */
  105338. export class TubeBuilder {
  105339. /**
  105340. * Creates a tube mesh.
  105341. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  105342. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  105343. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  105344. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  105345. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  105346. * * 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)
  105347. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  105348. * * 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
  105349. * * 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
  105350. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105351. * * If you create a double-sided mesh, you can choose what parts of 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
  105352. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  105353. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105354. * @param name defines the name of the mesh
  105355. * @param options defines the options used to create the mesh
  105356. * @param scene defines the hosting scene
  105357. * @returns the tube mesh
  105358. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  105359. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  105360. */
  105361. static CreateTube(name: string, options: {
  105362. path: Vector3[];
  105363. radius?: number;
  105364. tessellation?: number;
  105365. radiusFunction?: {
  105366. (i: number, distance: number): number;
  105367. };
  105368. cap?: number;
  105369. arc?: number;
  105370. updatable?: boolean;
  105371. sideOrientation?: number;
  105372. frontUVs?: Vector4;
  105373. backUVs?: Vector4;
  105374. instance?: Mesh;
  105375. invertUV?: boolean;
  105376. }, scene: Scene): Mesh;
  105377. }
  105378. }
  105379. declare module BABYLON {
  105380. /**
  105381. * Class containing static functions to help procedurally build meshes
  105382. */
  105383. export class IcoSphereBuilder {
  105384. /**
  105385. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  105386. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  105387. * * 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`)
  105388. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  105389. * * 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
  105390. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105391. * * If you create a double-sided mesh, you can choose what parts of 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
  105392. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105393. * @param name defines the name of the mesh
  105394. * @param options defines the options used to create the mesh
  105395. * @param scene defines the hosting scene
  105396. * @returns the icosahedron mesh
  105397. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  105398. */
  105399. static CreateIcoSphere(name: string, options: {
  105400. radius?: number;
  105401. radiusX?: number;
  105402. radiusY?: number;
  105403. radiusZ?: number;
  105404. flat?: boolean;
  105405. subdivisions?: number;
  105406. sideOrientation?: number;
  105407. frontUVs?: Vector4;
  105408. backUVs?: Vector4;
  105409. updatable?: boolean;
  105410. }, scene: Scene): Mesh;
  105411. }
  105412. }
  105413. declare module BABYLON {
  105414. /**
  105415. * Class containing static functions to help procedurally build meshes
  105416. */
  105417. export class DecalBuilder {
  105418. /**
  105419. * Creates a decal mesh.
  105420. * 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
  105421. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  105422. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  105423. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  105424. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  105425. * @param name defines the name of the mesh
  105426. * @param sourceMesh defines the mesh where the decal must be applied
  105427. * @param options defines the options used to create the mesh
  105428. * @param scene defines the hosting scene
  105429. * @returns the decal mesh
  105430. * @see https://doc.babylonjs.com/how_to/decals
  105431. */
  105432. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  105433. position?: Vector3;
  105434. normal?: Vector3;
  105435. size?: Vector3;
  105436. angle?: number;
  105437. }): Mesh;
  105438. }
  105439. }
  105440. declare module BABYLON {
  105441. /**
  105442. * Class containing static functions to help procedurally build meshes
  105443. */
  105444. export class MeshBuilder {
  105445. /**
  105446. * Creates a box mesh
  105447. * * The parameter `size` sets the size (float) of each box side (default 1)
  105448. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  105449. * * 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)
  105450. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  105451. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105452. * * If you create a double-sided mesh, you can choose what parts of 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
  105453. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105454. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  105455. * @param name defines the name of the mesh
  105456. * @param options defines the options used to create the mesh
  105457. * @param scene defines the hosting scene
  105458. * @returns the box mesh
  105459. */
  105460. static CreateBox(name: string, options: {
  105461. size?: number;
  105462. width?: number;
  105463. height?: number;
  105464. depth?: number;
  105465. faceUV?: Vector4[];
  105466. faceColors?: Color4[];
  105467. sideOrientation?: number;
  105468. frontUVs?: Vector4;
  105469. backUVs?: Vector4;
  105470. updatable?: boolean;
  105471. }, scene?: Nullable<Scene>): Mesh;
  105472. /**
  105473. * Creates a sphere mesh
  105474. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  105475. * * 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`)
  105476. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  105477. * * 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
  105478. * * 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)
  105479. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105480. * * If you create a double-sided mesh, you can choose what parts of 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
  105481. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105482. * @param name defines the name of the mesh
  105483. * @param options defines the options used to create the mesh
  105484. * @param scene defines the hosting scene
  105485. * @returns the sphere mesh
  105486. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  105487. */
  105488. static CreateSphere(name: string, options: {
  105489. segments?: number;
  105490. diameter?: number;
  105491. diameterX?: number;
  105492. diameterY?: number;
  105493. diameterZ?: number;
  105494. arc?: number;
  105495. slice?: number;
  105496. sideOrientation?: number;
  105497. frontUVs?: Vector4;
  105498. backUVs?: Vector4;
  105499. updatable?: boolean;
  105500. }, scene: any): Mesh;
  105501. /**
  105502. * Creates a plane polygonal mesh. By default, this is a disc
  105503. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  105504. * * 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
  105505. * * 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
  105506. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105507. * * If you create a double-sided mesh, you can choose what parts of 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
  105508. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105509. * @param name defines the name of the mesh
  105510. * @param options defines the options used to create the mesh
  105511. * @param scene defines the hosting scene
  105512. * @returns the plane polygonal mesh
  105513. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  105514. */
  105515. static CreateDisc(name: string, options: {
  105516. radius?: number;
  105517. tessellation?: number;
  105518. arc?: number;
  105519. updatable?: boolean;
  105520. sideOrientation?: number;
  105521. frontUVs?: Vector4;
  105522. backUVs?: Vector4;
  105523. }, scene?: Nullable<Scene>): Mesh;
  105524. /**
  105525. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  105526. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  105527. * * 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`)
  105528. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  105529. * * 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
  105530. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105531. * * If you create a double-sided mesh, you can choose what parts of 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
  105532. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105533. * @param name defines the name of the mesh
  105534. * @param options defines the options used to create the mesh
  105535. * @param scene defines the hosting scene
  105536. * @returns the icosahedron mesh
  105537. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  105538. */
  105539. static CreateIcoSphere(name: string, options: {
  105540. radius?: number;
  105541. radiusX?: number;
  105542. radiusY?: number;
  105543. radiusZ?: number;
  105544. flat?: boolean;
  105545. subdivisions?: number;
  105546. sideOrientation?: number;
  105547. frontUVs?: Vector4;
  105548. backUVs?: Vector4;
  105549. updatable?: boolean;
  105550. }, scene: Scene): Mesh;
  105551. /**
  105552. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  105553. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  105554. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  105555. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  105556. * * 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
  105557. * * 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
  105558. * * 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
  105559. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105560. * * If you create a double-sided mesh, you can choose what parts of 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
  105561. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  105562. * * 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
  105563. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  105564. * * 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
  105565. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  105566. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105567. * @param name defines the name of the mesh
  105568. * @param options defines the options used to create the mesh
  105569. * @param scene defines the hosting scene
  105570. * @returns the ribbon mesh
  105571. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  105572. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  105573. */
  105574. static CreateRibbon(name: string, options: {
  105575. pathArray: Vector3[][];
  105576. closeArray?: boolean;
  105577. closePath?: boolean;
  105578. offset?: number;
  105579. updatable?: boolean;
  105580. sideOrientation?: number;
  105581. frontUVs?: Vector4;
  105582. backUVs?: Vector4;
  105583. instance?: Mesh;
  105584. invertUV?: boolean;
  105585. uvs?: Vector2[];
  105586. colors?: Color4[];
  105587. }, scene?: Nullable<Scene>): Mesh;
  105588. /**
  105589. * Creates a cylinder or a cone mesh
  105590. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  105591. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  105592. * * 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.
  105593. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  105594. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  105595. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  105596. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  105597. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  105598. * * 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).
  105599. * * 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
  105600. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  105601. * * 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
  105602. * * 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.
  105603. * * If `enclose` is false, a ring surface is one element.
  105604. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  105605. * * 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
  105606. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105607. * * If you create a double-sided mesh, you can choose what parts of 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
  105608. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  105609. * @param name defines the name of the mesh
  105610. * @param options defines the options used to create the mesh
  105611. * @param scene defines the hosting scene
  105612. * @returns the cylinder mesh
  105613. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  105614. */
  105615. static CreateCylinder(name: string, options: {
  105616. height?: number;
  105617. diameterTop?: number;
  105618. diameterBottom?: number;
  105619. diameter?: number;
  105620. tessellation?: number;
  105621. subdivisions?: number;
  105622. arc?: number;
  105623. faceColors?: Color4[];
  105624. faceUV?: Vector4[];
  105625. updatable?: boolean;
  105626. hasRings?: boolean;
  105627. enclose?: boolean;
  105628. sideOrientation?: number;
  105629. frontUVs?: Vector4;
  105630. backUVs?: Vector4;
  105631. }, scene: any): Mesh;
  105632. /**
  105633. * Creates a torus mesh
  105634. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  105635. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  105636. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  105637. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105638. * * If you create a double-sided mesh, you can choose what parts of 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
  105639. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  105640. * @param name defines the name of the mesh
  105641. * @param options defines the options used to create the mesh
  105642. * @param scene defines the hosting scene
  105643. * @returns the torus mesh
  105644. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  105645. */
  105646. static CreateTorus(name: string, options: {
  105647. diameter?: number;
  105648. thickness?: number;
  105649. tessellation?: number;
  105650. updatable?: boolean;
  105651. sideOrientation?: number;
  105652. frontUVs?: Vector4;
  105653. backUVs?: Vector4;
  105654. }, scene: any): Mesh;
  105655. /**
  105656. * Creates a torus knot mesh
  105657. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  105658. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  105659. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  105660. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  105661. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105662. * * If you create a double-sided mesh, you can choose what parts of 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
  105663. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  105664. * @param name defines the name of the mesh
  105665. * @param options defines the options used to create the mesh
  105666. * @param scene defines the hosting scene
  105667. * @returns the torus knot mesh
  105668. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  105669. */
  105670. static CreateTorusKnot(name: string, options: {
  105671. radius?: number;
  105672. tube?: number;
  105673. radialSegments?: number;
  105674. tubularSegments?: number;
  105675. p?: number;
  105676. q?: number;
  105677. updatable?: boolean;
  105678. sideOrientation?: number;
  105679. frontUVs?: Vector4;
  105680. backUVs?: Vector4;
  105681. }, scene: any): Mesh;
  105682. /**
  105683. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  105684. * * 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
  105685. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  105686. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  105687. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  105688. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  105689. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  105690. * * 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
  105691. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  105692. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105693. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  105694. * @param name defines the name of the new line system
  105695. * @param options defines the options used to create the line system
  105696. * @param scene defines the hosting scene
  105697. * @returns a new line system mesh
  105698. */
  105699. static CreateLineSystem(name: string, options: {
  105700. lines: Vector3[][];
  105701. updatable?: boolean;
  105702. instance?: Nullable<LinesMesh>;
  105703. colors?: Nullable<Color4[][]>;
  105704. useVertexAlpha?: boolean;
  105705. }, scene: Nullable<Scene>): LinesMesh;
  105706. /**
  105707. * Creates a line mesh
  105708. * 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
  105709. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  105710. * * The parameter `points` is an array successive Vector3
  105711. * * 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
  105712. * * The optional parameter `colors` is an array of successive Color4, one per line point
  105713. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  105714. * * When updating an instance, remember that only point positions can change, not the number of points
  105715. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105716. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  105717. * @param name defines the name of the new line system
  105718. * @param options defines the options used to create the line system
  105719. * @param scene defines the hosting scene
  105720. * @returns a new line mesh
  105721. */
  105722. static CreateLines(name: string, options: {
  105723. points: Vector3[];
  105724. updatable?: boolean;
  105725. instance?: Nullable<LinesMesh>;
  105726. colors?: Color4[];
  105727. useVertexAlpha?: boolean;
  105728. }, scene?: Nullable<Scene>): LinesMesh;
  105729. /**
  105730. * Creates a dashed line mesh
  105731. * * 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
  105732. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  105733. * * The parameter `points` is an array successive Vector3
  105734. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  105735. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  105736. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  105737. * * 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
  105738. * * When updating an instance, remember that only point positions can change, not the number of points
  105739. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105740. * @param name defines the name of the mesh
  105741. * @param options defines the options used to create the mesh
  105742. * @param scene defines the hosting scene
  105743. * @returns the dashed line mesh
  105744. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  105745. */
  105746. static CreateDashedLines(name: string, options: {
  105747. points: Vector3[];
  105748. dashSize?: number;
  105749. gapSize?: number;
  105750. dashNb?: number;
  105751. updatable?: boolean;
  105752. instance?: LinesMesh;
  105753. }, scene?: Nullable<Scene>): LinesMesh;
  105754. /**
  105755. * 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.
  105756. * * 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.
  105757. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  105758. * * 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.
  105759. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  105760. * * 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
  105761. * * 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
  105762. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  105763. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105764. * * If you create a double-sided mesh, you can choose what parts of 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
  105765. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  105766. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  105767. * @param name defines the name of the mesh
  105768. * @param options defines the options used to create the mesh
  105769. * @param scene defines the hosting scene
  105770. * @returns the extruded shape mesh
  105771. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  105772. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  105773. */
  105774. static ExtrudeShape(name: string, options: {
  105775. shape: Vector3[];
  105776. path: Vector3[];
  105777. scale?: number;
  105778. rotation?: number;
  105779. cap?: number;
  105780. updatable?: boolean;
  105781. sideOrientation?: number;
  105782. frontUVs?: Vector4;
  105783. backUVs?: Vector4;
  105784. instance?: Mesh;
  105785. invertUV?: boolean;
  105786. }, scene?: Nullable<Scene>): Mesh;
  105787. /**
  105788. * Creates an custom extruded shape mesh.
  105789. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  105790. * * 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.
  105791. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  105792. * * 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
  105793. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  105794. * * 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
  105795. * * It must returns a float value that will be the scale value applied to the shape on each path point
  105796. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  105797. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  105798. * * 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
  105799. * * 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
  105800. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  105801. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105802. * * If you create a double-sided mesh, you can choose what parts of 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
  105803. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  105804. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105805. * @param name defines the name of the mesh
  105806. * @param options defines the options used to create the mesh
  105807. * @param scene defines the hosting scene
  105808. * @returns the custom extruded shape mesh
  105809. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  105810. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  105811. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  105812. */
  105813. static ExtrudeShapeCustom(name: string, options: {
  105814. shape: Vector3[];
  105815. path: Vector3[];
  105816. scaleFunction?: any;
  105817. rotationFunction?: any;
  105818. ribbonCloseArray?: boolean;
  105819. ribbonClosePath?: boolean;
  105820. cap?: number;
  105821. updatable?: boolean;
  105822. sideOrientation?: number;
  105823. frontUVs?: Vector4;
  105824. backUVs?: Vector4;
  105825. instance?: Mesh;
  105826. invertUV?: boolean;
  105827. }, scene: Scene): Mesh;
  105828. /**
  105829. * Creates lathe mesh.
  105830. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  105831. * * 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
  105832. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  105833. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  105834. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  105835. * * 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
  105836. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  105837. * * 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
  105838. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105839. * * If you create a double-sided mesh, you can choose what parts of 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
  105840. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  105841. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105842. * @param name defines the name of the mesh
  105843. * @param options defines the options used to create the mesh
  105844. * @param scene defines the hosting scene
  105845. * @returns the lathe mesh
  105846. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  105847. */
  105848. static CreateLathe(name: string, options: {
  105849. shape: Vector3[];
  105850. radius?: number;
  105851. tessellation?: number;
  105852. clip?: number;
  105853. arc?: number;
  105854. closed?: boolean;
  105855. updatable?: boolean;
  105856. sideOrientation?: number;
  105857. frontUVs?: Vector4;
  105858. backUVs?: Vector4;
  105859. cap?: number;
  105860. invertUV?: boolean;
  105861. }, scene: Scene): Mesh;
  105862. /**
  105863. * Creates a plane mesh
  105864. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  105865. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  105866. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  105867. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105868. * * If you create a double-sided mesh, you can choose what parts of 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
  105869. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105870. * @param name defines the name of the mesh
  105871. * @param options defines the options used to create the mesh
  105872. * @param scene defines the hosting scene
  105873. * @returns the plane mesh
  105874. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  105875. */
  105876. static CreatePlane(name: string, options: {
  105877. size?: number;
  105878. width?: number;
  105879. height?: number;
  105880. sideOrientation?: number;
  105881. frontUVs?: Vector4;
  105882. backUVs?: Vector4;
  105883. updatable?: boolean;
  105884. sourcePlane?: Plane;
  105885. }, scene: Scene): Mesh;
  105886. /**
  105887. * Creates a ground mesh
  105888. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  105889. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  105890. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105891. * @param name defines the name of the mesh
  105892. * @param options defines the options used to create the mesh
  105893. * @param scene defines the hosting scene
  105894. * @returns the ground mesh
  105895. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  105896. */
  105897. static CreateGround(name: string, options: {
  105898. width?: number;
  105899. height?: number;
  105900. subdivisions?: number;
  105901. subdivisionsX?: number;
  105902. subdivisionsY?: number;
  105903. updatable?: boolean;
  105904. }, scene: any): Mesh;
  105905. /**
  105906. * Creates a tiled ground mesh
  105907. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  105908. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  105909. * * 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
  105910. * * 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
  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. * @param name defines the name of the mesh
  105913. * @param options defines the options used to create the mesh
  105914. * @param scene defines the hosting scene
  105915. * @returns the tiled ground mesh
  105916. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  105917. */
  105918. static CreateTiledGround(name: string, options: {
  105919. xmin: number;
  105920. zmin: number;
  105921. xmax: number;
  105922. zmax: number;
  105923. subdivisions?: {
  105924. w: number;
  105925. h: number;
  105926. };
  105927. precision?: {
  105928. w: number;
  105929. h: number;
  105930. };
  105931. updatable?: boolean;
  105932. }, scene: Scene): Mesh;
  105933. /**
  105934. * Creates a ground mesh from a height map
  105935. * * The parameter `url` sets the URL of the height map image resource.
  105936. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  105937. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  105938. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  105939. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  105940. * * 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.
  105941. * * 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).
  105942. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  105943. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  105944. * @param name defines the name of the mesh
  105945. * @param url defines the url to the height map
  105946. * @param options defines the options used to create the mesh
  105947. * @param scene defines the hosting scene
  105948. * @returns the ground mesh
  105949. * @see https://doc.babylonjs.com/babylon101/height_map
  105950. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  105951. */
  105952. static CreateGroundFromHeightMap(name: string, url: string, options: {
  105953. width?: number;
  105954. height?: number;
  105955. subdivisions?: number;
  105956. minHeight?: number;
  105957. maxHeight?: number;
  105958. colorFilter?: Color3;
  105959. alphaFilter?: number;
  105960. updatable?: boolean;
  105961. onReady?: (mesh: GroundMesh) => void;
  105962. }, scene: Scene): GroundMesh;
  105963. /**
  105964. * Creates a polygon mesh
  105965. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  105966. * * 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
  105967. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  105968. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105969. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  105970. * * Remember you can only change the shape positions, not their number when updating a polygon
  105971. * @param name defines the name of the mesh
  105972. * @param options defines the options used to create the mesh
  105973. * @param scene defines the hosting scene
  105974. * @param earcutInjection can be used to inject your own earcut reference
  105975. * @returns the polygon mesh
  105976. */
  105977. static CreatePolygon(name: string, options: {
  105978. shape: Vector3[];
  105979. holes?: Vector3[][];
  105980. depth?: number;
  105981. faceUV?: Vector4[];
  105982. faceColors?: Color4[];
  105983. updatable?: boolean;
  105984. sideOrientation?: number;
  105985. frontUVs?: Vector4;
  105986. backUVs?: Vector4;
  105987. }, scene: Scene, earcutInjection?: any): Mesh;
  105988. /**
  105989. * Creates an extruded polygon mesh, with depth in the Y direction.
  105990. * * 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)
  105991. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  105992. * @param name defines the name of the mesh
  105993. * @param options defines the options used to create the mesh
  105994. * @param scene defines the hosting scene
  105995. * @param earcutInjection can be used to inject your own earcut reference
  105996. * @returns the polygon mesh
  105997. */
  105998. static ExtrudePolygon(name: string, options: {
  105999. shape: Vector3[];
  106000. holes?: Vector3[][];
  106001. depth?: number;
  106002. faceUV?: Vector4[];
  106003. faceColors?: Color4[];
  106004. updatable?: boolean;
  106005. sideOrientation?: number;
  106006. frontUVs?: Vector4;
  106007. backUVs?: Vector4;
  106008. }, scene: Scene, earcutInjection?: any): Mesh;
  106009. /**
  106010. * Creates a tube mesh.
  106011. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  106012. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  106013. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  106014. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  106015. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  106016. * * 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)
  106017. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  106018. * * 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
  106019. * * 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
  106020. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106021. * * If you create a double-sided mesh, you can choose what parts of 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
  106022. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  106023. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106024. * @param name defines the name of the mesh
  106025. * @param options defines the options used to create the mesh
  106026. * @param scene defines the hosting scene
  106027. * @returns the tube mesh
  106028. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  106029. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  106030. */
  106031. static CreateTube(name: string, options: {
  106032. path: Vector3[];
  106033. radius?: number;
  106034. tessellation?: number;
  106035. radiusFunction?: {
  106036. (i: number, distance: number): number;
  106037. };
  106038. cap?: number;
  106039. arc?: number;
  106040. updatable?: boolean;
  106041. sideOrientation?: number;
  106042. frontUVs?: Vector4;
  106043. backUVs?: Vector4;
  106044. instance?: Mesh;
  106045. invertUV?: boolean;
  106046. }, scene: Scene): Mesh;
  106047. /**
  106048. * Creates a polyhedron mesh
  106049. * * 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
  106050. * * The parameter `size` (positive float, default 1) sets the polygon size
  106051. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  106052. * * 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`
  106053. * * 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
  106054. * * 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)`)
  106055. * * 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
  106056. * * 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
  106057. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106058. * * If you create a double-sided mesh, you can choose what parts of 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
  106059. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106060. * @param name defines the name of the mesh
  106061. * @param options defines the options used to create the mesh
  106062. * @param scene defines the hosting scene
  106063. * @returns the polyhedron mesh
  106064. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  106065. */
  106066. static CreatePolyhedron(name: string, options: {
  106067. type?: number;
  106068. size?: number;
  106069. sizeX?: number;
  106070. sizeY?: number;
  106071. sizeZ?: number;
  106072. custom?: any;
  106073. faceUV?: Vector4[];
  106074. faceColors?: Color4[];
  106075. flat?: boolean;
  106076. updatable?: boolean;
  106077. sideOrientation?: number;
  106078. frontUVs?: Vector4;
  106079. backUVs?: Vector4;
  106080. }, scene: Scene): Mesh;
  106081. /**
  106082. * Creates a decal mesh.
  106083. * 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
  106084. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  106085. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  106086. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  106087. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  106088. * @param name defines the name of the mesh
  106089. * @param sourceMesh defines the mesh where the decal must be applied
  106090. * @param options defines the options used to create the mesh
  106091. * @param scene defines the hosting scene
  106092. * @returns the decal mesh
  106093. * @see https://doc.babylonjs.com/how_to/decals
  106094. */
  106095. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  106096. position?: Vector3;
  106097. normal?: Vector3;
  106098. size?: Vector3;
  106099. angle?: number;
  106100. }): Mesh;
  106101. }
  106102. }
  106103. declare module BABYLON {
  106104. /**
  106105. * A simplifier interface for future simplification implementations
  106106. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  106107. */
  106108. export interface ISimplifier {
  106109. /**
  106110. * Simplification of a given mesh according to the given settings.
  106111. * Since this requires computation, it is assumed that the function runs async.
  106112. * @param settings The settings of the simplification, including quality and distance
  106113. * @param successCallback A callback that will be called after the mesh was simplified.
  106114. * @param errorCallback in case of an error, this callback will be called. optional.
  106115. */
  106116. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  106117. }
  106118. /**
  106119. * Expected simplification settings.
  106120. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  106121. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  106122. */
  106123. export interface ISimplificationSettings {
  106124. /**
  106125. * Gets or sets the expected quality
  106126. */
  106127. quality: number;
  106128. /**
  106129. * Gets or sets the distance when this optimized version should be used
  106130. */
  106131. distance: number;
  106132. /**
  106133. * Gets an already optimized mesh
  106134. */
  106135. optimizeMesh?: boolean;
  106136. }
  106137. /**
  106138. * Class used to specify simplification options
  106139. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  106140. */
  106141. export class SimplificationSettings implements ISimplificationSettings {
  106142. /** expected quality */
  106143. quality: number;
  106144. /** distance when this optimized version should be used */
  106145. distance: number;
  106146. /** already optimized mesh */
  106147. optimizeMesh?: boolean | undefined;
  106148. /**
  106149. * Creates a SimplificationSettings
  106150. * @param quality expected quality
  106151. * @param distance distance when this optimized version should be used
  106152. * @param optimizeMesh already optimized mesh
  106153. */
  106154. constructor(
  106155. /** expected quality */
  106156. quality: number,
  106157. /** distance when this optimized version should be used */
  106158. distance: number,
  106159. /** already optimized mesh */
  106160. optimizeMesh?: boolean | undefined);
  106161. }
  106162. /**
  106163. * Interface used to define a simplification task
  106164. */
  106165. export interface ISimplificationTask {
  106166. /**
  106167. * Array of settings
  106168. */
  106169. settings: Array<ISimplificationSettings>;
  106170. /**
  106171. * Simplification type
  106172. */
  106173. simplificationType: SimplificationType;
  106174. /**
  106175. * Mesh to simplify
  106176. */
  106177. mesh: Mesh;
  106178. /**
  106179. * Callback called on success
  106180. */
  106181. successCallback?: () => void;
  106182. /**
  106183. * Defines if parallel processing can be used
  106184. */
  106185. parallelProcessing: boolean;
  106186. }
  106187. /**
  106188. * Queue used to order the simplification tasks
  106189. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  106190. */
  106191. export class SimplificationQueue {
  106192. private _simplificationArray;
  106193. /**
  106194. * Gets a boolean indicating that the process is still running
  106195. */
  106196. running: boolean;
  106197. /**
  106198. * Creates a new queue
  106199. */
  106200. constructor();
  106201. /**
  106202. * Adds a new simplification task
  106203. * @param task defines a task to add
  106204. */
  106205. addTask(task: ISimplificationTask): void;
  106206. /**
  106207. * Execute next task
  106208. */
  106209. executeNext(): void;
  106210. /**
  106211. * Execute a simplification task
  106212. * @param task defines the task to run
  106213. */
  106214. runSimplification(task: ISimplificationTask): void;
  106215. private getSimplifier;
  106216. }
  106217. /**
  106218. * The implemented types of simplification
  106219. * At the moment only Quadratic Error Decimation is implemented
  106220. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  106221. */
  106222. export enum SimplificationType {
  106223. /** Quadratic error decimation */
  106224. QUADRATIC = 0
  106225. }
  106226. }
  106227. declare module BABYLON {
  106228. interface Scene {
  106229. /** @hidden (Backing field) */
  106230. _simplificationQueue: SimplificationQueue;
  106231. /**
  106232. * Gets or sets the simplification queue attached to the scene
  106233. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  106234. */
  106235. simplificationQueue: SimplificationQueue;
  106236. }
  106237. interface Mesh {
  106238. /**
  106239. * Simplify the mesh according to the given array of settings.
  106240. * Function will return immediately and will simplify async
  106241. * @param settings a collection of simplification settings
  106242. * @param parallelProcessing should all levels calculate parallel or one after the other
  106243. * @param simplificationType the type of simplification to run
  106244. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  106245. * @returns the current mesh
  106246. */
  106247. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  106248. }
  106249. /**
  106250. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  106251. * created in a scene
  106252. */
  106253. export class SimplicationQueueSceneComponent implements ISceneComponent {
  106254. /**
  106255. * The component name helpfull to identify the component in the list of scene components.
  106256. */
  106257. readonly name: string;
  106258. /**
  106259. * The scene the component belongs to.
  106260. */
  106261. scene: Scene;
  106262. /**
  106263. * Creates a new instance of the component for the given scene
  106264. * @param scene Defines the scene to register the component in
  106265. */
  106266. constructor(scene: Scene);
  106267. /**
  106268. * Registers the component in a given scene
  106269. */
  106270. register(): void;
  106271. /**
  106272. * Rebuilds the elements related to this component in case of
  106273. * context lost for instance.
  106274. */
  106275. rebuild(): void;
  106276. /**
  106277. * Disposes the component and the associated ressources
  106278. */
  106279. dispose(): void;
  106280. private _beforeCameraUpdate;
  106281. }
  106282. }
  106283. declare module BABYLON {
  106284. /**
  106285. * Class used to enable access to IndexedDB
  106286. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  106287. */
  106288. export class Database implements IOfflineProvider {
  106289. private _callbackManifestChecked;
  106290. private _currentSceneUrl;
  106291. private _db;
  106292. private _enableSceneOffline;
  106293. private _enableTexturesOffline;
  106294. private _manifestVersionFound;
  106295. private _mustUpdateRessources;
  106296. private _hasReachedQuota;
  106297. private _isSupported;
  106298. private _idbFactory;
  106299. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  106300. private static IsUASupportingBlobStorage;
  106301. /**
  106302. * Gets a boolean indicating if Database storate is enabled (off by default)
  106303. */
  106304. static IDBStorageEnabled: boolean;
  106305. /**
  106306. * Gets a boolean indicating if scene must be saved in the database
  106307. */
  106308. readonly enableSceneOffline: boolean;
  106309. /**
  106310. * Gets a boolean indicating if textures must be saved in the database
  106311. */
  106312. readonly enableTexturesOffline: boolean;
  106313. /**
  106314. * Creates a new Database
  106315. * @param urlToScene defines the url to load the scene
  106316. * @param callbackManifestChecked defines the callback to use when manifest is checked
  106317. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  106318. */
  106319. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  106320. private static _ParseURL;
  106321. private static _ReturnFullUrlLocation;
  106322. private _checkManifestFile;
  106323. /**
  106324. * Open the database and make it available
  106325. * @param successCallback defines the callback to call on success
  106326. * @param errorCallback defines the callback to call on error
  106327. */
  106328. open(successCallback: () => void, errorCallback: () => void): void;
  106329. /**
  106330. * Loads an image from the database
  106331. * @param url defines the url to load from
  106332. * @param image defines the target DOM image
  106333. */
  106334. loadImage(url: string, image: HTMLImageElement): void;
  106335. private _loadImageFromDBAsync;
  106336. private _saveImageIntoDBAsync;
  106337. private _checkVersionFromDB;
  106338. private _loadVersionFromDBAsync;
  106339. private _saveVersionIntoDBAsync;
  106340. /**
  106341. * Loads a file from database
  106342. * @param url defines the URL to load from
  106343. * @param sceneLoaded defines a callback to call on success
  106344. * @param progressCallBack defines a callback to call when progress changed
  106345. * @param errorCallback defines a callback to call on error
  106346. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  106347. */
  106348. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  106349. private _loadFileAsync;
  106350. private _saveFileAsync;
  106351. /**
  106352. * Validates if xhr data is correct
  106353. * @param xhr defines the request to validate
  106354. * @param dataType defines the expected data type
  106355. * @returns true if data is correct
  106356. */
  106357. private static _ValidateXHRData;
  106358. }
  106359. }
  106360. declare module BABYLON {
  106361. /** @hidden */
  106362. export var gpuUpdateParticlesPixelShader: {
  106363. name: string;
  106364. shader: string;
  106365. };
  106366. }
  106367. declare module BABYLON {
  106368. /** @hidden */
  106369. export var gpuUpdateParticlesVertexShader: {
  106370. name: string;
  106371. shader: string;
  106372. };
  106373. }
  106374. declare module BABYLON {
  106375. /** @hidden */
  106376. export var clipPlaneFragmentDeclaration2: {
  106377. name: string;
  106378. shader: string;
  106379. };
  106380. }
  106381. declare module BABYLON {
  106382. /** @hidden */
  106383. export var gpuRenderParticlesPixelShader: {
  106384. name: string;
  106385. shader: string;
  106386. };
  106387. }
  106388. declare module BABYLON {
  106389. /** @hidden */
  106390. export var clipPlaneVertexDeclaration2: {
  106391. name: string;
  106392. shader: string;
  106393. };
  106394. }
  106395. declare module BABYLON {
  106396. /** @hidden */
  106397. export var gpuRenderParticlesVertexShader: {
  106398. name: string;
  106399. shader: string;
  106400. };
  106401. }
  106402. declare module BABYLON {
  106403. /**
  106404. * This represents a GPU particle system in Babylon
  106405. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  106406. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  106407. */
  106408. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  106409. /**
  106410. * The layer mask we are rendering the particles through.
  106411. */
  106412. layerMask: number;
  106413. private _capacity;
  106414. private _activeCount;
  106415. private _currentActiveCount;
  106416. private _accumulatedCount;
  106417. private _renderEffect;
  106418. private _updateEffect;
  106419. private _buffer0;
  106420. private _buffer1;
  106421. private _spriteBuffer;
  106422. private _updateVAO;
  106423. private _renderVAO;
  106424. private _targetIndex;
  106425. private _sourceBuffer;
  106426. private _targetBuffer;
  106427. private _engine;
  106428. private _currentRenderId;
  106429. private _started;
  106430. private _stopped;
  106431. private _timeDelta;
  106432. private _randomTexture;
  106433. private _randomTexture2;
  106434. private _attributesStrideSize;
  106435. private _updateEffectOptions;
  106436. private _randomTextureSize;
  106437. private _actualFrame;
  106438. private readonly _rawTextureWidth;
  106439. /**
  106440. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  106441. */
  106442. static readonly IsSupported: boolean;
  106443. /**
  106444. * An event triggered when the system is disposed.
  106445. */
  106446. onDisposeObservable: Observable<GPUParticleSystem>;
  106447. /**
  106448. * Gets the maximum number of particles active at the same time.
  106449. * @returns The max number of active particles.
  106450. */
  106451. getCapacity(): number;
  106452. /**
  106453. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  106454. * to override the particles.
  106455. */
  106456. forceDepthWrite: boolean;
  106457. /**
  106458. * Gets or set the number of active particles
  106459. */
  106460. activeParticleCount: number;
  106461. private _preWarmDone;
  106462. /**
  106463. * Is this system ready to be used/rendered
  106464. * @return true if the system is ready
  106465. */
  106466. isReady(): boolean;
  106467. /**
  106468. * Gets if the system has been started. (Note: this will still be true after stop is called)
  106469. * @returns True if it has been started, otherwise false.
  106470. */
  106471. isStarted(): boolean;
  106472. /**
  106473. * Starts the particle system and begins to emit
  106474. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  106475. */
  106476. start(delay?: number): void;
  106477. /**
  106478. * Stops the particle system.
  106479. */
  106480. stop(): void;
  106481. /**
  106482. * Remove all active particles
  106483. */
  106484. reset(): void;
  106485. /**
  106486. * Returns the string "GPUParticleSystem"
  106487. * @returns a string containing the class name
  106488. */
  106489. getClassName(): string;
  106490. private _colorGradientsTexture;
  106491. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  106492. /**
  106493. * Adds a new color gradient
  106494. * @param gradient defines the gradient to use (between 0 and 1)
  106495. * @param color1 defines the color to affect to the specified gradient
  106496. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  106497. * @returns the current particle system
  106498. */
  106499. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  106500. /**
  106501. * Remove a specific color gradient
  106502. * @param gradient defines the gradient to remove
  106503. * @returns the current particle system
  106504. */
  106505. removeColorGradient(gradient: number): GPUParticleSystem;
  106506. private _angularSpeedGradientsTexture;
  106507. private _sizeGradientsTexture;
  106508. private _velocityGradientsTexture;
  106509. private _limitVelocityGradientsTexture;
  106510. private _dragGradientsTexture;
  106511. private _addFactorGradient;
  106512. /**
  106513. * Adds a new size gradient
  106514. * @param gradient defines the gradient to use (between 0 and 1)
  106515. * @param factor defines the size factor to affect to the specified gradient
  106516. * @returns the current particle system
  106517. */
  106518. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  106519. /**
  106520. * Remove a specific size gradient
  106521. * @param gradient defines the gradient to remove
  106522. * @returns the current particle system
  106523. */
  106524. removeSizeGradient(gradient: number): GPUParticleSystem;
  106525. /**
  106526. * Adds a new angular speed gradient
  106527. * @param gradient defines the gradient to use (between 0 and 1)
  106528. * @param factor defines the angular speed to affect to the specified gradient
  106529. * @returns the current particle system
  106530. */
  106531. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  106532. /**
  106533. * Remove a specific angular speed gradient
  106534. * @param gradient defines the gradient to remove
  106535. * @returns the current particle system
  106536. */
  106537. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  106538. /**
  106539. * Adds a new velocity gradient
  106540. * @param gradient defines the gradient to use (between 0 and 1)
  106541. * @param factor defines the velocity to affect to the specified gradient
  106542. * @returns the current particle system
  106543. */
  106544. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  106545. /**
  106546. * Remove a specific velocity gradient
  106547. * @param gradient defines the gradient to remove
  106548. * @returns the current particle system
  106549. */
  106550. removeVelocityGradient(gradient: number): GPUParticleSystem;
  106551. /**
  106552. * Adds a new limit velocity gradient
  106553. * @param gradient defines the gradient to use (between 0 and 1)
  106554. * @param factor defines the limit velocity value to affect to the specified gradient
  106555. * @returns the current particle system
  106556. */
  106557. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  106558. /**
  106559. * Remove a specific limit velocity gradient
  106560. * @param gradient defines the gradient to remove
  106561. * @returns the current particle system
  106562. */
  106563. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  106564. /**
  106565. * Adds a new drag gradient
  106566. * @param gradient defines the gradient to use (between 0 and 1)
  106567. * @param factor defines the drag value to affect to the specified gradient
  106568. * @returns the current particle system
  106569. */
  106570. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  106571. /**
  106572. * Remove a specific drag gradient
  106573. * @param gradient defines the gradient to remove
  106574. * @returns the current particle system
  106575. */
  106576. removeDragGradient(gradient: number): GPUParticleSystem;
  106577. /**
  106578. * Not supported by GPUParticleSystem
  106579. * @param gradient defines the gradient to use (between 0 and 1)
  106580. * @param factor defines the emit rate value to affect to the specified gradient
  106581. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  106582. * @returns the current particle system
  106583. */
  106584. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  106585. /**
  106586. * Not supported by GPUParticleSystem
  106587. * @param gradient defines the gradient to remove
  106588. * @returns the current particle system
  106589. */
  106590. removeEmitRateGradient(gradient: number): IParticleSystem;
  106591. /**
  106592. * Not supported by GPUParticleSystem
  106593. * @param gradient defines the gradient to use (between 0 and 1)
  106594. * @param factor defines the start size value to affect to the specified gradient
  106595. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  106596. * @returns the current particle system
  106597. */
  106598. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  106599. /**
  106600. * Not supported by GPUParticleSystem
  106601. * @param gradient defines the gradient to remove
  106602. * @returns the current particle system
  106603. */
  106604. removeStartSizeGradient(gradient: number): IParticleSystem;
  106605. /**
  106606. * Not supported by GPUParticleSystem
  106607. * @param gradient defines the gradient to use (between 0 and 1)
  106608. * @param min defines the color remap minimal range
  106609. * @param max defines the color remap maximal range
  106610. * @returns the current particle system
  106611. */
  106612. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  106613. /**
  106614. * Not supported by GPUParticleSystem
  106615. * @param gradient defines the gradient to remove
  106616. * @returns the current particle system
  106617. */
  106618. removeColorRemapGradient(): IParticleSystem;
  106619. /**
  106620. * Not supported by GPUParticleSystem
  106621. * @param gradient defines the gradient to use (between 0 and 1)
  106622. * @param min defines the alpha remap minimal range
  106623. * @param max defines the alpha remap maximal range
  106624. * @returns the current particle system
  106625. */
  106626. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  106627. /**
  106628. * Not supported by GPUParticleSystem
  106629. * @param gradient defines the gradient to remove
  106630. * @returns the current particle system
  106631. */
  106632. removeAlphaRemapGradient(): IParticleSystem;
  106633. /**
  106634. * Not supported by GPUParticleSystem
  106635. * @param gradient defines the gradient to use (between 0 and 1)
  106636. * @param color defines the color to affect to the specified gradient
  106637. * @returns the current particle system
  106638. */
  106639. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  106640. /**
  106641. * Not supported by GPUParticleSystem
  106642. * @param gradient defines the gradient to remove
  106643. * @returns the current particle system
  106644. */
  106645. removeRampGradient(): IParticleSystem;
  106646. /**
  106647. * Not supported by GPUParticleSystem
  106648. * @returns the list of ramp gradients
  106649. */
  106650. getRampGradients(): Nullable<Array<Color3Gradient>>;
  106651. /**
  106652. * Not supported by GPUParticleSystem
  106653. * Gets or sets a boolean indicating that ramp gradients must be used
  106654. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  106655. */
  106656. useRampGradients: boolean;
  106657. /**
  106658. * Not supported by GPUParticleSystem
  106659. * @param gradient defines the gradient to use (between 0 and 1)
  106660. * @param factor defines the life time factor to affect to the specified gradient
  106661. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  106662. * @returns the current particle system
  106663. */
  106664. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  106665. /**
  106666. * Not supported by GPUParticleSystem
  106667. * @param gradient defines the gradient to remove
  106668. * @returns the current particle system
  106669. */
  106670. removeLifeTimeGradient(gradient: number): IParticleSystem;
  106671. /**
  106672. * Instantiates a GPU particle system.
  106673. * 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.
  106674. * @param name The name of the particle system
  106675. * @param options The options used to create the system
  106676. * @param scene The scene the particle system belongs to
  106677. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  106678. */
  106679. constructor(name: string, options: Partial<{
  106680. capacity: number;
  106681. randomTextureSize: number;
  106682. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  106683. protected _reset(): void;
  106684. private _createUpdateVAO;
  106685. private _createRenderVAO;
  106686. private _initialize;
  106687. /** @hidden */
  106688. _recreateUpdateEffect(): void;
  106689. /** @hidden */
  106690. _recreateRenderEffect(): void;
  106691. /**
  106692. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  106693. * @param preWarm defines if we are in the pre-warmimg phase
  106694. */
  106695. animate(preWarm?: boolean): void;
  106696. private _createFactorGradientTexture;
  106697. private _createSizeGradientTexture;
  106698. private _createAngularSpeedGradientTexture;
  106699. private _createVelocityGradientTexture;
  106700. private _createLimitVelocityGradientTexture;
  106701. private _createDragGradientTexture;
  106702. private _createColorGradientTexture;
  106703. /**
  106704. * Renders the particle system in its current state
  106705. * @param preWarm defines if the system should only update the particles but not render them
  106706. * @returns the current number of particles
  106707. */
  106708. render(preWarm?: boolean): number;
  106709. /**
  106710. * Rebuilds the particle system
  106711. */
  106712. rebuild(): void;
  106713. private _releaseBuffers;
  106714. private _releaseVAOs;
  106715. /**
  106716. * Disposes the particle system and free the associated resources
  106717. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  106718. */
  106719. dispose(disposeTexture?: boolean): void;
  106720. /**
  106721. * Clones the particle system.
  106722. * @param name The name of the cloned object
  106723. * @param newEmitter The new emitter to use
  106724. * @returns the cloned particle system
  106725. */
  106726. clone(name: string, newEmitter: any): GPUParticleSystem;
  106727. /**
  106728. * Serializes the particle system to a JSON object.
  106729. * @returns the JSON object
  106730. */
  106731. serialize(): any;
  106732. /**
  106733. * Parses a JSON object to create a GPU particle system.
  106734. * @param parsedParticleSystem The JSON object to parse
  106735. * @param scene The scene to create the particle system in
  106736. * @param rootUrl The root url to use to load external dependencies like texture
  106737. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  106738. * @returns the parsed GPU particle system
  106739. */
  106740. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  106741. }
  106742. }
  106743. declare module BABYLON {
  106744. /**
  106745. * Represents a set of particle systems working together to create a specific effect
  106746. */
  106747. export class ParticleSystemSet implements IDisposable {
  106748. private _emitterCreationOptions;
  106749. private _emitterNode;
  106750. /**
  106751. * Gets the particle system list
  106752. */
  106753. systems: IParticleSystem[];
  106754. /**
  106755. * Gets the emitter node used with this set
  106756. */
  106757. readonly emitterNode: Nullable<TransformNode>;
  106758. /**
  106759. * Creates a new emitter mesh as a sphere
  106760. * @param options defines the options used to create the sphere
  106761. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  106762. * @param scene defines the hosting scene
  106763. */
  106764. setEmitterAsSphere(options: {
  106765. diameter: number;
  106766. segments: number;
  106767. color: Color3;
  106768. }, renderingGroupId: number, scene: Scene): void;
  106769. /**
  106770. * Starts all particle systems of the set
  106771. * @param emitter defines an optional mesh to use as emitter for the particle systems
  106772. */
  106773. start(emitter?: AbstractMesh): void;
  106774. /**
  106775. * Release all associated resources
  106776. */
  106777. dispose(): void;
  106778. /**
  106779. * Serialize the set into a JSON compatible object
  106780. * @returns a JSON compatible representation of the set
  106781. */
  106782. serialize(): any;
  106783. /**
  106784. * Parse a new ParticleSystemSet from a serialized source
  106785. * @param data defines a JSON compatible representation of the set
  106786. * @param scene defines the hosting scene
  106787. * @param gpu defines if we want GPU particles or CPU particles
  106788. * @returns a new ParticleSystemSet
  106789. */
  106790. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  106791. }
  106792. }
  106793. declare module BABYLON {
  106794. /**
  106795. * This class is made for on one-liner static method to help creating particle system set.
  106796. */
  106797. export class ParticleHelper {
  106798. /**
  106799. * Gets or sets base Assets URL
  106800. */
  106801. static BaseAssetsUrl: string;
  106802. /**
  106803. * Create a default particle system that you can tweak
  106804. * @param emitter defines the emitter to use
  106805. * @param capacity defines the system capacity (default is 500 particles)
  106806. * @param scene defines the hosting scene
  106807. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  106808. * @returns the new Particle system
  106809. */
  106810. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  106811. /**
  106812. * This is the main static method (one-liner) of this helper to create different particle systems
  106813. * @param type This string represents the type to the particle system to create
  106814. * @param scene The scene where the particle system should live
  106815. * @param gpu If the system will use gpu
  106816. * @returns the ParticleSystemSet created
  106817. */
  106818. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  106819. /**
  106820. * Static function used to export a particle system to a ParticleSystemSet variable.
  106821. * Please note that the emitter shape is not exported
  106822. * @param systems defines the particle systems to export
  106823. * @returns the created particle system set
  106824. */
  106825. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  106826. }
  106827. }
  106828. declare module BABYLON {
  106829. interface Engine {
  106830. /**
  106831. * Create an effect to use with particle systems.
  106832. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  106833. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  106834. * @param uniformsNames defines a list of attribute names
  106835. * @param samplers defines an array of string used to represent textures
  106836. * @param defines defines the string containing the defines to use to compile the shaders
  106837. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  106838. * @param onCompiled defines a function to call when the effect creation is successful
  106839. * @param onError defines a function to call when the effect creation has failed
  106840. * @returns the new Effect
  106841. */
  106842. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  106843. }
  106844. interface Mesh {
  106845. /**
  106846. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  106847. * @returns an array of IParticleSystem
  106848. */
  106849. getEmittedParticleSystems(): IParticleSystem[];
  106850. /**
  106851. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  106852. * @returns an array of IParticleSystem
  106853. */
  106854. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  106855. }
  106856. /**
  106857. * @hidden
  106858. */
  106859. export var _IDoNeedToBeInTheBuild: number;
  106860. }
  106861. declare module BABYLON {
  106862. interface Scene {
  106863. /** @hidden (Backing field) */
  106864. _physicsEngine: Nullable<IPhysicsEngine>;
  106865. /**
  106866. * Gets the current physics engine
  106867. * @returns a IPhysicsEngine or null if none attached
  106868. */
  106869. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  106870. /**
  106871. * Enables physics to the current scene
  106872. * @param gravity defines the scene's gravity for the physics engine
  106873. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  106874. * @return a boolean indicating if the physics engine was initialized
  106875. */
  106876. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  106877. /**
  106878. * Disables and disposes the physics engine associated with the scene
  106879. */
  106880. disablePhysicsEngine(): void;
  106881. /**
  106882. * Gets a boolean indicating if there is an active physics engine
  106883. * @returns a boolean indicating if there is an active physics engine
  106884. */
  106885. isPhysicsEnabled(): boolean;
  106886. /**
  106887. * Deletes a physics compound impostor
  106888. * @param compound defines the compound to delete
  106889. */
  106890. deleteCompoundImpostor(compound: any): void;
  106891. /**
  106892. * An event triggered when physic simulation is about to be run
  106893. */
  106894. onBeforePhysicsObservable: Observable<Scene>;
  106895. /**
  106896. * An event triggered when physic simulation has been done
  106897. */
  106898. onAfterPhysicsObservable: Observable<Scene>;
  106899. }
  106900. interface AbstractMesh {
  106901. /** @hidden */
  106902. _physicsImpostor: Nullable<PhysicsImpostor>;
  106903. /**
  106904. * Gets or sets impostor used for physic simulation
  106905. * @see http://doc.babylonjs.com/features/physics_engine
  106906. */
  106907. physicsImpostor: Nullable<PhysicsImpostor>;
  106908. /**
  106909. * Gets the current physics impostor
  106910. * @see http://doc.babylonjs.com/features/physics_engine
  106911. * @returns a physics impostor or null
  106912. */
  106913. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  106914. /** Apply a physic impulse to the mesh
  106915. * @param force defines the force to apply
  106916. * @param contactPoint defines where to apply the force
  106917. * @returns the current mesh
  106918. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  106919. */
  106920. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  106921. /**
  106922. * Creates a physic joint between two meshes
  106923. * @param otherMesh defines the other mesh to use
  106924. * @param pivot1 defines the pivot to use on this mesh
  106925. * @param pivot2 defines the pivot to use on the other mesh
  106926. * @param options defines additional options (can be plugin dependent)
  106927. * @returns the current mesh
  106928. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  106929. */
  106930. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  106931. /** @hidden */
  106932. _disposePhysicsObserver: Nullable<Observer<Node>>;
  106933. }
  106934. /**
  106935. * Defines the physics engine scene component responsible to manage a physics engine
  106936. */
  106937. export class PhysicsEngineSceneComponent implements ISceneComponent {
  106938. /**
  106939. * The component name helpful to identify the component in the list of scene components.
  106940. */
  106941. readonly name: string;
  106942. /**
  106943. * The scene the component belongs to.
  106944. */
  106945. scene: Scene;
  106946. /**
  106947. * Creates a new instance of the component for the given scene
  106948. * @param scene Defines the scene to register the component in
  106949. */
  106950. constructor(scene: Scene);
  106951. /**
  106952. * Registers the component in a given scene
  106953. */
  106954. register(): void;
  106955. /**
  106956. * Rebuilds the elements related to this component in case of
  106957. * context lost for instance.
  106958. */
  106959. rebuild(): void;
  106960. /**
  106961. * Disposes the component and the associated ressources
  106962. */
  106963. dispose(): void;
  106964. }
  106965. }
  106966. declare module BABYLON {
  106967. /**
  106968. * A helper for physics simulations
  106969. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  106970. */
  106971. export class PhysicsHelper {
  106972. private _scene;
  106973. private _physicsEngine;
  106974. /**
  106975. * Initializes the Physics helper
  106976. * @param scene Babylon.js scene
  106977. */
  106978. constructor(scene: Scene);
  106979. /**
  106980. * Applies a radial explosion impulse
  106981. * @param origin the origin of the explosion
  106982. * @param radius the explosion radius
  106983. * @param strength the explosion strength
  106984. * @param falloff possible options: Constant & Linear. Defaults to Constant
  106985. * @returns A physics radial explosion event, or null
  106986. */
  106987. applyRadialExplosionImpulse(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  106988. /**
  106989. * Applies a radial explosion force
  106990. * @param origin the origin of the explosion
  106991. * @param radius the explosion radius
  106992. * @param strength the explosion strength
  106993. * @param falloff possible options: Constant & Linear. Defaults to Constant
  106994. * @returns A physics radial explosion event, or null
  106995. */
  106996. applyRadialExplosionForce(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  106997. /**
  106998. * Creates a gravitational field
  106999. * @param origin the origin of the explosion
  107000. * @param radius the explosion radius
  107001. * @param strength the explosion strength
  107002. * @param falloff possible options: Constant & Linear. Defaults to Constant
  107003. * @returns A physics gravitational field event, or null
  107004. */
  107005. gravitationalField(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  107006. /**
  107007. * Creates a physics updraft event
  107008. * @param origin the origin of the updraft
  107009. * @param radius the radius of the updraft
  107010. * @param strength the strength of the updraft
  107011. * @param height the height of the updraft
  107012. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  107013. * @returns A physics updraft event, or null
  107014. */
  107015. updraft(origin: Vector3, radius: number, strength: number, height: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  107016. /**
  107017. * Creates a physics vortex event
  107018. * @param origin the of the vortex
  107019. * @param radius the radius of the vortex
  107020. * @param strength the strength of the vortex
  107021. * @param height the height of the vortex
  107022. * @returns a Physics vortex event, or null
  107023. * A physics vortex event or null
  107024. */
  107025. vortex(origin: Vector3, radius: number, strength: number, height: number): Nullable<PhysicsVortexEvent>;
  107026. }
  107027. /**
  107028. * Represents a physics radial explosion event
  107029. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107030. */
  107031. export class PhysicsRadialExplosionEvent {
  107032. private _scene;
  107033. private _sphere;
  107034. private _sphereOptions;
  107035. private _rays;
  107036. private _dataFetched;
  107037. /**
  107038. * Initializes a radial explosioin event
  107039. * @param scene BabylonJS scene
  107040. */
  107041. constructor(scene: Scene);
  107042. /**
  107043. * Returns the data related to the radial explosion event (sphere & rays).
  107044. * @returns The radial explosion event data
  107045. */
  107046. getData(): PhysicsRadialExplosionEventData;
  107047. /**
  107048. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  107049. * @param impostor A physics imposter
  107050. * @param origin the origin of the explosion
  107051. * @param radius the explosion radius
  107052. * @param strength the explosion strength
  107053. * @param falloff possible options: Constant & Linear
  107054. * @returns {Nullable<PhysicsForceAndContactPoint>} A physics force and contact point, or null
  107055. */
  107056. getImpostorForceAndContactPoint(impostor: PhysicsImpostor, origin: Vector3, radius: number, strength: number, falloff: PhysicsRadialImpulseFalloff): Nullable<PhysicsForceAndContactPoint>;
  107057. /**
  107058. * Disposes the sphere.
  107059. * @param force Specifies if the sphere should be disposed by force
  107060. */
  107061. dispose(force?: boolean): void;
  107062. /*** Helpers ***/
  107063. private _prepareSphere;
  107064. private _intersectsWithSphere;
  107065. }
  107066. /**
  107067. * Represents a gravitational field event
  107068. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107069. */
  107070. export class PhysicsGravitationalFieldEvent {
  107071. private _physicsHelper;
  107072. private _scene;
  107073. private _origin;
  107074. private _radius;
  107075. private _strength;
  107076. private _falloff;
  107077. private _tickCallback;
  107078. private _sphere;
  107079. private _dataFetched;
  107080. /**
  107081. * Initializes the physics gravitational field event
  107082. * @param physicsHelper A physics helper
  107083. * @param scene BabylonJS scene
  107084. * @param origin The origin position of the gravitational field event
  107085. * @param radius The radius of the gravitational field event
  107086. * @param strength The strength of the gravitational field event
  107087. * @param falloff The falloff for the gravitational field event
  107088. */
  107089. constructor(physicsHelper: PhysicsHelper, scene: Scene, origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff);
  107090. /**
  107091. * Returns the data related to the gravitational field event (sphere).
  107092. * @returns A gravitational field event
  107093. */
  107094. getData(): PhysicsGravitationalFieldEventData;
  107095. /**
  107096. * Enables the gravitational field.
  107097. */
  107098. enable(): void;
  107099. /**
  107100. * Disables the gravitational field.
  107101. */
  107102. disable(): void;
  107103. /**
  107104. * Disposes the sphere.
  107105. * @param force The force to dispose from the gravitational field event
  107106. */
  107107. dispose(force?: boolean): void;
  107108. private _tick;
  107109. }
  107110. /**
  107111. * Represents a physics updraft event
  107112. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107113. */
  107114. export class PhysicsUpdraftEvent {
  107115. private _scene;
  107116. private _origin;
  107117. private _radius;
  107118. private _strength;
  107119. private _height;
  107120. private _updraftMode;
  107121. private _physicsEngine;
  107122. private _originTop;
  107123. private _originDirection;
  107124. private _tickCallback;
  107125. private _cylinder;
  107126. private _cylinderPosition;
  107127. private _dataFetched;
  107128. /**
  107129. * Initializes the physics updraft event
  107130. * @param _scene BabylonJS scene
  107131. * @param _origin The origin position of the updraft
  107132. * @param _radius The radius of the updraft
  107133. * @param _strength The strength of the updraft
  107134. * @param _height The height of the updraft
  107135. * @param _updraftMode The mode of the updraft
  107136. */
  107137. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number, _updraftMode: PhysicsUpdraftMode);
  107138. /**
  107139. * Returns the data related to the updraft event (cylinder).
  107140. * @returns A physics updraft event
  107141. */
  107142. getData(): PhysicsUpdraftEventData;
  107143. /**
  107144. * Enables the updraft.
  107145. */
  107146. enable(): void;
  107147. /**
  107148. * Disables the cortex.
  107149. */
  107150. disable(): void;
  107151. /**
  107152. * Disposes the sphere.
  107153. * @param force Specifies if the updraft should be disposed by force
  107154. */
  107155. dispose(force?: boolean): void;
  107156. private getImpostorForceAndContactPoint;
  107157. private _tick;
  107158. /*** Helpers ***/
  107159. private _prepareCylinder;
  107160. private _intersectsWithCylinder;
  107161. }
  107162. /**
  107163. * Represents a physics vortex event
  107164. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107165. */
  107166. export class PhysicsVortexEvent {
  107167. private _scene;
  107168. private _origin;
  107169. private _radius;
  107170. private _strength;
  107171. private _height;
  107172. private _physicsEngine;
  107173. private _originTop;
  107174. private _centripetalForceThreshold;
  107175. private _updraftMultiplier;
  107176. private _tickCallback;
  107177. private _cylinder;
  107178. private _cylinderPosition;
  107179. private _dataFetched;
  107180. /**
  107181. * Initializes the physics vortex event
  107182. * @param _scene The BabylonJS scene
  107183. * @param _origin The origin position of the vortex
  107184. * @param _radius The radius of the vortex
  107185. * @param _strength The strength of the vortex
  107186. * @param _height The height of the vortex
  107187. */
  107188. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number);
  107189. /**
  107190. * Returns the data related to the vortex event (cylinder).
  107191. * @returns The physics vortex event data
  107192. */
  107193. getData(): PhysicsVortexEventData;
  107194. /**
  107195. * Enables the vortex.
  107196. */
  107197. enable(): void;
  107198. /**
  107199. * Disables the cortex.
  107200. */
  107201. disable(): void;
  107202. /**
  107203. * Disposes the sphere.
  107204. * @param force
  107205. */
  107206. dispose(force?: boolean): void;
  107207. private getImpostorForceAndContactPoint;
  107208. private _tick;
  107209. /*** Helpers ***/
  107210. private _prepareCylinder;
  107211. private _intersectsWithCylinder;
  107212. }
  107213. /**
  107214. * The strenght of the force in correspondence to the distance of the affected object
  107215. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107216. */
  107217. export enum PhysicsRadialImpulseFalloff {
  107218. /** Defines that impulse is constant in strength across it's whole radius */
  107219. Constant = 0,
  107220. /** DEfines that impulse gets weaker if it's further from the origin */
  107221. Linear = 1
  107222. }
  107223. /**
  107224. * The strength of the force in correspondence to the distance of the affected object
  107225. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107226. */
  107227. export enum PhysicsUpdraftMode {
  107228. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  107229. Center = 0,
  107230. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  107231. Perpendicular = 1
  107232. }
  107233. /**
  107234. * Interface for a physics force and contact point
  107235. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107236. */
  107237. export interface PhysicsForceAndContactPoint {
  107238. /**
  107239. * The force applied at the contact point
  107240. */
  107241. force: Vector3;
  107242. /**
  107243. * The contact point
  107244. */
  107245. contactPoint: Vector3;
  107246. }
  107247. /**
  107248. * Interface for radial explosion event data
  107249. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107250. */
  107251. export interface PhysicsRadialExplosionEventData {
  107252. /**
  107253. * A sphere used for the radial explosion event
  107254. */
  107255. sphere: Mesh;
  107256. /**
  107257. * An array of rays for the radial explosion event
  107258. */
  107259. rays: Array<Ray>;
  107260. }
  107261. /**
  107262. * Interface for gravitational field event data
  107263. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107264. */
  107265. export interface PhysicsGravitationalFieldEventData {
  107266. /**
  107267. * A sphere mesh used for the gravitational field event
  107268. */
  107269. sphere: Mesh;
  107270. }
  107271. /**
  107272. * Interface for updraft event data
  107273. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107274. */
  107275. export interface PhysicsUpdraftEventData {
  107276. /**
  107277. * A cylinder used for the updraft event
  107278. */
  107279. cylinder: Mesh;
  107280. }
  107281. /**
  107282. * Interface for vortex event data
  107283. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107284. */
  107285. export interface PhysicsVortexEventData {
  107286. /**
  107287. * A cylinder used for the vortex event
  107288. */
  107289. cylinder: Mesh;
  107290. }
  107291. }
  107292. declare module BABYLON {
  107293. /**
  107294. * AmmoJS Physics plugin
  107295. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107296. * @see https://github.com/kripken/ammo.js/
  107297. */
  107298. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  107299. private _useDeltaForWorldStep;
  107300. /**
  107301. * Reference to the Ammo library
  107302. */
  107303. bjsAMMO: any;
  107304. /**
  107305. * Created ammoJS world which physics bodies are added to
  107306. */
  107307. world: any;
  107308. /**
  107309. * Name of the plugin
  107310. */
  107311. name: string;
  107312. private _timeStep;
  107313. private _fixedTimeStep;
  107314. private _maxSteps;
  107315. private _tmpQuaternion;
  107316. private _tmpAmmoTransform;
  107317. private _tmpAmmoQuaternion;
  107318. private _tmpAmmoConcreteContactResultCallback;
  107319. private _collisionConfiguration;
  107320. private _dispatcher;
  107321. private _overlappingPairCache;
  107322. private _solver;
  107323. private _tmpAmmoVectorA;
  107324. private _tmpAmmoVectorB;
  107325. private _tmpAmmoVectorC;
  107326. private _tmpContactCallbackResult;
  107327. private static readonly DISABLE_COLLISION_FLAG;
  107328. private static readonly KINEMATIC_FLAG;
  107329. private static readonly DISABLE_DEACTIVATION_FLAG;
  107330. /**
  107331. * Initializes the ammoJS plugin
  107332. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  107333. * @param ammoInjection can be used to inject your own ammo reference
  107334. */
  107335. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any);
  107336. /**
  107337. * Sets the gravity of the physics world (m/(s^2))
  107338. * @param gravity Gravity to set
  107339. */
  107340. setGravity(gravity: Vector3): void;
  107341. /**
  107342. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  107343. * @param timeStep timestep to use in seconds
  107344. */
  107345. setTimeStep(timeStep: number): void;
  107346. /**
  107347. * 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)
  107348. * @param fixedTimeStep fixedTimeStep to use in seconds
  107349. */
  107350. setFixedTimeStep(fixedTimeStep: number): void;
  107351. /**
  107352. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  107353. * @param maxSteps the maximum number of steps by the physics engine per frame
  107354. */
  107355. setMaxSteps(maxSteps: number): void;
  107356. /**
  107357. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  107358. * @returns the current timestep in seconds
  107359. */
  107360. getTimeStep(): number;
  107361. private _isImpostorInContact;
  107362. private _isImpostorPairInContact;
  107363. private _stepSimulation;
  107364. /**
  107365. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  107366. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  107367. * After the step the babylon meshes are set to the position of the physics imposters
  107368. * @param delta amount of time to step forward
  107369. * @param impostors array of imposters to update before/after the step
  107370. */
  107371. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  107372. private _tmpVector;
  107373. private _tmpMatrix;
  107374. /**
  107375. * Applies an implulse on the imposter
  107376. * @param impostor imposter to apply impulse
  107377. * @param force amount of force to be applied to the imposter
  107378. * @param contactPoint the location to apply the impulse on the imposter
  107379. */
  107380. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  107381. /**
  107382. * Applies a force on the imposter
  107383. * @param impostor imposter to apply force
  107384. * @param force amount of force to be applied to the imposter
  107385. * @param contactPoint the location to apply the force on the imposter
  107386. */
  107387. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  107388. /**
  107389. * Creates a physics body using the plugin
  107390. * @param impostor the imposter to create the physics body on
  107391. */
  107392. generatePhysicsBody(impostor: PhysicsImpostor): void;
  107393. /**
  107394. * Removes the physics body from the imposter and disposes of the body's memory
  107395. * @param impostor imposter to remove the physics body from
  107396. */
  107397. removePhysicsBody(impostor: PhysicsImpostor): void;
  107398. /**
  107399. * Generates a joint
  107400. * @param impostorJoint the imposter joint to create the joint with
  107401. */
  107402. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  107403. /**
  107404. * Removes a joint
  107405. * @param impostorJoint the imposter joint to remove the joint from
  107406. */
  107407. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  107408. private _addMeshVerts;
  107409. private _createShape;
  107410. /**
  107411. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  107412. * @param impostor imposter containing the physics body and babylon object
  107413. */
  107414. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  107415. /**
  107416. * Sets the babylon object's position/rotation from the physics body's position/rotation
  107417. * @param impostor imposter containing the physics body and babylon object
  107418. * @param newPosition new position
  107419. * @param newRotation new rotation
  107420. */
  107421. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  107422. /**
  107423. * If this plugin is supported
  107424. * @returns true if its supported
  107425. */
  107426. isSupported(): boolean;
  107427. /**
  107428. * Sets the linear velocity of the physics body
  107429. * @param impostor imposter to set the velocity on
  107430. * @param velocity velocity to set
  107431. */
  107432. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  107433. /**
  107434. * Sets the angular velocity of the physics body
  107435. * @param impostor imposter to set the velocity on
  107436. * @param velocity velocity to set
  107437. */
  107438. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  107439. /**
  107440. * gets the linear velocity
  107441. * @param impostor imposter to get linear velocity from
  107442. * @returns linear velocity
  107443. */
  107444. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  107445. /**
  107446. * gets the angular velocity
  107447. * @param impostor imposter to get angular velocity from
  107448. * @returns angular velocity
  107449. */
  107450. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  107451. /**
  107452. * Sets the mass of physics body
  107453. * @param impostor imposter to set the mass on
  107454. * @param mass mass to set
  107455. */
  107456. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  107457. /**
  107458. * Gets the mass of the physics body
  107459. * @param impostor imposter to get the mass from
  107460. * @returns mass
  107461. */
  107462. getBodyMass(impostor: PhysicsImpostor): number;
  107463. /**
  107464. * Gets friction of the impostor
  107465. * @param impostor impostor to get friction from
  107466. * @returns friction value
  107467. */
  107468. getBodyFriction(impostor: PhysicsImpostor): number;
  107469. /**
  107470. * Sets friction of the impostor
  107471. * @param impostor impostor to set friction on
  107472. * @param friction friction value
  107473. */
  107474. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  107475. /**
  107476. * Gets restitution of the impostor
  107477. * @param impostor impostor to get restitution from
  107478. * @returns restitution value
  107479. */
  107480. getBodyRestitution(impostor: PhysicsImpostor): number;
  107481. /**
  107482. * Sets resitution of the impostor
  107483. * @param impostor impostor to set resitution on
  107484. * @param restitution resitution value
  107485. */
  107486. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  107487. /**
  107488. * Sleeps the physics body and stops it from being active
  107489. * @param impostor impostor to sleep
  107490. */
  107491. sleepBody(impostor: PhysicsImpostor): void;
  107492. /**
  107493. * Activates the physics body
  107494. * @param impostor impostor to activate
  107495. */
  107496. wakeUpBody(impostor: PhysicsImpostor): void;
  107497. /**
  107498. * Updates the distance parameters of the joint
  107499. * @param joint joint to update
  107500. * @param maxDistance maximum distance of the joint
  107501. * @param minDistance minimum distance of the joint
  107502. */
  107503. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  107504. /**
  107505. * Sets a motor on the joint
  107506. * @param joint joint to set motor on
  107507. * @param speed speed of the motor
  107508. * @param maxForce maximum force of the motor
  107509. * @param motorIndex index of the motor
  107510. */
  107511. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  107512. /**
  107513. * Sets the motors limit
  107514. * @param joint joint to set limit on
  107515. * @param upperLimit upper limit
  107516. * @param lowerLimit lower limit
  107517. */
  107518. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  107519. /**
  107520. * Syncs the position and rotation of a mesh with the impostor
  107521. * @param mesh mesh to sync
  107522. * @param impostor impostor to update the mesh with
  107523. */
  107524. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  107525. /**
  107526. * Gets the radius of the impostor
  107527. * @param impostor impostor to get radius from
  107528. * @returns the radius
  107529. */
  107530. getRadius(impostor: PhysicsImpostor): number;
  107531. /**
  107532. * Gets the box size of the impostor
  107533. * @param impostor impostor to get box size from
  107534. * @param result the resulting box size
  107535. */
  107536. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  107537. /**
  107538. * Disposes of the impostor
  107539. */
  107540. dispose(): void;
  107541. }
  107542. }
  107543. declare module BABYLON {
  107544. /** @hidden */
  107545. export var blackAndWhitePixelShader: {
  107546. name: string;
  107547. shader: string;
  107548. };
  107549. }
  107550. declare module BABYLON {
  107551. /**
  107552. * Post process used to render in black and white
  107553. */
  107554. export class BlackAndWhitePostProcess extends PostProcess {
  107555. /**
  107556. * Linear about to convert he result to black and white (default: 1)
  107557. */
  107558. degree: number;
  107559. /**
  107560. * Creates a black and white post process
  107561. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  107562. * @param name The name of the effect.
  107563. * @param options The required width/height ratio to downsize to before computing the render pass.
  107564. * @param camera The camera to apply the render pass to.
  107565. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  107566. * @param engine The engine which the post process will be applied. (default: current engine)
  107567. * @param reusable If the post process can be reused on the same frame. (default: false)
  107568. */
  107569. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  107570. }
  107571. }
  107572. declare module BABYLON {
  107573. /**
  107574. * This represents a set of one or more post processes in Babylon.
  107575. * A post process can be used to apply a shader to a texture after it is rendered.
  107576. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  107577. */
  107578. export class PostProcessRenderEffect {
  107579. private _postProcesses;
  107580. private _getPostProcesses;
  107581. private _singleInstance;
  107582. private _cameras;
  107583. private _indicesForCamera;
  107584. /**
  107585. * Name of the effect
  107586. * @hidden
  107587. */
  107588. _name: string;
  107589. /**
  107590. * Instantiates a post process render effect.
  107591. * A post process can be used to apply a shader to a texture after it is rendered.
  107592. * @param engine The engine the effect is tied to
  107593. * @param name The name of the effect
  107594. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  107595. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  107596. */
  107597. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  107598. /**
  107599. * Checks if all the post processes in the effect are supported.
  107600. */
  107601. readonly isSupported: boolean;
  107602. /**
  107603. * Updates the current state of the effect
  107604. * @hidden
  107605. */
  107606. _update(): void;
  107607. /**
  107608. * Attaches the effect on cameras
  107609. * @param cameras The camera to attach to.
  107610. * @hidden
  107611. */
  107612. _attachCameras(cameras: Camera): void;
  107613. /**
  107614. * Attaches the effect on cameras
  107615. * @param cameras The camera to attach to.
  107616. * @hidden
  107617. */
  107618. _attachCameras(cameras: Camera[]): void;
  107619. /**
  107620. * Detatches the effect on cameras
  107621. * @param cameras The camera to detatch from.
  107622. * @hidden
  107623. */
  107624. _detachCameras(cameras: Camera): void;
  107625. /**
  107626. * Detatches the effect on cameras
  107627. * @param cameras The camera to detatch from.
  107628. * @hidden
  107629. */
  107630. _detachCameras(cameras: Camera[]): void;
  107631. /**
  107632. * Enables the effect on given cameras
  107633. * @param cameras The camera to enable.
  107634. * @hidden
  107635. */
  107636. _enable(cameras: Camera): void;
  107637. /**
  107638. * Enables the effect on given cameras
  107639. * @param cameras The camera to enable.
  107640. * @hidden
  107641. */
  107642. _enable(cameras: Nullable<Camera[]>): void;
  107643. /**
  107644. * Disables the effect on the given cameras
  107645. * @param cameras The camera to disable.
  107646. * @hidden
  107647. */
  107648. _disable(cameras: Camera): void;
  107649. /**
  107650. * Disables the effect on the given cameras
  107651. * @param cameras The camera to disable.
  107652. * @hidden
  107653. */
  107654. _disable(cameras: Nullable<Camera[]>): void;
  107655. /**
  107656. * Gets a list of the post processes contained in the effect.
  107657. * @param camera The camera to get the post processes on.
  107658. * @returns The list of the post processes in the effect.
  107659. */
  107660. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  107661. }
  107662. }
  107663. declare module BABYLON {
  107664. /** @hidden */
  107665. export var extractHighlightsPixelShader: {
  107666. name: string;
  107667. shader: string;
  107668. };
  107669. }
  107670. declare module BABYLON {
  107671. /**
  107672. * 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.
  107673. */
  107674. export class ExtractHighlightsPostProcess extends PostProcess {
  107675. /**
  107676. * The luminance threshold, pixels below this value will be set to black.
  107677. */
  107678. threshold: number;
  107679. /** @hidden */
  107680. _exposure: number;
  107681. /**
  107682. * Post process which has the input texture to be used when performing highlight extraction
  107683. * @hidden
  107684. */
  107685. _inputPostProcess: Nullable<PostProcess>;
  107686. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  107687. }
  107688. }
  107689. declare module BABYLON {
  107690. /** @hidden */
  107691. export var bloomMergePixelShader: {
  107692. name: string;
  107693. shader: string;
  107694. };
  107695. }
  107696. declare module BABYLON {
  107697. /**
  107698. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  107699. */
  107700. export class BloomMergePostProcess extends PostProcess {
  107701. /** Weight of the bloom to be added to the original input. */
  107702. weight: number;
  107703. /**
  107704. * Creates a new instance of @see BloomMergePostProcess
  107705. * @param name The name of the effect.
  107706. * @param originalFromInput Post process which's input will be used for the merge.
  107707. * @param blurred Blurred highlights post process which's output will be used.
  107708. * @param weight Weight of the bloom to be added to the original input.
  107709. * @param options The required width/height ratio to downsize to before computing the render pass.
  107710. * @param camera The camera to apply the render pass to.
  107711. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  107712. * @param engine The engine which the post process will be applied. (default: current engine)
  107713. * @param reusable If the post process can be reused on the same frame. (default: false)
  107714. * @param textureType Type of textures used when performing the post process. (default: 0)
  107715. * @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)
  107716. */
  107717. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  107718. /** Weight of the bloom to be added to the original input. */
  107719. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  107720. }
  107721. }
  107722. declare module BABYLON {
  107723. /**
  107724. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  107725. */
  107726. export class BloomEffect extends PostProcessRenderEffect {
  107727. private bloomScale;
  107728. /**
  107729. * @hidden Internal
  107730. */
  107731. _effects: Array<PostProcess>;
  107732. /**
  107733. * @hidden Internal
  107734. */
  107735. _downscale: ExtractHighlightsPostProcess;
  107736. private _blurX;
  107737. private _blurY;
  107738. private _merge;
  107739. /**
  107740. * The luminance threshold to find bright areas of the image to bloom.
  107741. */
  107742. threshold: number;
  107743. /**
  107744. * The strength of the bloom.
  107745. */
  107746. weight: number;
  107747. /**
  107748. * Specifies the size of the bloom blur kernel, relative to the final output size
  107749. */
  107750. kernel: number;
  107751. /**
  107752. * Creates a new instance of @see BloomEffect
  107753. * @param scene The scene the effect belongs to.
  107754. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  107755. * @param bloomKernel The size of the kernel to be used when applying the blur.
  107756. * @param bloomWeight The the strength of bloom.
  107757. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  107758. * @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)
  107759. */
  107760. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  107761. /**
  107762. * Disposes each of the internal effects for a given camera.
  107763. * @param camera The camera to dispose the effect on.
  107764. */
  107765. disposeEffects(camera: Camera): void;
  107766. /**
  107767. * @hidden Internal
  107768. */
  107769. _updateEffects(): void;
  107770. /**
  107771. * Internal
  107772. * @returns if all the contained post processes are ready.
  107773. * @hidden
  107774. */
  107775. _isReady(): boolean;
  107776. }
  107777. }
  107778. declare module BABYLON {
  107779. /** @hidden */
  107780. export var chromaticAberrationPixelShader: {
  107781. name: string;
  107782. shader: string;
  107783. };
  107784. }
  107785. declare module BABYLON {
  107786. /**
  107787. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  107788. */
  107789. export class ChromaticAberrationPostProcess extends PostProcess {
  107790. /**
  107791. * The amount of seperation of rgb channels (default: 30)
  107792. */
  107793. aberrationAmount: number;
  107794. /**
  107795. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  107796. */
  107797. radialIntensity: number;
  107798. /**
  107799. * 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))
  107800. */
  107801. direction: Vector2;
  107802. /**
  107803. * 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))
  107804. */
  107805. centerPosition: Vector2;
  107806. /**
  107807. * Creates a new instance ChromaticAberrationPostProcess
  107808. * @param name The name of the effect.
  107809. * @param screenWidth The width of the screen to apply the effect on.
  107810. * @param screenHeight The height of the screen to apply the effect on.
  107811. * @param options The required width/height ratio to downsize to before computing the render pass.
  107812. * @param camera The camera to apply the render pass to.
  107813. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  107814. * @param engine The engine which the post process will be applied. (default: current engine)
  107815. * @param reusable If the post process can be reused on the same frame. (default: false)
  107816. * @param textureType Type of textures used when performing the post process. (default: 0)
  107817. * @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)
  107818. */
  107819. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  107820. }
  107821. }
  107822. declare module BABYLON {
  107823. /** @hidden */
  107824. export var circleOfConfusionPixelShader: {
  107825. name: string;
  107826. shader: string;
  107827. };
  107828. }
  107829. declare module BABYLON {
  107830. /**
  107831. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  107832. */
  107833. export class CircleOfConfusionPostProcess extends PostProcess {
  107834. /**
  107835. * 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.
  107836. */
  107837. lensSize: number;
  107838. /**
  107839. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  107840. */
  107841. fStop: number;
  107842. /**
  107843. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  107844. */
  107845. focusDistance: number;
  107846. /**
  107847. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  107848. */
  107849. focalLength: number;
  107850. private _depthTexture;
  107851. /**
  107852. * Creates a new instance CircleOfConfusionPostProcess
  107853. * @param name The name of the effect.
  107854. * @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.
  107855. * @param options The required width/height ratio to downsize to before computing the render pass.
  107856. * @param camera The camera to apply the render pass to.
  107857. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  107858. * @param engine The engine which the post process will be applied. (default: current engine)
  107859. * @param reusable If the post process can be reused on the same frame. (default: false)
  107860. * @param textureType Type of textures used when performing the post process. (default: 0)
  107861. * @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)
  107862. */
  107863. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  107864. /**
  107865. * 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.
  107866. */
  107867. depthTexture: RenderTargetTexture;
  107868. }
  107869. }
  107870. declare module BABYLON {
  107871. /** @hidden */
  107872. export var colorCorrectionPixelShader: {
  107873. name: string;
  107874. shader: string;
  107875. };
  107876. }
  107877. declare module BABYLON {
  107878. /**
  107879. *
  107880. * This post-process allows the modification of rendered colors by using
  107881. * a 'look-up table' (LUT). This effect is also called Color Grading.
  107882. *
  107883. * The object needs to be provided an url to a texture containing the color
  107884. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  107885. * Use an image editing software to tweak the LUT to match your needs.
  107886. *
  107887. * For an example of a color LUT, see here:
  107888. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  107889. * For explanations on color grading, see here:
  107890. * @see http://udn.epicgames.com/Three/ColorGrading.html
  107891. *
  107892. */
  107893. export class ColorCorrectionPostProcess extends PostProcess {
  107894. private _colorTableTexture;
  107895. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  107896. }
  107897. }
  107898. declare module BABYLON {
  107899. /** @hidden */
  107900. export var convolutionPixelShader: {
  107901. name: string;
  107902. shader: string;
  107903. };
  107904. }
  107905. declare module BABYLON {
  107906. /**
  107907. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  107908. * input texture to perform effects such as edge detection or sharpening
  107909. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  107910. */
  107911. export class ConvolutionPostProcess extends PostProcess {
  107912. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  107913. kernel: number[];
  107914. /**
  107915. * Creates a new instance ConvolutionPostProcess
  107916. * @param name The name of the effect.
  107917. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  107918. * @param options The required width/height ratio to downsize to before computing the render pass.
  107919. * @param camera The camera to apply the render pass to.
  107920. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  107921. * @param engine The engine which the post process will be applied. (default: current engine)
  107922. * @param reusable If the post process can be reused on the same frame. (default: false)
  107923. * @param textureType Type of textures used when performing the post process. (default: 0)
  107924. */
  107925. constructor(name: string,
  107926. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  107927. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  107928. /**
  107929. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  107930. */
  107931. static EdgeDetect0Kernel: number[];
  107932. /**
  107933. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  107934. */
  107935. static EdgeDetect1Kernel: number[];
  107936. /**
  107937. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  107938. */
  107939. static EdgeDetect2Kernel: number[];
  107940. /**
  107941. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  107942. */
  107943. static SharpenKernel: number[];
  107944. /**
  107945. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  107946. */
  107947. static EmbossKernel: number[];
  107948. /**
  107949. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  107950. */
  107951. static GaussianKernel: number[];
  107952. }
  107953. }
  107954. declare module BABYLON {
  107955. /**
  107956. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  107957. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  107958. * based on samples that have a large difference in distance than the center pixel.
  107959. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  107960. */
  107961. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  107962. direction: Vector2;
  107963. /**
  107964. * Creates a new instance CircleOfConfusionPostProcess
  107965. * @param name The name of the effect.
  107966. * @param scene The scene the effect belongs to.
  107967. * @param direction The direction the blur should be applied.
  107968. * @param kernel The size of the kernel used to blur.
  107969. * @param options The required width/height ratio to downsize to before computing the render pass.
  107970. * @param camera The camera to apply the render pass to.
  107971. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  107972. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  107973. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  107974. * @param engine The engine which the post process will be applied. (default: current engine)
  107975. * @param reusable If the post process can be reused on the same frame. (default: false)
  107976. * @param textureType Type of textures used when performing the post process. (default: 0)
  107977. * @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)
  107978. */
  107979. 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);
  107980. }
  107981. }
  107982. declare module BABYLON {
  107983. /** @hidden */
  107984. export var depthOfFieldMergePixelShader: {
  107985. name: string;
  107986. shader: string;
  107987. };
  107988. }
  107989. declare module BABYLON {
  107990. /**
  107991. * Options to be set when merging outputs from the default pipeline.
  107992. */
  107993. export class DepthOfFieldMergePostProcessOptions {
  107994. /**
  107995. * The original image to merge on top of
  107996. */
  107997. originalFromInput: PostProcess;
  107998. /**
  107999. * Parameters to perform the merge of the depth of field effect
  108000. */
  108001. depthOfField?: {
  108002. circleOfConfusion: PostProcess;
  108003. blurSteps: Array<PostProcess>;
  108004. };
  108005. /**
  108006. * Parameters to perform the merge of bloom effect
  108007. */
  108008. bloom?: {
  108009. blurred: PostProcess;
  108010. weight: number;
  108011. };
  108012. }
  108013. /**
  108014. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  108015. */
  108016. export class DepthOfFieldMergePostProcess extends PostProcess {
  108017. private blurSteps;
  108018. /**
  108019. * Creates a new instance of DepthOfFieldMergePostProcess
  108020. * @param name The name of the effect.
  108021. * @param originalFromInput Post process which's input will be used for the merge.
  108022. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  108023. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  108024. * @param options The required width/height ratio to downsize to before computing the render pass.
  108025. * @param camera The camera to apply the render pass to.
  108026. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  108027. * @param engine The engine which the post process will be applied. (default: current engine)
  108028. * @param reusable If the post process can be reused on the same frame. (default: false)
  108029. * @param textureType Type of textures used when performing the post process. (default: 0)
  108030. * @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)
  108031. */
  108032. 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);
  108033. /**
  108034. * Updates the effect with the current post process compile time values and recompiles the shader.
  108035. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  108036. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  108037. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  108038. * @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
  108039. * @param onCompiled Called when the shader has been compiled.
  108040. * @param onError Called if there is an error when compiling a shader.
  108041. */
  108042. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  108043. }
  108044. }
  108045. declare module BABYLON {
  108046. /**
  108047. * Specifies the level of max blur that should be applied when using the depth of field effect
  108048. */
  108049. export enum DepthOfFieldEffectBlurLevel {
  108050. /**
  108051. * Subtle blur
  108052. */
  108053. Low = 0,
  108054. /**
  108055. * Medium blur
  108056. */
  108057. Medium = 1,
  108058. /**
  108059. * Large blur
  108060. */
  108061. High = 2
  108062. }
  108063. /**
  108064. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  108065. */
  108066. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  108067. private _circleOfConfusion;
  108068. /**
  108069. * @hidden Internal, blurs from high to low
  108070. */
  108071. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  108072. private _depthOfFieldBlurY;
  108073. private _dofMerge;
  108074. /**
  108075. * @hidden Internal post processes in depth of field effect
  108076. */
  108077. _effects: Array<PostProcess>;
  108078. /**
  108079. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  108080. */
  108081. focalLength: number;
  108082. /**
  108083. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  108084. */
  108085. fStop: number;
  108086. /**
  108087. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  108088. */
  108089. focusDistance: number;
  108090. /**
  108091. * 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.
  108092. */
  108093. lensSize: number;
  108094. /**
  108095. * Creates a new instance DepthOfFieldEffect
  108096. * @param scene The scene the effect belongs to.
  108097. * @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.
  108098. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  108099. * @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)
  108100. */
  108101. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  108102. /**
  108103. * 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.
  108104. */
  108105. depthTexture: RenderTargetTexture;
  108106. /**
  108107. * Disposes each of the internal effects for a given camera.
  108108. * @param camera The camera to dispose the effect on.
  108109. */
  108110. disposeEffects(camera: Camera): void;
  108111. /**
  108112. * @hidden Internal
  108113. */
  108114. _updateEffects(): void;
  108115. /**
  108116. * Internal
  108117. * @returns if all the contained post processes are ready.
  108118. * @hidden
  108119. */
  108120. _isReady(): boolean;
  108121. }
  108122. }
  108123. declare module BABYLON {
  108124. /** @hidden */
  108125. export var displayPassPixelShader: {
  108126. name: string;
  108127. shader: string;
  108128. };
  108129. }
  108130. declare module BABYLON {
  108131. /**
  108132. * DisplayPassPostProcess which produces an output the same as it's input
  108133. */
  108134. export class DisplayPassPostProcess extends PostProcess {
  108135. /**
  108136. * Creates the DisplayPassPostProcess
  108137. * @param name The name of the effect.
  108138. * @param options The required width/height ratio to downsize to before computing the render pass.
  108139. * @param camera The camera to apply the render pass to.
  108140. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  108141. * @param engine The engine which the post process will be applied. (default: current engine)
  108142. * @param reusable If the post process can be reused on the same frame. (default: false)
  108143. */
  108144. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  108145. }
  108146. }
  108147. declare module BABYLON {
  108148. /** @hidden */
  108149. export var filterPixelShader: {
  108150. name: string;
  108151. shader: string;
  108152. };
  108153. }
  108154. declare module BABYLON {
  108155. /**
  108156. * Applies a kernel filter to the image
  108157. */
  108158. export class FilterPostProcess extends PostProcess {
  108159. /** The matrix to be applied to the image */
  108160. kernelMatrix: Matrix;
  108161. /**
  108162. *
  108163. * @param name The name of the effect.
  108164. * @param kernelMatrix The matrix to be applied to the image
  108165. * @param options The required width/height ratio to downsize to before computing the render pass.
  108166. * @param camera The camera to apply the render pass to.
  108167. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  108168. * @param engine The engine which the post process will be applied. (default: current engine)
  108169. * @param reusable If the post process can be reused on the same frame. (default: false)
  108170. */
  108171. constructor(name: string,
  108172. /** The matrix to be applied to the image */
  108173. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  108174. }
  108175. }
  108176. declare module BABYLON {
  108177. /** @hidden */
  108178. export var fxaaPixelShader: {
  108179. name: string;
  108180. shader: string;
  108181. };
  108182. }
  108183. declare module BABYLON {
  108184. /** @hidden */
  108185. export var fxaaVertexShader: {
  108186. name: string;
  108187. shader: string;
  108188. };
  108189. }
  108190. declare module BABYLON {
  108191. /**
  108192. * Fxaa post process
  108193. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  108194. */
  108195. export class FxaaPostProcess extends PostProcess {
  108196. /** @hidden */
  108197. texelWidth: number;
  108198. /** @hidden */
  108199. texelHeight: number;
  108200. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  108201. private _getDefines;
  108202. }
  108203. }
  108204. declare module BABYLON {
  108205. /** @hidden */
  108206. export var grainPixelShader: {
  108207. name: string;
  108208. shader: string;
  108209. };
  108210. }
  108211. declare module BABYLON {
  108212. /**
  108213. * The GrainPostProcess adds noise to the image at mid luminance levels
  108214. */
  108215. export class GrainPostProcess extends PostProcess {
  108216. /**
  108217. * The intensity of the grain added (default: 30)
  108218. */
  108219. intensity: number;
  108220. /**
  108221. * If the grain should be randomized on every frame
  108222. */
  108223. animated: boolean;
  108224. /**
  108225. * Creates a new instance of @see GrainPostProcess
  108226. * @param name The name of the effect.
  108227. * @param options The required width/height ratio to downsize to before computing the render pass.
  108228. * @param camera The camera to apply the render pass to.
  108229. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  108230. * @param engine The engine which the post process will be applied. (default: current engine)
  108231. * @param reusable If the post process can be reused on the same frame. (default: false)
  108232. * @param textureType Type of textures used when performing the post process. (default: 0)
  108233. * @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)
  108234. */
  108235. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  108236. }
  108237. }
  108238. declare module BABYLON {
  108239. /** @hidden */
  108240. export var highlightsPixelShader: {
  108241. name: string;
  108242. shader: string;
  108243. };
  108244. }
  108245. declare module BABYLON {
  108246. /**
  108247. * Extracts highlights from the image
  108248. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  108249. */
  108250. export class HighlightsPostProcess extends PostProcess {
  108251. /**
  108252. * Extracts highlights from the image
  108253. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  108254. * @param name The name of the effect.
  108255. * @param options The required width/height ratio to downsize to before computing the render pass.
  108256. * @param camera The camera to apply the render pass to.
  108257. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  108258. * @param engine The engine which the post process will be applied. (default: current engine)
  108259. * @param reusable If the post process can be reused on the same frame. (default: false)
  108260. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  108261. */
  108262. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  108263. }
  108264. }
  108265. declare module BABYLON {
  108266. /** @hidden */
  108267. export var mrtFragmentDeclaration: {
  108268. name: string;
  108269. shader: string;
  108270. };
  108271. }
  108272. declare module BABYLON {
  108273. /** @hidden */
  108274. export var geometryPixelShader: {
  108275. name: string;
  108276. shader: string;
  108277. };
  108278. }
  108279. declare module BABYLON {
  108280. /** @hidden */
  108281. export var geometryVertexShader: {
  108282. name: string;
  108283. shader: string;
  108284. };
  108285. }
  108286. declare module BABYLON {
  108287. /**
  108288. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  108289. */
  108290. export class GeometryBufferRenderer {
  108291. /**
  108292. * Constant used to retrieve the position texture index in the G-Buffer textures array
  108293. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  108294. */
  108295. static readonly POSITION_TEXTURE_TYPE: number;
  108296. /**
  108297. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  108298. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  108299. */
  108300. static readonly VELOCITY_TEXTURE_TYPE: number;
  108301. /**
  108302. * Dictionary used to store the previous transformation matrices of each rendered mesh
  108303. * in order to compute objects velocities when enableVelocity is set to "true"
  108304. * @hidden
  108305. */
  108306. _previousTransformationMatrices: {
  108307. [index: number]: Matrix;
  108308. };
  108309. private _scene;
  108310. private _multiRenderTarget;
  108311. private _ratio;
  108312. private _enablePosition;
  108313. private _enableVelocity;
  108314. private _positionIndex;
  108315. private _velocityIndex;
  108316. protected _effect: Effect;
  108317. protected _cachedDefines: string;
  108318. /**
  108319. * Set the render list (meshes to be rendered) used in the G buffer.
  108320. */
  108321. renderList: Mesh[];
  108322. /**
  108323. * Gets wether or not G buffer are supported by the running hardware.
  108324. * This requires draw buffer supports
  108325. */
  108326. readonly isSupported: boolean;
  108327. /**
  108328. * Returns the index of the given texture type in the G-Buffer textures array
  108329. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  108330. * @returns the index of the given texture type in the G-Buffer textures array
  108331. */
  108332. getTextureIndex(textureType: number): number;
  108333. /**
  108334. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  108335. */
  108336. /**
  108337. * Sets whether or not objects positions are enabled for the G buffer.
  108338. */
  108339. enablePosition: boolean;
  108340. /**
  108341. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  108342. */
  108343. /**
  108344. * Sets wether or not objects velocities are enabled for the G buffer.
  108345. */
  108346. enableVelocity: boolean;
  108347. /**
  108348. * Gets the scene associated with the buffer.
  108349. */
  108350. readonly scene: Scene;
  108351. /**
  108352. * Gets the ratio used by the buffer during its creation.
  108353. * How big is the buffer related to the main canvas.
  108354. */
  108355. readonly ratio: number;
  108356. /** @hidden */
  108357. static _SceneComponentInitialization: (scene: Scene) => void;
  108358. /**
  108359. * Creates a new G Buffer for the scene
  108360. * @param scene The scene the buffer belongs to
  108361. * @param ratio How big is the buffer related to the main canvas.
  108362. */
  108363. constructor(scene: Scene, ratio?: number);
  108364. /**
  108365. * Checks wether everything is ready to render a submesh to the G buffer.
  108366. * @param subMesh the submesh to check readiness for
  108367. * @param useInstances is the mesh drawn using instance or not
  108368. * @returns true if ready otherwise false
  108369. */
  108370. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  108371. /**
  108372. * Gets the current underlying G Buffer.
  108373. * @returns the buffer
  108374. */
  108375. getGBuffer(): MultiRenderTarget;
  108376. /**
  108377. * Gets the number of samples used to render the buffer (anti aliasing).
  108378. */
  108379. /**
  108380. * Sets the number of samples used to render the buffer (anti aliasing).
  108381. */
  108382. samples: number;
  108383. /**
  108384. * Disposes the renderer and frees up associated resources.
  108385. */
  108386. dispose(): void;
  108387. protected _createRenderTargets(): void;
  108388. }
  108389. }
  108390. declare module BABYLON {
  108391. /** @hidden */
  108392. export var motionBlurPixelShader: {
  108393. name: string;
  108394. shader: string;
  108395. };
  108396. }
  108397. declare module BABYLON {
  108398. /**
  108399. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  108400. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  108401. * As an example, all you have to do is to create the post-process:
  108402. * var mb = new BABYLON.MotionBlurPostProcess(
  108403. * 'mb', // The name of the effect.
  108404. * scene, // The scene containing the objects to blur according to their velocity.
  108405. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  108406. * camera // The camera to apply the render pass to.
  108407. * );
  108408. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  108409. */
  108410. export class MotionBlurPostProcess extends PostProcess {
  108411. /**
  108412. * Defines how much the image is blurred by the movement. Default value is equal to 1
  108413. */
  108414. motionStrength: number;
  108415. /**
  108416. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  108417. */
  108418. /**
  108419. * Sets the number of iterations to be used for motion blur quality
  108420. */
  108421. motionBlurSamples: number;
  108422. private _motionBlurSamples;
  108423. private _geometryBufferRenderer;
  108424. /**
  108425. * Creates a new instance MotionBlurPostProcess
  108426. * @param name The name of the effect.
  108427. * @param scene The scene containing the objects to blur according to their velocity.
  108428. * @param options The required width/height ratio to downsize to before computing the render pass.
  108429. * @param camera The camera to apply the render pass to.
  108430. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  108431. * @param engine The engine which the post process will be applied. (default: current engine)
  108432. * @param reusable If the post process can be reused on the same frame. (default: false)
  108433. * @param textureType Type of textures used when performing the post process. (default: 0)
  108434. * @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)
  108435. */
  108436. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  108437. /**
  108438. * Disposes the post process.
  108439. * @param camera The camera to dispose the post process on.
  108440. */
  108441. dispose(camera?: Camera): void;
  108442. }
  108443. }
  108444. declare module BABYLON {
  108445. /** @hidden */
  108446. export var refractionPixelShader: {
  108447. name: string;
  108448. shader: string;
  108449. };
  108450. }
  108451. declare module BABYLON {
  108452. /**
  108453. * Post process which applies a refractin texture
  108454. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  108455. */
  108456. export class RefractionPostProcess extends PostProcess {
  108457. /** the base color of the refraction (used to taint the rendering) */
  108458. color: Color3;
  108459. /** simulated refraction depth */
  108460. depth: number;
  108461. /** the coefficient of the base color (0 to remove base color tainting) */
  108462. colorLevel: number;
  108463. private _refTexture;
  108464. private _ownRefractionTexture;
  108465. /**
  108466. * Gets or sets the refraction texture
  108467. * Please note that you are responsible for disposing the texture if you set it manually
  108468. */
  108469. refractionTexture: Texture;
  108470. /**
  108471. * Initializes the RefractionPostProcess
  108472. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  108473. * @param name The name of the effect.
  108474. * @param refractionTextureUrl Url of the refraction texture to use
  108475. * @param color the base color of the refraction (used to taint the rendering)
  108476. * @param depth simulated refraction depth
  108477. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  108478. * @param camera The camera to apply the render pass to.
  108479. * @param options The required width/height ratio to downsize to before computing the render pass.
  108480. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  108481. * @param engine The engine which the post process will be applied. (default: current engine)
  108482. * @param reusable If the post process can be reused on the same frame. (default: false)
  108483. */
  108484. constructor(name: string, refractionTextureUrl: string,
  108485. /** the base color of the refraction (used to taint the rendering) */
  108486. color: Color3,
  108487. /** simulated refraction depth */
  108488. depth: number,
  108489. /** the coefficient of the base color (0 to remove base color tainting) */
  108490. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  108491. /**
  108492. * Disposes of the post process
  108493. * @param camera Camera to dispose post process on
  108494. */
  108495. dispose(camera: Camera): void;
  108496. }
  108497. }
  108498. declare module BABYLON {
  108499. /** @hidden */
  108500. export var sharpenPixelShader: {
  108501. name: string;
  108502. shader: string;
  108503. };
  108504. }
  108505. declare module BABYLON {
  108506. /**
  108507. * The SharpenPostProcess applies a sharpen kernel to every pixel
  108508. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  108509. */
  108510. export class SharpenPostProcess extends PostProcess {
  108511. /**
  108512. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  108513. */
  108514. colorAmount: number;
  108515. /**
  108516. * How much sharpness should be applied (default: 0.3)
  108517. */
  108518. edgeAmount: number;
  108519. /**
  108520. * Creates a new instance ConvolutionPostProcess
  108521. * @param name The name of the effect.
  108522. * @param options The required width/height ratio to downsize to before computing the render pass.
  108523. * @param camera The camera to apply the render pass to.
  108524. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  108525. * @param engine The engine which the post process will be applied. (default: current engine)
  108526. * @param reusable If the post process can be reused on the same frame. (default: false)
  108527. * @param textureType Type of textures used when performing the post process. (default: 0)
  108528. * @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)
  108529. */
  108530. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  108531. }
  108532. }
  108533. declare module BABYLON {
  108534. /**
  108535. * PostProcessRenderPipeline
  108536. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  108537. */
  108538. export class PostProcessRenderPipeline {
  108539. private engine;
  108540. private _renderEffects;
  108541. private _renderEffectsForIsolatedPass;
  108542. /**
  108543. * @hidden
  108544. */
  108545. protected _cameras: Camera[];
  108546. /** @hidden */
  108547. _name: string;
  108548. /**
  108549. * Gets pipeline name
  108550. */
  108551. readonly name: string;
  108552. /**
  108553. * Initializes a PostProcessRenderPipeline
  108554. * @param engine engine to add the pipeline to
  108555. * @param name name of the pipeline
  108556. */
  108557. constructor(engine: Engine, name: string);
  108558. /**
  108559. * Gets the class name
  108560. * @returns "PostProcessRenderPipeline"
  108561. */
  108562. getClassName(): string;
  108563. /**
  108564. * If all the render effects in the pipeline are supported
  108565. */
  108566. readonly isSupported: boolean;
  108567. /**
  108568. * Adds an effect to the pipeline
  108569. * @param renderEffect the effect to add
  108570. */
  108571. addEffect(renderEffect: PostProcessRenderEffect): void;
  108572. /** @hidden */
  108573. _rebuild(): void;
  108574. /** @hidden */
  108575. _enableEffect(renderEffectName: string, cameras: Camera): void;
  108576. /** @hidden */
  108577. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  108578. /** @hidden */
  108579. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  108580. /** @hidden */
  108581. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  108582. /** @hidden */
  108583. _attachCameras(cameras: Camera, unique: boolean): void;
  108584. /** @hidden */
  108585. _attachCameras(cameras: Camera[], unique: boolean): void;
  108586. /** @hidden */
  108587. _detachCameras(cameras: Camera): void;
  108588. /** @hidden */
  108589. _detachCameras(cameras: Nullable<Camera[]>): void;
  108590. /** @hidden */
  108591. _update(): void;
  108592. /** @hidden */
  108593. _reset(): void;
  108594. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  108595. /**
  108596. * Disposes of the pipeline
  108597. */
  108598. dispose(): void;
  108599. }
  108600. }
  108601. declare module BABYLON {
  108602. /**
  108603. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  108604. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  108605. */
  108606. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  108607. private _scene;
  108608. private _camerasToBeAttached;
  108609. /**
  108610. * ID of the sharpen post process,
  108611. */
  108612. private readonly SharpenPostProcessId;
  108613. /**
  108614. * @ignore
  108615. * ID of the image processing post process;
  108616. */
  108617. readonly ImageProcessingPostProcessId: string;
  108618. /**
  108619. * @ignore
  108620. * ID of the Fast Approximate Anti-Aliasing post process;
  108621. */
  108622. readonly FxaaPostProcessId: string;
  108623. /**
  108624. * ID of the chromatic aberration post process,
  108625. */
  108626. private readonly ChromaticAberrationPostProcessId;
  108627. /**
  108628. * ID of the grain post process
  108629. */
  108630. private readonly GrainPostProcessId;
  108631. /**
  108632. * Sharpen post process which will apply a sharpen convolution to enhance edges
  108633. */
  108634. sharpen: SharpenPostProcess;
  108635. private _sharpenEffect;
  108636. private bloom;
  108637. /**
  108638. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  108639. */
  108640. depthOfField: DepthOfFieldEffect;
  108641. /**
  108642. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  108643. */
  108644. fxaa: FxaaPostProcess;
  108645. /**
  108646. * Image post processing pass used to perform operations such as tone mapping or color grading.
  108647. */
  108648. imageProcessing: ImageProcessingPostProcess;
  108649. /**
  108650. * Chromatic aberration post process which will shift rgb colors in the image
  108651. */
  108652. chromaticAberration: ChromaticAberrationPostProcess;
  108653. private _chromaticAberrationEffect;
  108654. /**
  108655. * Grain post process which add noise to the image
  108656. */
  108657. grain: GrainPostProcess;
  108658. private _grainEffect;
  108659. /**
  108660. * Glow post process which adds a glow to emissive areas of the image
  108661. */
  108662. private _glowLayer;
  108663. /**
  108664. * Animations which can be used to tweak settings over a period of time
  108665. */
  108666. animations: Animation[];
  108667. private _imageProcessingConfigurationObserver;
  108668. private _sharpenEnabled;
  108669. private _bloomEnabled;
  108670. private _depthOfFieldEnabled;
  108671. private _depthOfFieldBlurLevel;
  108672. private _fxaaEnabled;
  108673. private _imageProcessingEnabled;
  108674. private _defaultPipelineTextureType;
  108675. private _bloomScale;
  108676. private _chromaticAberrationEnabled;
  108677. private _grainEnabled;
  108678. private _buildAllowed;
  108679. /**
  108680. * Gets active scene
  108681. */
  108682. readonly scene: Scene;
  108683. /**
  108684. * Enable or disable the sharpen process from the pipeline
  108685. */
  108686. sharpenEnabled: boolean;
  108687. private _resizeObserver;
  108688. private _hardwareScaleLevel;
  108689. private _bloomKernel;
  108690. /**
  108691. * Specifies the size of the bloom blur kernel, relative to the final output size
  108692. */
  108693. bloomKernel: number;
  108694. /**
  108695. * Specifies the weight of the bloom in the final rendering
  108696. */
  108697. private _bloomWeight;
  108698. /**
  108699. * Specifies the luma threshold for the area that will be blurred by the bloom
  108700. */
  108701. private _bloomThreshold;
  108702. private _hdr;
  108703. /**
  108704. * The strength of the bloom.
  108705. */
  108706. bloomWeight: number;
  108707. /**
  108708. * The strength of the bloom.
  108709. */
  108710. bloomThreshold: number;
  108711. /**
  108712. * The scale of the bloom, lower value will provide better performance.
  108713. */
  108714. bloomScale: number;
  108715. /**
  108716. * Enable or disable the bloom from the pipeline
  108717. */
  108718. bloomEnabled: boolean;
  108719. private _rebuildBloom;
  108720. /**
  108721. * If the depth of field is enabled.
  108722. */
  108723. depthOfFieldEnabled: boolean;
  108724. /**
  108725. * Blur level of the depth of field effect. (Higher blur will effect performance)
  108726. */
  108727. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  108728. /**
  108729. * If the anti aliasing is enabled.
  108730. */
  108731. fxaaEnabled: boolean;
  108732. private _samples;
  108733. /**
  108734. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  108735. */
  108736. samples: number;
  108737. /**
  108738. * If image processing is enabled.
  108739. */
  108740. imageProcessingEnabled: boolean;
  108741. /**
  108742. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  108743. */
  108744. glowLayerEnabled: boolean;
  108745. /**
  108746. * Enable or disable the chromaticAberration process from the pipeline
  108747. */
  108748. chromaticAberrationEnabled: boolean;
  108749. /**
  108750. * Enable or disable the grain process from the pipeline
  108751. */
  108752. grainEnabled: boolean;
  108753. /**
  108754. * @constructor
  108755. * @param name - The rendering pipeline name (default: "")
  108756. * @param hdr - If high dynamic range textures should be used (default: true)
  108757. * @param scene - The scene linked to this pipeline (default: the last created scene)
  108758. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  108759. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  108760. */
  108761. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  108762. /**
  108763. * Get the class name
  108764. * @returns "DefaultRenderingPipeline"
  108765. */
  108766. getClassName(): string;
  108767. /**
  108768. * Force the compilation of the entire pipeline.
  108769. */
  108770. prepare(): void;
  108771. private _hasCleared;
  108772. private _prevPostProcess;
  108773. private _prevPrevPostProcess;
  108774. private _setAutoClearAndTextureSharing;
  108775. private _depthOfFieldSceneObserver;
  108776. private _buildPipeline;
  108777. private _disposePostProcesses;
  108778. /**
  108779. * Adds a camera to the pipeline
  108780. * @param camera the camera to be added
  108781. */
  108782. addCamera(camera: Camera): void;
  108783. /**
  108784. * Removes a camera from the pipeline
  108785. * @param camera the camera to remove
  108786. */
  108787. removeCamera(camera: Camera): void;
  108788. /**
  108789. * Dispose of the pipeline and stop all post processes
  108790. */
  108791. dispose(): void;
  108792. /**
  108793. * Serialize the rendering pipeline (Used when exporting)
  108794. * @returns the serialized object
  108795. */
  108796. serialize(): any;
  108797. /**
  108798. * Parse the serialized pipeline
  108799. * @param source Source pipeline.
  108800. * @param scene The scene to load the pipeline to.
  108801. * @param rootUrl The URL of the serialized pipeline.
  108802. * @returns An instantiated pipeline from the serialized object.
  108803. */
  108804. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  108805. }
  108806. }
  108807. declare module BABYLON {
  108808. /** @hidden */
  108809. export var lensHighlightsPixelShader: {
  108810. name: string;
  108811. shader: string;
  108812. };
  108813. }
  108814. declare module BABYLON {
  108815. /** @hidden */
  108816. export var depthOfFieldPixelShader: {
  108817. name: string;
  108818. shader: string;
  108819. };
  108820. }
  108821. declare module BABYLON {
  108822. /**
  108823. * BABYLON.JS Chromatic Aberration GLSL Shader
  108824. * Author: Olivier Guyot
  108825. * Separates very slightly R, G and B colors on the edges of the screen
  108826. * Inspired by Francois Tarlier & Martins Upitis
  108827. */
  108828. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  108829. /**
  108830. * @ignore
  108831. * The chromatic aberration PostProcess id in the pipeline
  108832. */
  108833. LensChromaticAberrationEffect: string;
  108834. /**
  108835. * @ignore
  108836. * The highlights enhancing PostProcess id in the pipeline
  108837. */
  108838. HighlightsEnhancingEffect: string;
  108839. /**
  108840. * @ignore
  108841. * The depth-of-field PostProcess id in the pipeline
  108842. */
  108843. LensDepthOfFieldEffect: string;
  108844. private _scene;
  108845. private _depthTexture;
  108846. private _grainTexture;
  108847. private _chromaticAberrationPostProcess;
  108848. private _highlightsPostProcess;
  108849. private _depthOfFieldPostProcess;
  108850. private _edgeBlur;
  108851. private _grainAmount;
  108852. private _chromaticAberration;
  108853. private _distortion;
  108854. private _highlightsGain;
  108855. private _highlightsThreshold;
  108856. private _dofDistance;
  108857. private _dofAperture;
  108858. private _dofDarken;
  108859. private _dofPentagon;
  108860. private _blurNoise;
  108861. /**
  108862. * @constructor
  108863. *
  108864. * Effect parameters are as follow:
  108865. * {
  108866. * chromatic_aberration: number; // from 0 to x (1 for realism)
  108867. * edge_blur: number; // from 0 to x (1 for realism)
  108868. * distortion: number; // from 0 to x (1 for realism)
  108869. * grain_amount: number; // from 0 to 1
  108870. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  108871. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  108872. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  108873. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  108874. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  108875. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  108876. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  108877. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  108878. * }
  108879. * Note: if an effect parameter is unset, effect is disabled
  108880. *
  108881. * @param name The rendering pipeline name
  108882. * @param parameters - An object containing all parameters (see above)
  108883. * @param scene The scene linked to this pipeline
  108884. * @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)
  108885. * @param cameras The array of cameras that the rendering pipeline will be attached to
  108886. */
  108887. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  108888. /**
  108889. * Sets the amount of blur at the edges
  108890. * @param amount blur amount
  108891. */
  108892. setEdgeBlur(amount: number): void;
  108893. /**
  108894. * Sets edge blur to 0
  108895. */
  108896. disableEdgeBlur(): void;
  108897. /**
  108898. * Sets the amout of grain
  108899. * @param amount Amount of grain
  108900. */
  108901. setGrainAmount(amount: number): void;
  108902. /**
  108903. * Set grain amount to 0
  108904. */
  108905. disableGrain(): void;
  108906. /**
  108907. * Sets the chromatic aberration amount
  108908. * @param amount amount of chromatic aberration
  108909. */
  108910. setChromaticAberration(amount: number): void;
  108911. /**
  108912. * Sets chromatic aberration amount to 0
  108913. */
  108914. disableChromaticAberration(): void;
  108915. /**
  108916. * Sets the EdgeDistortion amount
  108917. * @param amount amount of EdgeDistortion
  108918. */
  108919. setEdgeDistortion(amount: number): void;
  108920. /**
  108921. * Sets edge distortion to 0
  108922. */
  108923. disableEdgeDistortion(): void;
  108924. /**
  108925. * Sets the FocusDistance amount
  108926. * @param amount amount of FocusDistance
  108927. */
  108928. setFocusDistance(amount: number): void;
  108929. /**
  108930. * Disables depth of field
  108931. */
  108932. disableDepthOfField(): void;
  108933. /**
  108934. * Sets the Aperture amount
  108935. * @param amount amount of Aperture
  108936. */
  108937. setAperture(amount: number): void;
  108938. /**
  108939. * Sets the DarkenOutOfFocus amount
  108940. * @param amount amount of DarkenOutOfFocus
  108941. */
  108942. setDarkenOutOfFocus(amount: number): void;
  108943. /**
  108944. * Creates a pentagon bokeh effect
  108945. */
  108946. enablePentagonBokeh(): void;
  108947. /**
  108948. * Disables the pentagon bokeh effect
  108949. */
  108950. disablePentagonBokeh(): void;
  108951. /**
  108952. * Enables noise blur
  108953. */
  108954. enableNoiseBlur(): void;
  108955. /**
  108956. * Disables noise blur
  108957. */
  108958. disableNoiseBlur(): void;
  108959. /**
  108960. * Sets the HighlightsGain amount
  108961. * @param amount amount of HighlightsGain
  108962. */
  108963. setHighlightsGain(amount: number): void;
  108964. /**
  108965. * Sets the HighlightsThreshold amount
  108966. * @param amount amount of HighlightsThreshold
  108967. */
  108968. setHighlightsThreshold(amount: number): void;
  108969. /**
  108970. * Disables highlights
  108971. */
  108972. disableHighlights(): void;
  108973. /**
  108974. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  108975. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  108976. */
  108977. dispose(disableDepthRender?: boolean): void;
  108978. private _createChromaticAberrationPostProcess;
  108979. private _createHighlightsPostProcess;
  108980. private _createDepthOfFieldPostProcess;
  108981. private _createGrainTexture;
  108982. }
  108983. }
  108984. declare module BABYLON {
  108985. /** @hidden */
  108986. export var ssao2PixelShader: {
  108987. name: string;
  108988. shader: string;
  108989. };
  108990. }
  108991. declare module BABYLON {
  108992. /** @hidden */
  108993. export var ssaoCombinePixelShader: {
  108994. name: string;
  108995. shader: string;
  108996. };
  108997. }
  108998. declare module BABYLON {
  108999. /**
  109000. * Render pipeline to produce ssao effect
  109001. */
  109002. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  109003. /**
  109004. * @ignore
  109005. * The PassPostProcess id in the pipeline that contains the original scene color
  109006. */
  109007. SSAOOriginalSceneColorEffect: string;
  109008. /**
  109009. * @ignore
  109010. * The SSAO PostProcess id in the pipeline
  109011. */
  109012. SSAORenderEffect: string;
  109013. /**
  109014. * @ignore
  109015. * The horizontal blur PostProcess id in the pipeline
  109016. */
  109017. SSAOBlurHRenderEffect: string;
  109018. /**
  109019. * @ignore
  109020. * The vertical blur PostProcess id in the pipeline
  109021. */
  109022. SSAOBlurVRenderEffect: string;
  109023. /**
  109024. * @ignore
  109025. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  109026. */
  109027. SSAOCombineRenderEffect: string;
  109028. /**
  109029. * The output strength of the SSAO post-process. Default value is 1.0.
  109030. */
  109031. totalStrength: number;
  109032. /**
  109033. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  109034. */
  109035. maxZ: number;
  109036. /**
  109037. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  109038. */
  109039. minZAspect: number;
  109040. private _samples;
  109041. /**
  109042. * Number of samples used for the SSAO calculations. Default value is 8
  109043. */
  109044. samples: number;
  109045. private _textureSamples;
  109046. /**
  109047. * Number of samples to use for antialiasing
  109048. */
  109049. textureSamples: number;
  109050. /**
  109051. * Ratio object used for SSAO ratio and blur ratio
  109052. */
  109053. private _ratio;
  109054. /**
  109055. * Dynamically generated sphere sampler.
  109056. */
  109057. private _sampleSphere;
  109058. /**
  109059. * Blur filter offsets
  109060. */
  109061. private _samplerOffsets;
  109062. private _expensiveBlur;
  109063. /**
  109064. * If bilateral blur should be used
  109065. */
  109066. expensiveBlur: boolean;
  109067. /**
  109068. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  109069. */
  109070. radius: number;
  109071. /**
  109072. * The base color of the SSAO post-process
  109073. * The final result is "base + ssao" between [0, 1]
  109074. */
  109075. base: number;
  109076. /**
  109077. * Support test.
  109078. */
  109079. static readonly IsSupported: boolean;
  109080. private _scene;
  109081. private _depthTexture;
  109082. private _normalTexture;
  109083. private _randomTexture;
  109084. private _originalColorPostProcess;
  109085. private _ssaoPostProcess;
  109086. private _blurHPostProcess;
  109087. private _blurVPostProcess;
  109088. private _ssaoCombinePostProcess;
  109089. private _firstUpdate;
  109090. /**
  109091. * Gets active scene
  109092. */
  109093. readonly scene: Scene;
  109094. /**
  109095. * @constructor
  109096. * @param name The rendering pipeline name
  109097. * @param scene The scene linked to this pipeline
  109098. * @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 }
  109099. * @param cameras The array of cameras that the rendering pipeline will be attached to
  109100. */
  109101. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  109102. /**
  109103. * Get the class name
  109104. * @returns "SSAO2RenderingPipeline"
  109105. */
  109106. getClassName(): string;
  109107. /**
  109108. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  109109. */
  109110. dispose(disableGeometryBufferRenderer?: boolean): void;
  109111. private _createBlurPostProcess;
  109112. /** @hidden */
  109113. _rebuild(): void;
  109114. private _bits;
  109115. private _radicalInverse_VdC;
  109116. private _hammersley;
  109117. private _hemisphereSample_uniform;
  109118. private _generateHemisphere;
  109119. private _createSSAOPostProcess;
  109120. private _createSSAOCombinePostProcess;
  109121. private _createRandomTexture;
  109122. /**
  109123. * Serialize the rendering pipeline (Used when exporting)
  109124. * @returns the serialized object
  109125. */
  109126. serialize(): any;
  109127. /**
  109128. * Parse the serialized pipeline
  109129. * @param source Source pipeline.
  109130. * @param scene The scene to load the pipeline to.
  109131. * @param rootUrl The URL of the serialized pipeline.
  109132. * @returns An instantiated pipeline from the serialized object.
  109133. */
  109134. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  109135. }
  109136. }
  109137. declare module BABYLON {
  109138. /** @hidden */
  109139. export var ssaoPixelShader: {
  109140. name: string;
  109141. shader: string;
  109142. };
  109143. }
  109144. declare module BABYLON {
  109145. /**
  109146. * Render pipeline to produce ssao effect
  109147. */
  109148. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  109149. /**
  109150. * @ignore
  109151. * The PassPostProcess id in the pipeline that contains the original scene color
  109152. */
  109153. SSAOOriginalSceneColorEffect: string;
  109154. /**
  109155. * @ignore
  109156. * The SSAO PostProcess id in the pipeline
  109157. */
  109158. SSAORenderEffect: string;
  109159. /**
  109160. * @ignore
  109161. * The horizontal blur PostProcess id in the pipeline
  109162. */
  109163. SSAOBlurHRenderEffect: string;
  109164. /**
  109165. * @ignore
  109166. * The vertical blur PostProcess id in the pipeline
  109167. */
  109168. SSAOBlurVRenderEffect: string;
  109169. /**
  109170. * @ignore
  109171. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  109172. */
  109173. SSAOCombineRenderEffect: string;
  109174. /**
  109175. * The output strength of the SSAO post-process. Default value is 1.0.
  109176. */
  109177. totalStrength: number;
  109178. /**
  109179. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  109180. */
  109181. radius: number;
  109182. /**
  109183. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  109184. * Must not be equal to fallOff and superior to fallOff.
  109185. * Default value is 0.0075
  109186. */
  109187. area: number;
  109188. /**
  109189. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  109190. * Must not be equal to area and inferior to area.
  109191. * Default value is 0.000001
  109192. */
  109193. fallOff: number;
  109194. /**
  109195. * The base color of the SSAO post-process
  109196. * The final result is "base + ssao" between [0, 1]
  109197. */
  109198. base: number;
  109199. private _scene;
  109200. private _depthTexture;
  109201. private _randomTexture;
  109202. private _originalColorPostProcess;
  109203. private _ssaoPostProcess;
  109204. private _blurHPostProcess;
  109205. private _blurVPostProcess;
  109206. private _ssaoCombinePostProcess;
  109207. private _firstUpdate;
  109208. /**
  109209. * Gets active scene
  109210. */
  109211. readonly scene: Scene;
  109212. /**
  109213. * @constructor
  109214. * @param name - The rendering pipeline name
  109215. * @param scene - The scene linked to this pipeline
  109216. * @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 }
  109217. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  109218. */
  109219. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  109220. /**
  109221. * Get the class name
  109222. * @returns "SSAORenderingPipeline"
  109223. */
  109224. getClassName(): string;
  109225. /**
  109226. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  109227. */
  109228. dispose(disableDepthRender?: boolean): void;
  109229. private _createBlurPostProcess;
  109230. /** @hidden */
  109231. _rebuild(): void;
  109232. private _createSSAOPostProcess;
  109233. private _createSSAOCombinePostProcess;
  109234. private _createRandomTexture;
  109235. }
  109236. }
  109237. declare module BABYLON {
  109238. /** @hidden */
  109239. export var standardPixelShader: {
  109240. name: string;
  109241. shader: string;
  109242. };
  109243. }
  109244. declare module BABYLON {
  109245. /**
  109246. * Standard rendering pipeline
  109247. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  109248. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  109249. */
  109250. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  109251. /**
  109252. * Public members
  109253. */
  109254. /**
  109255. * Post-process which contains the original scene color before the pipeline applies all the effects
  109256. */
  109257. originalPostProcess: Nullable<PostProcess>;
  109258. /**
  109259. * Post-process used to down scale an image x4
  109260. */
  109261. downSampleX4PostProcess: Nullable<PostProcess>;
  109262. /**
  109263. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  109264. */
  109265. brightPassPostProcess: Nullable<PostProcess>;
  109266. /**
  109267. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  109268. */
  109269. blurHPostProcesses: PostProcess[];
  109270. /**
  109271. * Post-process array storing all the vertical blur post-processes used by the pipeline
  109272. */
  109273. blurVPostProcesses: PostProcess[];
  109274. /**
  109275. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  109276. */
  109277. textureAdderPostProcess: Nullable<PostProcess>;
  109278. /**
  109279. * Post-process used to create volumetric lighting effect
  109280. */
  109281. volumetricLightPostProcess: Nullable<PostProcess>;
  109282. /**
  109283. * Post-process used to smooth the previous volumetric light post-process on the X axis
  109284. */
  109285. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  109286. /**
  109287. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  109288. */
  109289. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  109290. /**
  109291. * Post-process used to merge the volumetric light effect and the real scene color
  109292. */
  109293. volumetricLightMergePostProces: Nullable<PostProcess>;
  109294. /**
  109295. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  109296. */
  109297. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  109298. /**
  109299. * Base post-process used to calculate the average luminance of the final image for HDR
  109300. */
  109301. luminancePostProcess: Nullable<PostProcess>;
  109302. /**
  109303. * Post-processes used to create down sample post-processes in order to get
  109304. * the average luminance of the final image for HDR
  109305. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  109306. */
  109307. luminanceDownSamplePostProcesses: PostProcess[];
  109308. /**
  109309. * Post-process used to create a HDR effect (light adaptation)
  109310. */
  109311. hdrPostProcess: Nullable<PostProcess>;
  109312. /**
  109313. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  109314. */
  109315. textureAdderFinalPostProcess: Nullable<PostProcess>;
  109316. /**
  109317. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  109318. */
  109319. lensFlareFinalPostProcess: Nullable<PostProcess>;
  109320. /**
  109321. * Post-process used to merge the final HDR post-process and the real scene color
  109322. */
  109323. hdrFinalPostProcess: Nullable<PostProcess>;
  109324. /**
  109325. * Post-process used to create a lens flare effect
  109326. */
  109327. lensFlarePostProcess: Nullable<PostProcess>;
  109328. /**
  109329. * Post-process that merges the result of the lens flare post-process and the real scene color
  109330. */
  109331. lensFlareComposePostProcess: Nullable<PostProcess>;
  109332. /**
  109333. * Post-process used to create a motion blur effect
  109334. */
  109335. motionBlurPostProcess: Nullable<PostProcess>;
  109336. /**
  109337. * Post-process used to create a depth of field effect
  109338. */
  109339. depthOfFieldPostProcess: Nullable<PostProcess>;
  109340. /**
  109341. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  109342. */
  109343. fxaaPostProcess: Nullable<FxaaPostProcess>;
  109344. /**
  109345. * Represents the brightness threshold in order to configure the illuminated surfaces
  109346. */
  109347. brightThreshold: number;
  109348. /**
  109349. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  109350. */
  109351. blurWidth: number;
  109352. /**
  109353. * Sets if the blur for highlighted surfaces must be only horizontal
  109354. */
  109355. horizontalBlur: boolean;
  109356. /**
  109357. * Sets the overall exposure used by the pipeline
  109358. */
  109359. exposure: number;
  109360. /**
  109361. * Texture used typically to simulate "dirty" on camera lens
  109362. */
  109363. lensTexture: Nullable<Texture>;
  109364. /**
  109365. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  109366. */
  109367. volumetricLightCoefficient: number;
  109368. /**
  109369. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  109370. */
  109371. volumetricLightPower: number;
  109372. /**
  109373. * Used the set the blur intensity to smooth the volumetric lights
  109374. */
  109375. volumetricLightBlurScale: number;
  109376. /**
  109377. * Light (spot or directional) used to generate the volumetric lights rays
  109378. * The source light must have a shadow generate so the pipeline can get its
  109379. * depth map
  109380. */
  109381. sourceLight: Nullable<SpotLight | DirectionalLight>;
  109382. /**
  109383. * For eye adaptation, represents the minimum luminance the eye can see
  109384. */
  109385. hdrMinimumLuminance: number;
  109386. /**
  109387. * For eye adaptation, represents the decrease luminance speed
  109388. */
  109389. hdrDecreaseRate: number;
  109390. /**
  109391. * For eye adaptation, represents the increase luminance speed
  109392. */
  109393. hdrIncreaseRate: number;
  109394. /**
  109395. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  109396. */
  109397. lensColorTexture: Nullable<Texture>;
  109398. /**
  109399. * The overall strengh for the lens flare effect
  109400. */
  109401. lensFlareStrength: number;
  109402. /**
  109403. * Dispersion coefficient for lens flare ghosts
  109404. */
  109405. lensFlareGhostDispersal: number;
  109406. /**
  109407. * Main lens flare halo width
  109408. */
  109409. lensFlareHaloWidth: number;
  109410. /**
  109411. * Based on the lens distortion effect, defines how much the lens flare result
  109412. * is distorted
  109413. */
  109414. lensFlareDistortionStrength: number;
  109415. /**
  109416. * Lens star texture must be used to simulate rays on the flares and is available
  109417. * in the documentation
  109418. */
  109419. lensStarTexture: Nullable<Texture>;
  109420. /**
  109421. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  109422. * flare effect by taking account of the dirt texture
  109423. */
  109424. lensFlareDirtTexture: Nullable<Texture>;
  109425. /**
  109426. * Represents the focal length for the depth of field effect
  109427. */
  109428. depthOfFieldDistance: number;
  109429. /**
  109430. * Represents the blur intensity for the blurred part of the depth of field effect
  109431. */
  109432. depthOfFieldBlurWidth: number;
  109433. /**
  109434. * For motion blur, defines how much the image is blurred by the movement
  109435. */
  109436. motionStrength: number;
  109437. /**
  109438. * List of animations for the pipeline (IAnimatable implementation)
  109439. */
  109440. animations: Animation[];
  109441. /**
  109442. * Private members
  109443. */
  109444. private _scene;
  109445. private _currentDepthOfFieldSource;
  109446. private _basePostProcess;
  109447. private _hdrCurrentLuminance;
  109448. private _floatTextureType;
  109449. private _ratio;
  109450. private _bloomEnabled;
  109451. private _depthOfFieldEnabled;
  109452. private _vlsEnabled;
  109453. private _lensFlareEnabled;
  109454. private _hdrEnabled;
  109455. private _motionBlurEnabled;
  109456. private _fxaaEnabled;
  109457. private _motionBlurSamples;
  109458. private _volumetricLightStepsCount;
  109459. private _samples;
  109460. /**
  109461. * @ignore
  109462. * Specifies if the bloom pipeline is enabled
  109463. */
  109464. BloomEnabled: boolean;
  109465. /**
  109466. * @ignore
  109467. * Specifies if the depth of field pipeline is enabed
  109468. */
  109469. DepthOfFieldEnabled: boolean;
  109470. /**
  109471. * @ignore
  109472. * Specifies if the lens flare pipeline is enabed
  109473. */
  109474. LensFlareEnabled: boolean;
  109475. /**
  109476. * @ignore
  109477. * Specifies if the HDR pipeline is enabled
  109478. */
  109479. HDREnabled: boolean;
  109480. /**
  109481. * @ignore
  109482. * Specifies if the volumetric lights scattering effect is enabled
  109483. */
  109484. VLSEnabled: boolean;
  109485. /**
  109486. * @ignore
  109487. * Specifies if the motion blur effect is enabled
  109488. */
  109489. MotionBlurEnabled: boolean;
  109490. /**
  109491. * Specifies if anti-aliasing is enabled
  109492. */
  109493. fxaaEnabled: boolean;
  109494. /**
  109495. * Specifies the number of steps used to calculate the volumetric lights
  109496. * Typically in interval [50, 200]
  109497. */
  109498. volumetricLightStepsCount: number;
  109499. /**
  109500. * Specifies the number of samples used for the motion blur effect
  109501. * Typically in interval [16, 64]
  109502. */
  109503. motionBlurSamples: number;
  109504. /**
  109505. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  109506. */
  109507. samples: number;
  109508. /**
  109509. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  109510. * @constructor
  109511. * @param name The rendering pipeline name
  109512. * @param scene The scene linked to this pipeline
  109513. * @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)
  109514. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  109515. * @param cameras The array of cameras that the rendering pipeline will be attached to
  109516. */
  109517. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  109518. private _buildPipeline;
  109519. private _createDownSampleX4PostProcess;
  109520. private _createBrightPassPostProcess;
  109521. private _createBlurPostProcesses;
  109522. private _createTextureAdderPostProcess;
  109523. private _createVolumetricLightPostProcess;
  109524. private _createLuminancePostProcesses;
  109525. private _createHdrPostProcess;
  109526. private _createLensFlarePostProcess;
  109527. private _createDepthOfFieldPostProcess;
  109528. private _createMotionBlurPostProcess;
  109529. private _getDepthTexture;
  109530. private _disposePostProcesses;
  109531. /**
  109532. * Dispose of the pipeline and stop all post processes
  109533. */
  109534. dispose(): void;
  109535. /**
  109536. * Serialize the rendering pipeline (Used when exporting)
  109537. * @returns the serialized object
  109538. */
  109539. serialize(): any;
  109540. /**
  109541. * Parse the serialized pipeline
  109542. * @param source Source pipeline.
  109543. * @param scene The scene to load the pipeline to.
  109544. * @param rootUrl The URL of the serialized pipeline.
  109545. * @returns An instantiated pipeline from the serialized object.
  109546. */
  109547. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  109548. /**
  109549. * Luminance steps
  109550. */
  109551. static LuminanceSteps: number;
  109552. }
  109553. }
  109554. declare module BABYLON {
  109555. /**
  109556. * PostProcessRenderPipelineManager class
  109557. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  109558. */
  109559. export class PostProcessRenderPipelineManager {
  109560. private _renderPipelines;
  109561. /**
  109562. * Initializes a PostProcessRenderPipelineManager
  109563. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  109564. */
  109565. constructor();
  109566. /**
  109567. * Gets the list of supported render pipelines
  109568. */
  109569. readonly supportedPipelines: PostProcessRenderPipeline[];
  109570. /**
  109571. * Adds a pipeline to the manager
  109572. * @param renderPipeline The pipeline to add
  109573. */
  109574. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  109575. /**
  109576. * Attaches a camera to the pipeline
  109577. * @param renderPipelineName The name of the pipeline to attach to
  109578. * @param cameras the camera to attach
  109579. * @param unique if the camera can be attached multiple times to the pipeline
  109580. */
  109581. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  109582. /**
  109583. * Detaches a camera from the pipeline
  109584. * @param renderPipelineName The name of the pipeline to detach from
  109585. * @param cameras the camera to detach
  109586. */
  109587. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  109588. /**
  109589. * Enables an effect by name on a pipeline
  109590. * @param renderPipelineName the name of the pipeline to enable the effect in
  109591. * @param renderEffectName the name of the effect to enable
  109592. * @param cameras the cameras that the effect should be enabled on
  109593. */
  109594. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  109595. /**
  109596. * Disables an effect by name on a pipeline
  109597. * @param renderPipelineName the name of the pipeline to disable the effect in
  109598. * @param renderEffectName the name of the effect to disable
  109599. * @param cameras the cameras that the effect should be disabled on
  109600. */
  109601. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  109602. /**
  109603. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  109604. */
  109605. update(): void;
  109606. /** @hidden */
  109607. _rebuild(): void;
  109608. /**
  109609. * Disposes of the manager and pipelines
  109610. */
  109611. dispose(): void;
  109612. }
  109613. }
  109614. declare module BABYLON {
  109615. interface Scene {
  109616. /** @hidden (Backing field) */
  109617. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  109618. /**
  109619. * Gets the postprocess render pipeline manager
  109620. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  109621. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  109622. */
  109623. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  109624. }
  109625. /**
  109626. * Defines the Render Pipeline scene component responsible to rendering pipelines
  109627. */
  109628. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  109629. /**
  109630. * The component name helpfull to identify the component in the list of scene components.
  109631. */
  109632. readonly name: string;
  109633. /**
  109634. * The scene the component belongs to.
  109635. */
  109636. scene: Scene;
  109637. /**
  109638. * Creates a new instance of the component for the given scene
  109639. * @param scene Defines the scene to register the component in
  109640. */
  109641. constructor(scene: Scene);
  109642. /**
  109643. * Registers the component in a given scene
  109644. */
  109645. register(): void;
  109646. /**
  109647. * Rebuilds the elements related to this component in case of
  109648. * context lost for instance.
  109649. */
  109650. rebuild(): void;
  109651. /**
  109652. * Disposes the component and the associated ressources
  109653. */
  109654. dispose(): void;
  109655. private _gatherRenderTargets;
  109656. }
  109657. }
  109658. declare module BABYLON {
  109659. /** @hidden */
  109660. export var tonemapPixelShader: {
  109661. name: string;
  109662. shader: string;
  109663. };
  109664. }
  109665. declare module BABYLON {
  109666. /** Defines operator used for tonemapping */
  109667. export enum TonemappingOperator {
  109668. /** Hable */
  109669. Hable = 0,
  109670. /** Reinhard */
  109671. Reinhard = 1,
  109672. /** HejiDawson */
  109673. HejiDawson = 2,
  109674. /** Photographic */
  109675. Photographic = 3
  109676. }
  109677. /**
  109678. * Defines a post process to apply tone mapping
  109679. */
  109680. export class TonemapPostProcess extends PostProcess {
  109681. private _operator;
  109682. /** Defines the required exposure adjustement */
  109683. exposureAdjustment: number;
  109684. /**
  109685. * Creates a new TonemapPostProcess
  109686. * @param name defines the name of the postprocess
  109687. * @param _operator defines the operator to use
  109688. * @param exposureAdjustment defines the required exposure adjustement
  109689. * @param camera defines the camera to use (can be null)
  109690. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  109691. * @param engine defines the hosting engine (can be ignore if camera is set)
  109692. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  109693. */
  109694. constructor(name: string, _operator: TonemappingOperator,
  109695. /** Defines the required exposure adjustement */
  109696. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  109697. }
  109698. }
  109699. declare module BABYLON {
  109700. /** @hidden */
  109701. export var depthVertexShader: {
  109702. name: string;
  109703. shader: string;
  109704. };
  109705. }
  109706. declare module BABYLON {
  109707. /** @hidden */
  109708. export var volumetricLightScatteringPixelShader: {
  109709. name: string;
  109710. shader: string;
  109711. };
  109712. }
  109713. declare module BABYLON {
  109714. /** @hidden */
  109715. export var volumetricLightScatteringPassPixelShader: {
  109716. name: string;
  109717. shader: string;
  109718. };
  109719. }
  109720. declare module BABYLON {
  109721. /**
  109722. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  109723. */
  109724. export class VolumetricLightScatteringPostProcess extends PostProcess {
  109725. private _volumetricLightScatteringPass;
  109726. private _volumetricLightScatteringRTT;
  109727. private _viewPort;
  109728. private _screenCoordinates;
  109729. private _cachedDefines;
  109730. /**
  109731. * If not undefined, the mesh position is computed from the attached node position
  109732. */
  109733. attachedNode: {
  109734. position: Vector3;
  109735. };
  109736. /**
  109737. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  109738. */
  109739. customMeshPosition: Vector3;
  109740. /**
  109741. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  109742. */
  109743. useCustomMeshPosition: boolean;
  109744. /**
  109745. * If the post-process should inverse the light scattering direction
  109746. */
  109747. invert: boolean;
  109748. /**
  109749. * The internal mesh used by the post-process
  109750. */
  109751. mesh: Mesh;
  109752. /**
  109753. * @hidden
  109754. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  109755. */
  109756. useDiffuseColor: boolean;
  109757. /**
  109758. * Array containing the excluded meshes not rendered in the internal pass
  109759. */
  109760. excludedMeshes: AbstractMesh[];
  109761. /**
  109762. * Controls the overall intensity of the post-process
  109763. */
  109764. exposure: number;
  109765. /**
  109766. * Dissipates each sample's contribution in range [0, 1]
  109767. */
  109768. decay: number;
  109769. /**
  109770. * Controls the overall intensity of each sample
  109771. */
  109772. weight: number;
  109773. /**
  109774. * Controls the density of each sample
  109775. */
  109776. density: number;
  109777. /**
  109778. * @constructor
  109779. * @param name The post-process name
  109780. * @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)
  109781. * @param camera The camera that the post-process will be attached to
  109782. * @param mesh The mesh used to create the light scattering
  109783. * @param samples The post-process quality, default 100
  109784. * @param samplingModeThe post-process filtering mode
  109785. * @param engine The babylon engine
  109786. * @param reusable If the post-process is reusable
  109787. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  109788. */
  109789. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  109790. /**
  109791. * Returns the string "VolumetricLightScatteringPostProcess"
  109792. * @returns "VolumetricLightScatteringPostProcess"
  109793. */
  109794. getClassName(): string;
  109795. private _isReady;
  109796. /**
  109797. * Sets the new light position for light scattering effect
  109798. * @param position The new custom light position
  109799. */
  109800. setCustomMeshPosition(position: Vector3): void;
  109801. /**
  109802. * Returns the light position for light scattering effect
  109803. * @return Vector3 The custom light position
  109804. */
  109805. getCustomMeshPosition(): Vector3;
  109806. /**
  109807. * Disposes the internal assets and detaches the post-process from the camera
  109808. */
  109809. dispose(camera: Camera): void;
  109810. /**
  109811. * Returns the render target texture used by the post-process
  109812. * @return the render target texture used by the post-process
  109813. */
  109814. getPass(): RenderTargetTexture;
  109815. private _meshExcluded;
  109816. private _createPass;
  109817. private _updateMeshScreenCoordinates;
  109818. /**
  109819. * Creates a default mesh for the Volumeric Light Scattering post-process
  109820. * @param name The mesh name
  109821. * @param scene The scene where to create the mesh
  109822. * @return the default mesh
  109823. */
  109824. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  109825. }
  109826. }
  109827. declare module BABYLON {
  109828. interface Scene {
  109829. /** @hidden (Backing field) */
  109830. _boundingBoxRenderer: BoundingBoxRenderer;
  109831. /** @hidden (Backing field) */
  109832. _forceShowBoundingBoxes: boolean;
  109833. /**
  109834. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  109835. */
  109836. forceShowBoundingBoxes: boolean;
  109837. /**
  109838. * Gets the bounding box renderer associated with the scene
  109839. * @returns a BoundingBoxRenderer
  109840. */
  109841. getBoundingBoxRenderer(): BoundingBoxRenderer;
  109842. }
  109843. interface AbstractMesh {
  109844. /** @hidden (Backing field) */
  109845. _showBoundingBox: boolean;
  109846. /**
  109847. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  109848. */
  109849. showBoundingBox: boolean;
  109850. }
  109851. /**
  109852. * Component responsible of rendering the bounding box of the meshes in a scene.
  109853. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  109854. */
  109855. export class BoundingBoxRenderer implements ISceneComponent {
  109856. /**
  109857. * The component name helpfull to identify the component in the list of scene components.
  109858. */
  109859. readonly name: string;
  109860. /**
  109861. * The scene the component belongs to.
  109862. */
  109863. scene: Scene;
  109864. /**
  109865. * Color of the bounding box lines placed in front of an object
  109866. */
  109867. frontColor: Color3;
  109868. /**
  109869. * Color of the bounding box lines placed behind an object
  109870. */
  109871. backColor: Color3;
  109872. /**
  109873. * Defines if the renderer should show the back lines or not
  109874. */
  109875. showBackLines: boolean;
  109876. /**
  109877. * @hidden
  109878. */
  109879. renderList: SmartArray<BoundingBox>;
  109880. private _colorShader;
  109881. private _vertexBuffers;
  109882. private _indexBuffer;
  109883. /**
  109884. * Instantiates a new bounding box renderer in a scene.
  109885. * @param scene the scene the renderer renders in
  109886. */
  109887. constructor(scene: Scene);
  109888. /**
  109889. * Registers the component in a given scene
  109890. */
  109891. register(): void;
  109892. private _evaluateSubMesh;
  109893. private _activeMesh;
  109894. private _prepareRessources;
  109895. private _createIndexBuffer;
  109896. /**
  109897. * Rebuilds the elements related to this component in case of
  109898. * context lost for instance.
  109899. */
  109900. rebuild(): void;
  109901. /**
  109902. * @hidden
  109903. */
  109904. reset(): void;
  109905. /**
  109906. * Render the bounding boxes of a specific rendering group
  109907. * @param renderingGroupId defines the rendering group to render
  109908. */
  109909. render(renderingGroupId: number): void;
  109910. /**
  109911. * In case of occlusion queries, we can render the occlusion bounding box through this method
  109912. * @param mesh Define the mesh to render the occlusion bounding box for
  109913. */
  109914. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  109915. /**
  109916. * Dispose and release the resources attached to this renderer.
  109917. */
  109918. dispose(): void;
  109919. }
  109920. }
  109921. declare module BABYLON {
  109922. /** @hidden */
  109923. export var depthPixelShader: {
  109924. name: string;
  109925. shader: string;
  109926. };
  109927. }
  109928. declare module BABYLON {
  109929. /**
  109930. * This represents a depth renderer in Babylon.
  109931. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  109932. */
  109933. export class DepthRenderer {
  109934. private _scene;
  109935. private _depthMap;
  109936. private _effect;
  109937. private _cachedDefines;
  109938. private _camera;
  109939. /**
  109940. * Specifiess that the depth renderer will only be used within
  109941. * the camera it is created for.
  109942. * This can help forcing its rendering during the camera processing.
  109943. */
  109944. useOnlyInActiveCamera: boolean;
  109945. /** @hidden */
  109946. static _SceneComponentInitialization: (scene: Scene) => void;
  109947. /**
  109948. * Instantiates a depth renderer
  109949. * @param scene The scene the renderer belongs to
  109950. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  109951. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  109952. */
  109953. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  109954. /**
  109955. * Creates the depth rendering effect and checks if the effect is ready.
  109956. * @param subMesh The submesh to be used to render the depth map of
  109957. * @param useInstances If multiple world instances should be used
  109958. * @returns if the depth renderer is ready to render the depth map
  109959. */
  109960. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  109961. /**
  109962. * Gets the texture which the depth map will be written to.
  109963. * @returns The depth map texture
  109964. */
  109965. getDepthMap(): RenderTargetTexture;
  109966. /**
  109967. * Disposes of the depth renderer.
  109968. */
  109969. dispose(): void;
  109970. }
  109971. }
  109972. declare module BABYLON {
  109973. interface Scene {
  109974. /** @hidden (Backing field) */
  109975. _depthRenderer: {
  109976. [id: string]: DepthRenderer;
  109977. };
  109978. /**
  109979. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  109980. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  109981. * @returns the created depth renderer
  109982. */
  109983. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  109984. /**
  109985. * Disables a depth renderer for a given camera
  109986. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  109987. */
  109988. disableDepthRenderer(camera?: Nullable<Camera>): void;
  109989. }
  109990. /**
  109991. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  109992. * in several rendering techniques.
  109993. */
  109994. export class DepthRendererSceneComponent implements ISceneComponent {
  109995. /**
  109996. * The component name helpfull to identify the component in the list of scene components.
  109997. */
  109998. readonly name: string;
  109999. /**
  110000. * The scene the component belongs to.
  110001. */
  110002. scene: Scene;
  110003. /**
  110004. * Creates a new instance of the component for the given scene
  110005. * @param scene Defines the scene to register the component in
  110006. */
  110007. constructor(scene: Scene);
  110008. /**
  110009. * Registers the component in a given scene
  110010. */
  110011. register(): void;
  110012. /**
  110013. * Rebuilds the elements related to this component in case of
  110014. * context lost for instance.
  110015. */
  110016. rebuild(): void;
  110017. /**
  110018. * Disposes the component and the associated ressources
  110019. */
  110020. dispose(): void;
  110021. private _gatherRenderTargets;
  110022. private _gatherActiveCameraRenderTargets;
  110023. }
  110024. }
  110025. declare module BABYLON {
  110026. interface Scene {
  110027. /** @hidden (Backing field) */
  110028. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  110029. /**
  110030. * Gets or Sets the current geometry buffer associated to the scene.
  110031. */
  110032. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  110033. /**
  110034. * Enables a GeometryBufferRender and associates it with the scene
  110035. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  110036. * @returns the GeometryBufferRenderer
  110037. */
  110038. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  110039. /**
  110040. * Disables the GeometryBufferRender associated with the scene
  110041. */
  110042. disableGeometryBufferRenderer(): void;
  110043. }
  110044. /**
  110045. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  110046. * in several rendering techniques.
  110047. */
  110048. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  110049. /**
  110050. * The component name helpful to identify the component in the list of scene components.
  110051. */
  110052. readonly name: string;
  110053. /**
  110054. * The scene the component belongs to.
  110055. */
  110056. scene: Scene;
  110057. /**
  110058. * Creates a new instance of the component for the given scene
  110059. * @param scene Defines the scene to register the component in
  110060. */
  110061. constructor(scene: Scene);
  110062. /**
  110063. * Registers the component in a given scene
  110064. */
  110065. register(): void;
  110066. /**
  110067. * Rebuilds the elements related to this component in case of
  110068. * context lost for instance.
  110069. */
  110070. rebuild(): void;
  110071. /**
  110072. * Disposes the component and the associated ressources
  110073. */
  110074. dispose(): void;
  110075. private _gatherRenderTargets;
  110076. }
  110077. }
  110078. declare module BABYLON {
  110079. /** @hidden */
  110080. export var outlinePixelShader: {
  110081. name: string;
  110082. shader: string;
  110083. };
  110084. }
  110085. declare module BABYLON {
  110086. /** @hidden */
  110087. export var outlineVertexShader: {
  110088. name: string;
  110089. shader: string;
  110090. };
  110091. }
  110092. declare module BABYLON {
  110093. interface Scene {
  110094. /** @hidden */
  110095. _outlineRenderer: OutlineRenderer;
  110096. /**
  110097. * Gets the outline renderer associated with the scene
  110098. * @returns a OutlineRenderer
  110099. */
  110100. getOutlineRenderer(): OutlineRenderer;
  110101. }
  110102. interface AbstractMesh {
  110103. /** @hidden (Backing field) */
  110104. _renderOutline: boolean;
  110105. /**
  110106. * Gets or sets a boolean indicating if the outline must be rendered as well
  110107. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  110108. */
  110109. renderOutline: boolean;
  110110. /** @hidden (Backing field) */
  110111. _renderOverlay: boolean;
  110112. /**
  110113. * Gets or sets a boolean indicating if the overlay must be rendered as well
  110114. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  110115. */
  110116. renderOverlay: boolean;
  110117. }
  110118. /**
  110119. * This class is responsible to draw bothe outline/overlay of meshes.
  110120. * It should not be used directly but through the available method on mesh.
  110121. */
  110122. export class OutlineRenderer implements ISceneComponent {
  110123. /**
  110124. * The name of the component. Each component must have a unique name.
  110125. */
  110126. name: string;
  110127. /**
  110128. * The scene the component belongs to.
  110129. */
  110130. scene: Scene;
  110131. /**
  110132. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  110133. */
  110134. zOffset: number;
  110135. private _engine;
  110136. private _effect;
  110137. private _cachedDefines;
  110138. private _savedDepthWrite;
  110139. /**
  110140. * Instantiates a new outline renderer. (There could be only one per scene).
  110141. * @param scene Defines the scene it belongs to
  110142. */
  110143. constructor(scene: Scene);
  110144. /**
  110145. * Register the component to one instance of a scene.
  110146. */
  110147. register(): void;
  110148. /**
  110149. * Rebuilds the elements related to this component in case of
  110150. * context lost for instance.
  110151. */
  110152. rebuild(): void;
  110153. /**
  110154. * Disposes the component and the associated ressources.
  110155. */
  110156. dispose(): void;
  110157. /**
  110158. * Renders the outline in the canvas.
  110159. * @param subMesh Defines the sumesh to render
  110160. * @param batch Defines the batch of meshes in case of instances
  110161. * @param useOverlay Defines if the rendering is for the overlay or the outline
  110162. */
  110163. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  110164. /**
  110165. * Returns whether or not the outline renderer is ready for a given submesh.
  110166. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  110167. * @param subMesh Defines the submesh to check readyness for
  110168. * @param useInstances Defines wheter wee are trying to render instances or not
  110169. * @returns true if ready otherwise false
  110170. */
  110171. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  110172. private _beforeRenderingMesh;
  110173. private _afterRenderingMesh;
  110174. }
  110175. }
  110176. declare module BABYLON {
  110177. /**
  110178. * Defines the list of states available for a task inside a AssetsManager
  110179. */
  110180. export enum AssetTaskState {
  110181. /**
  110182. * Initialization
  110183. */
  110184. INIT = 0,
  110185. /**
  110186. * Running
  110187. */
  110188. RUNNING = 1,
  110189. /**
  110190. * Done
  110191. */
  110192. DONE = 2,
  110193. /**
  110194. * Error
  110195. */
  110196. ERROR = 3
  110197. }
  110198. /**
  110199. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  110200. */
  110201. export abstract class AbstractAssetTask {
  110202. /**
  110203. * Task name
  110204. */ name: string;
  110205. /**
  110206. * Callback called when the task is successful
  110207. */
  110208. onSuccess: (task: any) => void;
  110209. /**
  110210. * Callback called when the task is not successful
  110211. */
  110212. onError: (task: any, message?: string, exception?: any) => void;
  110213. /**
  110214. * Creates a new AssetsManager
  110215. * @param name defines the name of the task
  110216. */
  110217. constructor(
  110218. /**
  110219. * Task name
  110220. */ name: string);
  110221. private _isCompleted;
  110222. private _taskState;
  110223. private _errorObject;
  110224. /**
  110225. * Get if the task is completed
  110226. */
  110227. readonly isCompleted: boolean;
  110228. /**
  110229. * Gets the current state of the task
  110230. */
  110231. readonly taskState: AssetTaskState;
  110232. /**
  110233. * Gets the current error object (if task is in error)
  110234. */
  110235. readonly errorObject: {
  110236. message?: string;
  110237. exception?: any;
  110238. };
  110239. /**
  110240. * Internal only
  110241. * @hidden
  110242. */
  110243. _setErrorObject(message?: string, exception?: any): void;
  110244. /**
  110245. * Execute the current task
  110246. * @param scene defines the scene where you want your assets to be loaded
  110247. * @param onSuccess is a callback called when the task is successfully executed
  110248. * @param onError is a callback called if an error occurs
  110249. */
  110250. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  110251. /**
  110252. * Execute the current task
  110253. * @param scene defines the scene where you want your assets to be loaded
  110254. * @param onSuccess is a callback called when the task is successfully executed
  110255. * @param onError is a callback called if an error occurs
  110256. */
  110257. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  110258. /**
  110259. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  110260. * This can be used with failed tasks that have the reason for failure fixed.
  110261. */
  110262. reset(): void;
  110263. private onErrorCallback;
  110264. private onDoneCallback;
  110265. }
  110266. /**
  110267. * Define the interface used by progress events raised during assets loading
  110268. */
  110269. export interface IAssetsProgressEvent {
  110270. /**
  110271. * Defines the number of remaining tasks to process
  110272. */
  110273. remainingCount: number;
  110274. /**
  110275. * Defines the total number of tasks
  110276. */
  110277. totalCount: number;
  110278. /**
  110279. * Defines the task that was just processed
  110280. */
  110281. task: AbstractAssetTask;
  110282. }
  110283. /**
  110284. * Class used to share progress information about assets loading
  110285. */
  110286. export class AssetsProgressEvent implements IAssetsProgressEvent {
  110287. /**
  110288. * Defines the number of remaining tasks to process
  110289. */
  110290. remainingCount: number;
  110291. /**
  110292. * Defines the total number of tasks
  110293. */
  110294. totalCount: number;
  110295. /**
  110296. * Defines the task that was just processed
  110297. */
  110298. task: AbstractAssetTask;
  110299. /**
  110300. * Creates a AssetsProgressEvent
  110301. * @param remainingCount defines the number of remaining tasks to process
  110302. * @param totalCount defines the total number of tasks
  110303. * @param task defines the task that was just processed
  110304. */
  110305. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  110306. }
  110307. /**
  110308. * Define a task used by AssetsManager to load meshes
  110309. */
  110310. export class MeshAssetTask extends AbstractAssetTask {
  110311. /**
  110312. * Defines the name of the task
  110313. */
  110314. name: string;
  110315. /**
  110316. * Defines the list of mesh's names you want to load
  110317. */
  110318. meshesNames: any;
  110319. /**
  110320. * Defines the root url to use as a base to load your meshes and associated resources
  110321. */
  110322. rootUrl: string;
  110323. /**
  110324. * Defines the filename of the scene to load from
  110325. */
  110326. sceneFilename: string;
  110327. /**
  110328. * Gets the list of loaded meshes
  110329. */
  110330. loadedMeshes: Array<AbstractMesh>;
  110331. /**
  110332. * Gets the list of loaded particle systems
  110333. */
  110334. loadedParticleSystems: Array<IParticleSystem>;
  110335. /**
  110336. * Gets the list of loaded skeletons
  110337. */
  110338. loadedSkeletons: Array<Skeleton>;
  110339. /**
  110340. * Gets the list of loaded animation groups
  110341. */
  110342. loadedAnimationGroups: Array<AnimationGroup>;
  110343. /**
  110344. * Callback called when the task is successful
  110345. */
  110346. onSuccess: (task: MeshAssetTask) => void;
  110347. /**
  110348. * Callback called when the task is successful
  110349. */
  110350. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  110351. /**
  110352. * Creates a new MeshAssetTask
  110353. * @param name defines the name of the task
  110354. * @param meshesNames defines the list of mesh's names you want to load
  110355. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  110356. * @param sceneFilename defines the filename of the scene to load from
  110357. */
  110358. constructor(
  110359. /**
  110360. * Defines the name of the task
  110361. */
  110362. name: string,
  110363. /**
  110364. * Defines the list of mesh's names you want to load
  110365. */
  110366. meshesNames: any,
  110367. /**
  110368. * Defines the root url to use as a base to load your meshes and associated resources
  110369. */
  110370. rootUrl: string,
  110371. /**
  110372. * Defines the filename of the scene to load from
  110373. */
  110374. sceneFilename: string);
  110375. /**
  110376. * Execute the current task
  110377. * @param scene defines the scene where you want your assets to be loaded
  110378. * @param onSuccess is a callback called when the task is successfully executed
  110379. * @param onError is a callback called if an error occurs
  110380. */
  110381. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  110382. }
  110383. /**
  110384. * Define a task used by AssetsManager to load text content
  110385. */
  110386. export class TextFileAssetTask extends AbstractAssetTask {
  110387. /**
  110388. * Defines the name of the task
  110389. */
  110390. name: string;
  110391. /**
  110392. * Defines the location of the file to load
  110393. */
  110394. url: string;
  110395. /**
  110396. * Gets the loaded text string
  110397. */
  110398. text: string;
  110399. /**
  110400. * Callback called when the task is successful
  110401. */
  110402. onSuccess: (task: TextFileAssetTask) => void;
  110403. /**
  110404. * Callback called when the task is successful
  110405. */
  110406. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  110407. /**
  110408. * Creates a new TextFileAssetTask object
  110409. * @param name defines the name of the task
  110410. * @param url defines the location of the file to load
  110411. */
  110412. constructor(
  110413. /**
  110414. * Defines the name of the task
  110415. */
  110416. name: string,
  110417. /**
  110418. * Defines the location of the file to load
  110419. */
  110420. url: string);
  110421. /**
  110422. * Execute the current task
  110423. * @param scene defines the scene where you want your assets to be loaded
  110424. * @param onSuccess is a callback called when the task is successfully executed
  110425. * @param onError is a callback called if an error occurs
  110426. */
  110427. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  110428. }
  110429. /**
  110430. * Define a task used by AssetsManager to load binary data
  110431. */
  110432. export class BinaryFileAssetTask extends AbstractAssetTask {
  110433. /**
  110434. * Defines the name of the task
  110435. */
  110436. name: string;
  110437. /**
  110438. * Defines the location of the file to load
  110439. */
  110440. url: string;
  110441. /**
  110442. * Gets the lodaded data (as an array buffer)
  110443. */
  110444. data: ArrayBuffer;
  110445. /**
  110446. * Callback called when the task is successful
  110447. */
  110448. onSuccess: (task: BinaryFileAssetTask) => void;
  110449. /**
  110450. * Callback called when the task is successful
  110451. */
  110452. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  110453. /**
  110454. * Creates a new BinaryFileAssetTask object
  110455. * @param name defines the name of the new task
  110456. * @param url defines the location of the file to load
  110457. */
  110458. constructor(
  110459. /**
  110460. * Defines the name of the task
  110461. */
  110462. name: string,
  110463. /**
  110464. * Defines the location of the file to load
  110465. */
  110466. url: string);
  110467. /**
  110468. * Execute the current task
  110469. * @param scene defines the scene where you want your assets to be loaded
  110470. * @param onSuccess is a callback called when the task is successfully executed
  110471. * @param onError is a callback called if an error occurs
  110472. */
  110473. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  110474. }
  110475. /**
  110476. * Define a task used by AssetsManager to load images
  110477. */
  110478. export class ImageAssetTask extends AbstractAssetTask {
  110479. /**
  110480. * Defines the name of the task
  110481. */
  110482. name: string;
  110483. /**
  110484. * Defines the location of the image to load
  110485. */
  110486. url: string;
  110487. /**
  110488. * Gets the loaded images
  110489. */
  110490. image: HTMLImageElement;
  110491. /**
  110492. * Callback called when the task is successful
  110493. */
  110494. onSuccess: (task: ImageAssetTask) => void;
  110495. /**
  110496. * Callback called when the task is successful
  110497. */
  110498. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  110499. /**
  110500. * Creates a new ImageAssetTask
  110501. * @param name defines the name of the task
  110502. * @param url defines the location of the image to load
  110503. */
  110504. constructor(
  110505. /**
  110506. * Defines the name of the task
  110507. */
  110508. name: string,
  110509. /**
  110510. * Defines the location of the image to load
  110511. */
  110512. url: string);
  110513. /**
  110514. * Execute the current task
  110515. * @param scene defines the scene where you want your assets to be loaded
  110516. * @param onSuccess is a callback called when the task is successfully executed
  110517. * @param onError is a callback called if an error occurs
  110518. */
  110519. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  110520. }
  110521. /**
  110522. * Defines the interface used by texture loading tasks
  110523. */
  110524. export interface ITextureAssetTask<TEX extends BaseTexture> {
  110525. /**
  110526. * Gets the loaded texture
  110527. */
  110528. texture: TEX;
  110529. }
  110530. /**
  110531. * Define a task used by AssetsManager to load 2D textures
  110532. */
  110533. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  110534. /**
  110535. * Defines the name of the task
  110536. */
  110537. name: string;
  110538. /**
  110539. * Defines the location of the file to load
  110540. */
  110541. url: string;
  110542. /**
  110543. * Defines if mipmap should not be generated (default is false)
  110544. */
  110545. noMipmap?: boolean | undefined;
  110546. /**
  110547. * Defines if texture must be inverted on Y axis (default is false)
  110548. */
  110549. invertY?: boolean | undefined;
  110550. /**
  110551. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  110552. */
  110553. samplingMode: number;
  110554. /**
  110555. * Gets the loaded texture
  110556. */
  110557. texture: Texture;
  110558. /**
  110559. * Callback called when the task is successful
  110560. */
  110561. onSuccess: (task: TextureAssetTask) => void;
  110562. /**
  110563. * Callback called when the task is successful
  110564. */
  110565. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  110566. /**
  110567. * Creates a new TextureAssetTask object
  110568. * @param name defines the name of the task
  110569. * @param url defines the location of the file to load
  110570. * @param noMipmap defines if mipmap should not be generated (default is false)
  110571. * @param invertY defines if texture must be inverted on Y axis (default is false)
  110572. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  110573. */
  110574. constructor(
  110575. /**
  110576. * Defines the name of the task
  110577. */
  110578. name: string,
  110579. /**
  110580. * Defines the location of the file to load
  110581. */
  110582. url: string,
  110583. /**
  110584. * Defines if mipmap should not be generated (default is false)
  110585. */
  110586. noMipmap?: boolean | undefined,
  110587. /**
  110588. * Defines if texture must be inverted on Y axis (default is false)
  110589. */
  110590. invertY?: boolean | undefined,
  110591. /**
  110592. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  110593. */
  110594. samplingMode?: number);
  110595. /**
  110596. * Execute the current task
  110597. * @param scene defines the scene where you want your assets to be loaded
  110598. * @param onSuccess is a callback called when the task is successfully executed
  110599. * @param onError is a callback called if an error occurs
  110600. */
  110601. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  110602. }
  110603. /**
  110604. * Define a task used by AssetsManager to load cube textures
  110605. */
  110606. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  110607. /**
  110608. * Defines the name of the task
  110609. */
  110610. name: string;
  110611. /**
  110612. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  110613. */
  110614. url: string;
  110615. /**
  110616. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  110617. */
  110618. extensions?: string[] | undefined;
  110619. /**
  110620. * Defines if mipmaps should not be generated (default is false)
  110621. */
  110622. noMipmap?: boolean | undefined;
  110623. /**
  110624. * Defines the explicit list of files (undefined by default)
  110625. */
  110626. files?: string[] | undefined;
  110627. /**
  110628. * Gets the loaded texture
  110629. */
  110630. texture: CubeTexture;
  110631. /**
  110632. * Callback called when the task is successful
  110633. */
  110634. onSuccess: (task: CubeTextureAssetTask) => void;
  110635. /**
  110636. * Callback called when the task is successful
  110637. */
  110638. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  110639. /**
  110640. * Creates a new CubeTextureAssetTask
  110641. * @param name defines the name of the task
  110642. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  110643. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  110644. * @param noMipmap defines if mipmaps should not be generated (default is false)
  110645. * @param files defines the explicit list of files (undefined by default)
  110646. */
  110647. constructor(
  110648. /**
  110649. * Defines the name of the task
  110650. */
  110651. name: string,
  110652. /**
  110653. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  110654. */
  110655. url: string,
  110656. /**
  110657. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  110658. */
  110659. extensions?: string[] | undefined,
  110660. /**
  110661. * Defines if mipmaps should not be generated (default is false)
  110662. */
  110663. noMipmap?: boolean | undefined,
  110664. /**
  110665. * Defines the explicit list of files (undefined by default)
  110666. */
  110667. files?: string[] | undefined);
  110668. /**
  110669. * Execute the current task
  110670. * @param scene defines the scene where you want your assets to be loaded
  110671. * @param onSuccess is a callback called when the task is successfully executed
  110672. * @param onError is a callback called if an error occurs
  110673. */
  110674. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  110675. }
  110676. /**
  110677. * Define a task used by AssetsManager to load HDR cube textures
  110678. */
  110679. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  110680. /**
  110681. * Defines the name of the task
  110682. */
  110683. name: string;
  110684. /**
  110685. * Defines the location of the file to load
  110686. */
  110687. url: string;
  110688. /**
  110689. * Defines the desired size (the more it increases the longer the generation will be)
  110690. */
  110691. size: number;
  110692. /**
  110693. * Defines if mipmaps should not be generated (default is false)
  110694. */
  110695. noMipmap: boolean;
  110696. /**
  110697. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  110698. */
  110699. generateHarmonics: boolean;
  110700. /**
  110701. * 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)
  110702. */
  110703. gammaSpace: boolean;
  110704. /**
  110705. * Internal Use Only
  110706. */
  110707. reserved: boolean;
  110708. /**
  110709. * Gets the loaded texture
  110710. */
  110711. texture: HDRCubeTexture;
  110712. /**
  110713. * Callback called when the task is successful
  110714. */
  110715. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  110716. /**
  110717. * Callback called when the task is successful
  110718. */
  110719. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  110720. /**
  110721. * Creates a new HDRCubeTextureAssetTask object
  110722. * @param name defines the name of the task
  110723. * @param url defines the location of the file to load
  110724. * @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.
  110725. * @param noMipmap defines if mipmaps should not be generated (default is false)
  110726. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  110727. * @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)
  110728. * @param reserved Internal use only
  110729. */
  110730. constructor(
  110731. /**
  110732. * Defines the name of the task
  110733. */
  110734. name: string,
  110735. /**
  110736. * Defines the location of the file to load
  110737. */
  110738. url: string,
  110739. /**
  110740. * Defines the desired size (the more it increases the longer the generation will be)
  110741. */
  110742. size: number,
  110743. /**
  110744. * Defines if mipmaps should not be generated (default is false)
  110745. */
  110746. noMipmap?: boolean,
  110747. /**
  110748. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  110749. */
  110750. generateHarmonics?: boolean,
  110751. /**
  110752. * 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)
  110753. */
  110754. gammaSpace?: boolean,
  110755. /**
  110756. * Internal Use Only
  110757. */
  110758. reserved?: boolean);
  110759. /**
  110760. * Execute the current task
  110761. * @param scene defines the scene where you want your assets to be loaded
  110762. * @param onSuccess is a callback called when the task is successfully executed
  110763. * @param onError is a callback called if an error occurs
  110764. */
  110765. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  110766. }
  110767. /**
  110768. * This class can be used to easily import assets into a scene
  110769. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  110770. */
  110771. export class AssetsManager {
  110772. private _scene;
  110773. private _isLoading;
  110774. protected _tasks: AbstractAssetTask[];
  110775. protected _waitingTasksCount: number;
  110776. protected _totalTasksCount: number;
  110777. /**
  110778. * Callback called when all tasks are processed
  110779. */
  110780. onFinish: (tasks: AbstractAssetTask[]) => void;
  110781. /**
  110782. * Callback called when a task is successful
  110783. */
  110784. onTaskSuccess: (task: AbstractAssetTask) => void;
  110785. /**
  110786. * Callback called when a task had an error
  110787. */
  110788. onTaskError: (task: AbstractAssetTask) => void;
  110789. /**
  110790. * Callback called when a task is done (whatever the result is)
  110791. */
  110792. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  110793. /**
  110794. * Observable called when all tasks are processed
  110795. */
  110796. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  110797. /**
  110798. * Observable called when a task had an error
  110799. */
  110800. onTaskErrorObservable: Observable<AbstractAssetTask>;
  110801. /**
  110802. * Observable called when a task is successful
  110803. */
  110804. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  110805. /**
  110806. * Observable called when a task is done (whatever the result is)
  110807. */
  110808. onProgressObservable: Observable<IAssetsProgressEvent>;
  110809. /**
  110810. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  110811. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  110812. */
  110813. useDefaultLoadingScreen: boolean;
  110814. /**
  110815. * Creates a new AssetsManager
  110816. * @param scene defines the scene to work on
  110817. */
  110818. constructor(scene: Scene);
  110819. /**
  110820. * Add a MeshAssetTask to the list of active tasks
  110821. * @param taskName defines the name of the new task
  110822. * @param meshesNames defines the name of meshes to load
  110823. * @param rootUrl defines the root url to use to locate files
  110824. * @param sceneFilename defines the filename of the scene file
  110825. * @returns a new MeshAssetTask object
  110826. */
  110827. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  110828. /**
  110829. * Add a TextFileAssetTask to the list of active tasks
  110830. * @param taskName defines the name of the new task
  110831. * @param url defines the url of the file to load
  110832. * @returns a new TextFileAssetTask object
  110833. */
  110834. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  110835. /**
  110836. * Add a BinaryFileAssetTask to the list of active tasks
  110837. * @param taskName defines the name of the new task
  110838. * @param url defines the url of the file to load
  110839. * @returns a new BinaryFileAssetTask object
  110840. */
  110841. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  110842. /**
  110843. * Add a ImageAssetTask to the list of active tasks
  110844. * @param taskName defines the name of the new task
  110845. * @param url defines the url of the file to load
  110846. * @returns a new ImageAssetTask object
  110847. */
  110848. addImageTask(taskName: string, url: string): ImageAssetTask;
  110849. /**
  110850. * Add a TextureAssetTask to the list of active tasks
  110851. * @param taskName defines the name of the new task
  110852. * @param url defines the url of the file to load
  110853. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  110854. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  110855. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  110856. * @returns a new TextureAssetTask object
  110857. */
  110858. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  110859. /**
  110860. * Add a CubeTextureAssetTask to the list of active tasks
  110861. * @param taskName defines the name of the new task
  110862. * @param url defines the url of the file to load
  110863. * @param extensions defines the extension to use to load the cube map (can be null)
  110864. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  110865. * @param files defines the list of files to load (can be null)
  110866. * @returns a new CubeTextureAssetTask object
  110867. */
  110868. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  110869. /**
  110870. *
  110871. * Add a HDRCubeTextureAssetTask to the list of active tasks
  110872. * @param taskName defines the name of the new task
  110873. * @param url defines the url of the file to load
  110874. * @param size defines the size you want for the cubemap (can be null)
  110875. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  110876. * @param generateHarmonics defines if you want to automatically generate (true by default)
  110877. * @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)
  110878. * @param reserved Internal use only
  110879. * @returns a new HDRCubeTextureAssetTask object
  110880. */
  110881. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  110882. /**
  110883. * Remove a task from the assets manager.
  110884. * @param task the task to remove
  110885. */
  110886. removeTask(task: AbstractAssetTask): void;
  110887. private _decreaseWaitingTasksCount;
  110888. private _runTask;
  110889. /**
  110890. * Reset the AssetsManager and remove all tasks
  110891. * @return the current instance of the AssetsManager
  110892. */
  110893. reset(): AssetsManager;
  110894. /**
  110895. * Start the loading process
  110896. * @return the current instance of the AssetsManager
  110897. */
  110898. load(): AssetsManager;
  110899. }
  110900. }
  110901. declare module BABYLON {
  110902. /**
  110903. * Wrapper class for promise with external resolve and reject.
  110904. */
  110905. export class Deferred<T> {
  110906. /**
  110907. * The promise associated with this deferred object.
  110908. */
  110909. readonly promise: Promise<T>;
  110910. private _resolve;
  110911. private _reject;
  110912. /**
  110913. * The resolve method of the promise associated with this deferred object.
  110914. */
  110915. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  110916. /**
  110917. * The reject method of the promise associated with this deferred object.
  110918. */
  110919. readonly reject: (reason?: any) => void;
  110920. /**
  110921. * Constructor for this deferred object.
  110922. */
  110923. constructor();
  110924. }
  110925. }
  110926. declare module BABYLON {
  110927. /**
  110928. * Class used to help managing file picking and drag'n'drop
  110929. */
  110930. export class FilesInput {
  110931. /**
  110932. * List of files ready to be loaded
  110933. */
  110934. static readonly FilesToLoad: {
  110935. [key: string]: File;
  110936. };
  110937. /**
  110938. * Callback called when a file is processed
  110939. */
  110940. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  110941. private _engine;
  110942. private _currentScene;
  110943. private _sceneLoadedCallback;
  110944. private _progressCallback;
  110945. private _additionalRenderLoopLogicCallback;
  110946. private _textureLoadingCallback;
  110947. private _startingProcessingFilesCallback;
  110948. private _onReloadCallback;
  110949. private _errorCallback;
  110950. private _elementToMonitor;
  110951. private _sceneFileToLoad;
  110952. private _filesToLoad;
  110953. /**
  110954. * Creates a new FilesInput
  110955. * @param engine defines the rendering engine
  110956. * @param scene defines the hosting scene
  110957. * @param sceneLoadedCallback callback called when scene is loaded
  110958. * @param progressCallback callback called to track progress
  110959. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  110960. * @param textureLoadingCallback callback called when a texture is loading
  110961. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  110962. * @param onReloadCallback callback called when a reload is requested
  110963. * @param errorCallback callback call if an error occurs
  110964. */
  110965. 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);
  110966. private _dragEnterHandler;
  110967. private _dragOverHandler;
  110968. private _dropHandler;
  110969. /**
  110970. * Calls this function to listen to drag'n'drop events on a specific DOM element
  110971. * @param elementToMonitor defines the DOM element to track
  110972. */
  110973. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  110974. /**
  110975. * Release all associated resources
  110976. */
  110977. dispose(): void;
  110978. private renderFunction;
  110979. private drag;
  110980. private drop;
  110981. private _traverseFolder;
  110982. private _processFiles;
  110983. /**
  110984. * Load files from a drop event
  110985. * @param event defines the drop event to use as source
  110986. */
  110987. loadFiles(event: any): void;
  110988. private _processReload;
  110989. /**
  110990. * Reload the current scene from the loaded files
  110991. */
  110992. reload(): void;
  110993. }
  110994. }
  110995. declare module BABYLON {
  110996. /**
  110997. * Defines the root class used to create scene optimization to use with SceneOptimizer
  110998. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  110999. */
  111000. export class SceneOptimization {
  111001. /**
  111002. * Defines the priority of this optimization (0 by default which means first in the list)
  111003. */
  111004. priority: number;
  111005. /**
  111006. * Gets a string describing the action executed by the current optimization
  111007. * @returns description string
  111008. */
  111009. getDescription(): string;
  111010. /**
  111011. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  111012. * @param scene defines the current scene where to apply this optimization
  111013. * @param optimizer defines the current optimizer
  111014. * @returns true if everything that can be done was applied
  111015. */
  111016. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  111017. /**
  111018. * Creates the SceneOptimization object
  111019. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  111020. * @param desc defines the description associated with the optimization
  111021. */
  111022. constructor(
  111023. /**
  111024. * Defines the priority of this optimization (0 by default which means first in the list)
  111025. */
  111026. priority?: number);
  111027. }
  111028. /**
  111029. * Defines an optimization used to reduce the size of render target textures
  111030. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  111031. */
  111032. export class TextureOptimization extends SceneOptimization {
  111033. /**
  111034. * Defines the priority of this optimization (0 by default which means first in the list)
  111035. */
  111036. priority: number;
  111037. /**
  111038. * 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
  111039. */
  111040. maximumSize: number;
  111041. /**
  111042. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  111043. */
  111044. step: number;
  111045. /**
  111046. * Gets a string describing the action executed by the current optimization
  111047. * @returns description string
  111048. */
  111049. getDescription(): string;
  111050. /**
  111051. * Creates the TextureOptimization object
  111052. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  111053. * @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
  111054. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  111055. */
  111056. constructor(
  111057. /**
  111058. * Defines the priority of this optimization (0 by default which means first in the list)
  111059. */
  111060. priority?: number,
  111061. /**
  111062. * 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
  111063. */
  111064. maximumSize?: number,
  111065. /**
  111066. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  111067. */
  111068. step?: number);
  111069. /**
  111070. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  111071. * @param scene defines the current scene where to apply this optimization
  111072. * @param optimizer defines the current optimizer
  111073. * @returns true if everything that can be done was applied
  111074. */
  111075. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  111076. }
  111077. /**
  111078. * Defines an optimization used to increase or decrease the rendering resolution
  111079. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  111080. */
  111081. export class HardwareScalingOptimization extends SceneOptimization {
  111082. /**
  111083. * Defines the priority of this optimization (0 by default which means first in the list)
  111084. */
  111085. priority: number;
  111086. /**
  111087. * Defines the maximum scale to use (2 by default)
  111088. */
  111089. maximumScale: number;
  111090. /**
  111091. * Defines the step to use between two passes (0.5 by default)
  111092. */
  111093. step: number;
  111094. private _currentScale;
  111095. private _directionOffset;
  111096. /**
  111097. * Gets a string describing the action executed by the current optimization
  111098. * @return description string
  111099. */
  111100. getDescription(): string;
  111101. /**
  111102. * Creates the HardwareScalingOptimization object
  111103. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  111104. * @param maximumScale defines the maximum scale to use (2 by default)
  111105. * @param step defines the step to use between two passes (0.5 by default)
  111106. */
  111107. constructor(
  111108. /**
  111109. * Defines the priority of this optimization (0 by default which means first in the list)
  111110. */
  111111. priority?: number,
  111112. /**
  111113. * Defines the maximum scale to use (2 by default)
  111114. */
  111115. maximumScale?: number,
  111116. /**
  111117. * Defines the step to use between two passes (0.5 by default)
  111118. */
  111119. step?: number);
  111120. /**
  111121. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  111122. * @param scene defines the current scene where to apply this optimization
  111123. * @param optimizer defines the current optimizer
  111124. * @returns true if everything that can be done was applied
  111125. */
  111126. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  111127. }
  111128. /**
  111129. * Defines an optimization used to remove shadows
  111130. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  111131. */
  111132. export class ShadowsOptimization extends SceneOptimization {
  111133. /**
  111134. * Gets a string describing the action executed by the current optimization
  111135. * @return description string
  111136. */
  111137. getDescription(): string;
  111138. /**
  111139. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  111140. * @param scene defines the current scene where to apply this optimization
  111141. * @param optimizer defines the current optimizer
  111142. * @returns true if everything that can be done was applied
  111143. */
  111144. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  111145. }
  111146. /**
  111147. * Defines an optimization used to turn post-processes off
  111148. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  111149. */
  111150. export class PostProcessesOptimization extends SceneOptimization {
  111151. /**
  111152. * Gets a string describing the action executed by the current optimization
  111153. * @return description string
  111154. */
  111155. getDescription(): string;
  111156. /**
  111157. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  111158. * @param scene defines the current scene where to apply this optimization
  111159. * @param optimizer defines the current optimizer
  111160. * @returns true if everything that can be done was applied
  111161. */
  111162. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  111163. }
  111164. /**
  111165. * Defines an optimization used to turn lens flares off
  111166. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  111167. */
  111168. export class LensFlaresOptimization extends SceneOptimization {
  111169. /**
  111170. * Gets a string describing the action executed by the current optimization
  111171. * @return description string
  111172. */
  111173. getDescription(): string;
  111174. /**
  111175. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  111176. * @param scene defines the current scene where to apply this optimization
  111177. * @param optimizer defines the current optimizer
  111178. * @returns true if everything that can be done was applied
  111179. */
  111180. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  111181. }
  111182. /**
  111183. * Defines an optimization based on user defined callback.
  111184. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  111185. */
  111186. export class CustomOptimization extends SceneOptimization {
  111187. /**
  111188. * Callback called to apply the custom optimization.
  111189. */
  111190. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  111191. /**
  111192. * Callback called to get custom description
  111193. */
  111194. onGetDescription: () => string;
  111195. /**
  111196. * Gets a string describing the action executed by the current optimization
  111197. * @returns description string
  111198. */
  111199. getDescription(): string;
  111200. /**
  111201. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  111202. * @param scene defines the current scene where to apply this optimization
  111203. * @param optimizer defines the current optimizer
  111204. * @returns true if everything that can be done was applied
  111205. */
  111206. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  111207. }
  111208. /**
  111209. * Defines an optimization used to turn particles off
  111210. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  111211. */
  111212. export class ParticlesOptimization extends SceneOptimization {
  111213. /**
  111214. * Gets a string describing the action executed by the current optimization
  111215. * @return description string
  111216. */
  111217. getDescription(): string;
  111218. /**
  111219. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  111220. * @param scene defines the current scene where to apply this optimization
  111221. * @param optimizer defines the current optimizer
  111222. * @returns true if everything that can be done was applied
  111223. */
  111224. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  111225. }
  111226. /**
  111227. * Defines an optimization used to turn render targets off
  111228. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  111229. */
  111230. export class RenderTargetsOptimization extends SceneOptimization {
  111231. /**
  111232. * Gets a string describing the action executed by the current optimization
  111233. * @return description string
  111234. */
  111235. getDescription(): string;
  111236. /**
  111237. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  111238. * @param scene defines the current scene where to apply this optimization
  111239. * @param optimizer defines the current optimizer
  111240. * @returns true if everything that can be done was applied
  111241. */
  111242. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  111243. }
  111244. /**
  111245. * Defines an optimization used to merge meshes with compatible materials
  111246. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  111247. */
  111248. export class MergeMeshesOptimization extends SceneOptimization {
  111249. private static _UpdateSelectionTree;
  111250. /**
  111251. * Gets or sets a boolean which defines if optimization octree has to be updated
  111252. */
  111253. /**
  111254. * Gets or sets a boolean which defines if optimization octree has to be updated
  111255. */
  111256. static UpdateSelectionTree: boolean;
  111257. /**
  111258. * Gets a string describing the action executed by the current optimization
  111259. * @return description string
  111260. */
  111261. getDescription(): string;
  111262. private _canBeMerged;
  111263. /**
  111264. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  111265. * @param scene defines the current scene where to apply this optimization
  111266. * @param optimizer defines the current optimizer
  111267. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  111268. * @returns true if everything that can be done was applied
  111269. */
  111270. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  111271. }
  111272. /**
  111273. * Defines a list of options used by SceneOptimizer
  111274. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  111275. */
  111276. export class SceneOptimizerOptions {
  111277. /**
  111278. * Defines the target frame rate to reach (60 by default)
  111279. */
  111280. targetFrameRate: number;
  111281. /**
  111282. * Defines the interval between two checkes (2000ms by default)
  111283. */
  111284. trackerDuration: number;
  111285. /**
  111286. * Gets the list of optimizations to apply
  111287. */
  111288. optimizations: SceneOptimization[];
  111289. /**
  111290. * Creates a new list of options used by SceneOptimizer
  111291. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  111292. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  111293. */
  111294. constructor(
  111295. /**
  111296. * Defines the target frame rate to reach (60 by default)
  111297. */
  111298. targetFrameRate?: number,
  111299. /**
  111300. * Defines the interval between two checkes (2000ms by default)
  111301. */
  111302. trackerDuration?: number);
  111303. /**
  111304. * Add a new optimization
  111305. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  111306. * @returns the current SceneOptimizerOptions
  111307. */
  111308. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  111309. /**
  111310. * Add a new custom optimization
  111311. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  111312. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  111313. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  111314. * @returns the current SceneOptimizerOptions
  111315. */
  111316. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  111317. /**
  111318. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  111319. * @param targetFrameRate defines the target frame rate (60 by default)
  111320. * @returns a SceneOptimizerOptions object
  111321. */
  111322. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  111323. /**
  111324. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  111325. * @param targetFrameRate defines the target frame rate (60 by default)
  111326. * @returns a SceneOptimizerOptions object
  111327. */
  111328. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  111329. /**
  111330. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  111331. * @param targetFrameRate defines the target frame rate (60 by default)
  111332. * @returns a SceneOptimizerOptions object
  111333. */
  111334. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  111335. }
  111336. /**
  111337. * Class used to run optimizations in order to reach a target frame rate
  111338. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  111339. */
  111340. export class SceneOptimizer implements IDisposable {
  111341. private _isRunning;
  111342. private _options;
  111343. private _scene;
  111344. private _currentPriorityLevel;
  111345. private _targetFrameRate;
  111346. private _trackerDuration;
  111347. private _currentFrameRate;
  111348. private _sceneDisposeObserver;
  111349. private _improvementMode;
  111350. /**
  111351. * Defines an observable called when the optimizer reaches the target frame rate
  111352. */
  111353. onSuccessObservable: Observable<SceneOptimizer>;
  111354. /**
  111355. * Defines an observable called when the optimizer enables an optimization
  111356. */
  111357. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  111358. /**
  111359. * Defines an observable called when the optimizer is not able to reach the target frame rate
  111360. */
  111361. onFailureObservable: Observable<SceneOptimizer>;
  111362. /**
  111363. * Gets a boolean indicating if the optimizer is in improvement mode
  111364. */
  111365. readonly isInImprovementMode: boolean;
  111366. /**
  111367. * Gets the current priority level (0 at start)
  111368. */
  111369. readonly currentPriorityLevel: number;
  111370. /**
  111371. * Gets the current frame rate checked by the SceneOptimizer
  111372. */
  111373. readonly currentFrameRate: number;
  111374. /**
  111375. * Gets or sets the current target frame rate (60 by default)
  111376. */
  111377. /**
  111378. * Gets or sets the current target frame rate (60 by default)
  111379. */
  111380. targetFrameRate: number;
  111381. /**
  111382. * Gets or sets the current interval between two checks (every 2000ms by default)
  111383. */
  111384. /**
  111385. * Gets or sets the current interval between two checks (every 2000ms by default)
  111386. */
  111387. trackerDuration: number;
  111388. /**
  111389. * Gets the list of active optimizations
  111390. */
  111391. readonly optimizations: SceneOptimization[];
  111392. /**
  111393. * Creates a new SceneOptimizer
  111394. * @param scene defines the scene to work on
  111395. * @param options defines the options to use with the SceneOptimizer
  111396. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  111397. * @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)
  111398. */
  111399. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  111400. /**
  111401. * Stops the current optimizer
  111402. */
  111403. stop(): void;
  111404. /**
  111405. * Reset the optimizer to initial step (current priority level = 0)
  111406. */
  111407. reset(): void;
  111408. /**
  111409. * Start the optimizer. By default it will try to reach a specific framerate
  111410. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  111411. */
  111412. start(): void;
  111413. private _checkCurrentState;
  111414. /**
  111415. * Release all resources
  111416. */
  111417. dispose(): void;
  111418. /**
  111419. * Helper function to create a SceneOptimizer with one single line of code
  111420. * @param scene defines the scene to work on
  111421. * @param options defines the options to use with the SceneOptimizer
  111422. * @param onSuccess defines a callback to call on success
  111423. * @param onFailure defines a callback to call on failure
  111424. * @returns the new SceneOptimizer object
  111425. */
  111426. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  111427. }
  111428. }
  111429. declare module BABYLON {
  111430. /**
  111431. * Class used to serialize a scene into a string
  111432. */
  111433. export class SceneSerializer {
  111434. /**
  111435. * Clear cache used by a previous serialization
  111436. */
  111437. static ClearCache(): void;
  111438. /**
  111439. * Serialize a scene into a JSON compatible object
  111440. * @param scene defines the scene to serialize
  111441. * @returns a JSON compatible object
  111442. */
  111443. static Serialize(scene: Scene): any;
  111444. /**
  111445. * Serialize a mesh into a JSON compatible object
  111446. * @param toSerialize defines the mesh to serialize
  111447. * @param withParents defines if parents must be serialized as well
  111448. * @param withChildren defines if children must be serialized as well
  111449. * @returns a JSON compatible object
  111450. */
  111451. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  111452. }
  111453. }
  111454. declare module BABYLON {
  111455. /**
  111456. * This represents the different options avilable for the video capture.
  111457. */
  111458. export interface VideoRecorderOptions {
  111459. /** Defines the mime type of the video */
  111460. mimeType: string;
  111461. /** Defines the video the video should be recorded at */
  111462. fps: number;
  111463. /** Defines the chunk size for the recording data */
  111464. recordChunckSize: number;
  111465. /** The audio tracks to attach to the record */
  111466. audioTracks?: MediaStreamTrack[];
  111467. }
  111468. /**
  111469. * This can helps recording videos from BabylonJS.
  111470. * This is based on the available WebRTC functionalities of the browser.
  111471. *
  111472. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  111473. */
  111474. export class VideoRecorder {
  111475. private static readonly _defaultOptions;
  111476. /**
  111477. * Returns wehther or not the VideoRecorder is available in your browser.
  111478. * @param engine Defines the Babylon Engine to check the support for
  111479. * @returns true if supported otherwise false
  111480. */
  111481. static IsSupported(engine: Engine): boolean;
  111482. private readonly _options;
  111483. private _canvas;
  111484. private _mediaRecorder;
  111485. private _recordedChunks;
  111486. private _fileName;
  111487. private _resolve;
  111488. private _reject;
  111489. /**
  111490. * True wether a recording is already in progress.
  111491. */
  111492. readonly isRecording: boolean;
  111493. /**
  111494. * Create a new VideoCapture object which can help converting what you see in Babylon to
  111495. * a video file.
  111496. * @param engine Defines the BabylonJS Engine you wish to record
  111497. * @param options Defines options that can be used to customized the capture
  111498. */
  111499. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  111500. /**
  111501. * Stops the current recording before the default capture timeout passed in the startRecording
  111502. * functions.
  111503. */
  111504. stopRecording(): void;
  111505. /**
  111506. * Starts recording the canvas for a max duration specified in parameters.
  111507. * @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.
  111508. * @param maxDuration Defines the maximum recording time in seconds.
  111509. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  111510. * @return a promise callback at the end of the recording with the video data in Blob.
  111511. */
  111512. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  111513. /**
  111514. * Releases internal resources used during the recording.
  111515. */
  111516. dispose(): void;
  111517. private _handleDataAvailable;
  111518. private _handleError;
  111519. private _handleStop;
  111520. }
  111521. }
  111522. declare module BABYLON {
  111523. /**
  111524. * Helper class to push actions to a pool of workers.
  111525. */
  111526. export class WorkerPool implements IDisposable {
  111527. private _workerInfos;
  111528. private _pendingActions;
  111529. /**
  111530. * Constructor
  111531. * @param workers Array of workers to use for actions
  111532. */
  111533. constructor(workers: Array<Worker>);
  111534. /**
  111535. * Terminates all workers and clears any pending actions.
  111536. */
  111537. dispose(): void;
  111538. /**
  111539. * Pushes an action to the worker pool. If all the workers are active, the action will be
  111540. * pended until a worker has completed its action.
  111541. * @param action The action to perform. Call onComplete when the action is complete.
  111542. */
  111543. push(action: (worker: Worker, onComplete: () => void) => void): void;
  111544. private _execute;
  111545. }
  111546. }
  111547. declare module BABYLON {
  111548. /**
  111549. * Class containing a set of static utilities functions for screenshots
  111550. */
  111551. export class ScreenshotTools {
  111552. /**
  111553. * Captures a screenshot of the current rendering
  111554. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  111555. * @param engine defines the rendering engine
  111556. * @param camera defines the source camera
  111557. * @param size This parameter can be set to a single number or to an object with the
  111558. * following (optional) properties: precision, width, height. If a single number is passed,
  111559. * it will be used for both width and height. If an object is passed, the screenshot size
  111560. * will be derived from the parameters. The precision property is a multiplier allowing
  111561. * rendering at a higher or lower resolution
  111562. * @param successCallback defines the callback receives a single parameter which contains the
  111563. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  111564. * src parameter of an <img> to display it
  111565. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  111566. * Check your browser for supported MIME types
  111567. */
  111568. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  111569. /**
  111570. * Generates an image screenshot from the specified camera.
  111571. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  111572. * @param engine The engine to use for rendering
  111573. * @param camera The camera to use for rendering
  111574. * @param size This parameter can be set to a single number or to an object with the
  111575. * following (optional) properties: precision, width, height. If a single number is passed,
  111576. * it will be used for both width and height. If an object is passed, the screenshot size
  111577. * will be derived from the parameters. The precision property is a multiplier allowing
  111578. * rendering at a higher or lower resolution
  111579. * @param successCallback The callback receives a single parameter which contains the
  111580. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  111581. * src parameter of an <img> to display it
  111582. * @param mimeType The MIME type of the screenshot image (default: image/png).
  111583. * Check your browser for supported MIME types
  111584. * @param samples Texture samples (default: 1)
  111585. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  111586. * @param fileName A name for for the downloaded file.
  111587. */
  111588. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  111589. }
  111590. }
  111591. declare module BABYLON {
  111592. /**
  111593. * A cursor which tracks a point on a path
  111594. */
  111595. export class PathCursor {
  111596. private path;
  111597. /**
  111598. * Stores path cursor callbacks for when an onchange event is triggered
  111599. */
  111600. private _onchange;
  111601. /**
  111602. * The value of the path cursor
  111603. */
  111604. value: number;
  111605. /**
  111606. * The animation array of the path cursor
  111607. */
  111608. animations: Animation[];
  111609. /**
  111610. * Initializes the path cursor
  111611. * @param path The path to track
  111612. */
  111613. constructor(path: Path2);
  111614. /**
  111615. * Gets the cursor point on the path
  111616. * @returns A point on the path cursor at the cursor location
  111617. */
  111618. getPoint(): Vector3;
  111619. /**
  111620. * Moves the cursor ahead by the step amount
  111621. * @param step The amount to move the cursor forward
  111622. * @returns This path cursor
  111623. */
  111624. moveAhead(step?: number): PathCursor;
  111625. /**
  111626. * Moves the cursor behind by the step amount
  111627. * @param step The amount to move the cursor back
  111628. * @returns This path cursor
  111629. */
  111630. moveBack(step?: number): PathCursor;
  111631. /**
  111632. * Moves the cursor by the step amount
  111633. * If the step amount is greater than one, an exception is thrown
  111634. * @param step The amount to move the cursor
  111635. * @returns This path cursor
  111636. */
  111637. move(step: number): PathCursor;
  111638. /**
  111639. * Ensures that the value is limited between zero and one
  111640. * @returns This path cursor
  111641. */
  111642. private ensureLimits;
  111643. /**
  111644. * Runs onchange callbacks on change (used by the animation engine)
  111645. * @returns This path cursor
  111646. */
  111647. private raiseOnChange;
  111648. /**
  111649. * Executes a function on change
  111650. * @param f A path cursor onchange callback
  111651. * @returns This path cursor
  111652. */
  111653. onchange(f: (cursor: PathCursor) => void): PathCursor;
  111654. }
  111655. }
  111656. declare module BABYLON {
  111657. /** @hidden */
  111658. export var blurPixelShader: {
  111659. name: string;
  111660. shader: string;
  111661. };
  111662. }
  111663. declare module BABYLON {
  111664. /** @hidden */
  111665. export var bones300Declaration: {
  111666. name: string;
  111667. shader: string;
  111668. };
  111669. }
  111670. declare module BABYLON {
  111671. /** @hidden */
  111672. export var instances300Declaration: {
  111673. name: string;
  111674. shader: string;
  111675. };
  111676. }
  111677. declare module BABYLON {
  111678. /** @hidden */
  111679. export var pointCloudVertexDeclaration: {
  111680. name: string;
  111681. shader: string;
  111682. };
  111683. }
  111684. // Mixins
  111685. interface Window {
  111686. mozIndexedDB: IDBFactory;
  111687. webkitIndexedDB: IDBFactory;
  111688. msIndexedDB: IDBFactory;
  111689. webkitURL: typeof URL;
  111690. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  111691. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  111692. WebGLRenderingContext: WebGLRenderingContext;
  111693. MSGesture: MSGesture;
  111694. CANNON: any;
  111695. AudioContext: AudioContext;
  111696. webkitAudioContext: AudioContext;
  111697. PointerEvent: any;
  111698. Math: Math;
  111699. Uint8Array: Uint8ArrayConstructor;
  111700. Float32Array: Float32ArrayConstructor;
  111701. mozURL: typeof URL;
  111702. msURL: typeof URL;
  111703. VRFrameData: any; // WebVR, from specs 1.1
  111704. DracoDecoderModule: any;
  111705. setImmediate(handler: (...args: any[]) => void): number;
  111706. }
  111707. interface Document {
  111708. mozCancelFullScreen(): void;
  111709. msCancelFullScreen(): void;
  111710. webkitCancelFullScreen(): void;
  111711. requestPointerLock(): void;
  111712. exitPointerLock(): void;
  111713. mozFullScreen: boolean;
  111714. msIsFullScreen: boolean;
  111715. readonly webkitIsFullScreen: boolean;
  111716. readonly pointerLockElement: Element;
  111717. mozPointerLockElement: HTMLElement;
  111718. msPointerLockElement: HTMLElement;
  111719. webkitPointerLockElement: HTMLElement;
  111720. }
  111721. interface HTMLCanvasElement {
  111722. requestPointerLock(): void;
  111723. msRequestPointerLock?(): void;
  111724. mozRequestPointerLock?(): void;
  111725. webkitRequestPointerLock?(): void;
  111726. /** Track wether a record is in progress */
  111727. isRecording: boolean;
  111728. /** Capture Stream method defined by some browsers */
  111729. captureStream(fps?: number): MediaStream;
  111730. }
  111731. interface CanvasRenderingContext2D {
  111732. msImageSmoothingEnabled: boolean;
  111733. }
  111734. interface MouseEvent {
  111735. mozMovementX: number;
  111736. mozMovementY: number;
  111737. webkitMovementX: number;
  111738. webkitMovementY: number;
  111739. msMovementX: number;
  111740. msMovementY: number;
  111741. }
  111742. interface Navigator {
  111743. mozGetVRDevices: (any: any) => any;
  111744. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  111745. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  111746. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  111747. webkitGetGamepads(): Gamepad[];
  111748. msGetGamepads(): Gamepad[];
  111749. webkitGamepads(): Gamepad[];
  111750. }
  111751. interface HTMLVideoElement {
  111752. mozSrcObject: any;
  111753. }
  111754. interface Math {
  111755. fround(x: number): number;
  111756. imul(a: number, b: number): number;
  111757. }
  111758. interface WebGLProgram {
  111759. context?: WebGLRenderingContext;
  111760. vertexShader?: WebGLShader;
  111761. fragmentShader?: WebGLShader;
  111762. isParallelCompiled: boolean;
  111763. onCompiled?: () => void;
  111764. }
  111765. interface WebGLRenderingContext {
  111766. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  111767. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  111768. vertexAttribDivisor(index: number, divisor: number): void;
  111769. createVertexArray(): any;
  111770. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  111771. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  111772. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  111773. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  111774. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  111775. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  111776. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  111777. // Queries
  111778. createQuery(): WebGLQuery;
  111779. deleteQuery(query: WebGLQuery): void;
  111780. beginQuery(target: number, query: WebGLQuery): void;
  111781. endQuery(target: number): void;
  111782. getQueryParameter(query: WebGLQuery, pname: number): any;
  111783. getQuery(target: number, pname: number): any;
  111784. MAX_SAMPLES: number;
  111785. RGBA8: number;
  111786. READ_FRAMEBUFFER: number;
  111787. DRAW_FRAMEBUFFER: number;
  111788. UNIFORM_BUFFER: number;
  111789. HALF_FLOAT_OES: number;
  111790. RGBA16F: number;
  111791. RGBA32F: number;
  111792. R32F: number;
  111793. RG32F: number;
  111794. RGB32F: number;
  111795. R16F: number;
  111796. RG16F: number;
  111797. RGB16F: number;
  111798. RED: number;
  111799. RG: number;
  111800. R8: number;
  111801. RG8: number;
  111802. UNSIGNED_INT_24_8: number;
  111803. DEPTH24_STENCIL8: number;
  111804. /* Multiple Render Targets */
  111805. drawBuffers(buffers: number[]): void;
  111806. readBuffer(src: number): void;
  111807. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  111808. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  111809. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  111810. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  111811. // Occlusion Query
  111812. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  111813. ANY_SAMPLES_PASSED: number;
  111814. QUERY_RESULT_AVAILABLE: number;
  111815. QUERY_RESULT: number;
  111816. }
  111817. interface WebGLBuffer {
  111818. references: number;
  111819. capacity: number;
  111820. is32Bits: boolean;
  111821. }
  111822. interface WebGLProgram {
  111823. transformFeedback?: WebGLTransformFeedback | null;
  111824. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  111825. }
  111826. interface EXT_disjoint_timer_query {
  111827. QUERY_COUNTER_BITS_EXT: number;
  111828. TIME_ELAPSED_EXT: number;
  111829. TIMESTAMP_EXT: number;
  111830. GPU_DISJOINT_EXT: number;
  111831. QUERY_RESULT_EXT: number;
  111832. QUERY_RESULT_AVAILABLE_EXT: number;
  111833. queryCounterEXT(query: WebGLQuery, target: number): void;
  111834. createQueryEXT(): WebGLQuery;
  111835. beginQueryEXT(target: number, query: WebGLQuery): void;
  111836. endQueryEXT(target: number): void;
  111837. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  111838. deleteQueryEXT(query: WebGLQuery): void;
  111839. }
  111840. interface WebGLUniformLocation {
  111841. _currentState: any;
  111842. }
  111843. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  111844. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  111845. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  111846. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  111847. interface WebGLRenderingContext {
  111848. readonly RASTERIZER_DISCARD: number;
  111849. readonly DEPTH_COMPONENT24: number;
  111850. readonly TEXTURE_3D: number;
  111851. readonly TEXTURE_2D_ARRAY: number;
  111852. readonly TEXTURE_COMPARE_FUNC: number;
  111853. readonly TEXTURE_COMPARE_MODE: number;
  111854. readonly COMPARE_REF_TO_TEXTURE: number;
  111855. readonly TEXTURE_WRAP_R: number;
  111856. readonly HALF_FLOAT: number;
  111857. readonly RGB8: number;
  111858. readonly RED_INTEGER: number;
  111859. readonly RG_INTEGER: number;
  111860. readonly RGB_INTEGER: number;
  111861. readonly RGBA_INTEGER: number;
  111862. readonly R8_SNORM: number;
  111863. readonly RG8_SNORM: number;
  111864. readonly RGB8_SNORM: number;
  111865. readonly RGBA8_SNORM: number;
  111866. readonly R8I: number;
  111867. readonly RG8I: number;
  111868. readonly RGB8I: number;
  111869. readonly RGBA8I: number;
  111870. readonly R8UI: number;
  111871. readonly RG8UI: number;
  111872. readonly RGB8UI: number;
  111873. readonly RGBA8UI: number;
  111874. readonly R16I: number;
  111875. readonly RG16I: number;
  111876. readonly RGB16I: number;
  111877. readonly RGBA16I: number;
  111878. readonly R16UI: number;
  111879. readonly RG16UI: number;
  111880. readonly RGB16UI: number;
  111881. readonly RGBA16UI: number;
  111882. readonly R32I: number;
  111883. readonly RG32I: number;
  111884. readonly RGB32I: number;
  111885. readonly RGBA32I: number;
  111886. readonly R32UI: number;
  111887. readonly RG32UI: number;
  111888. readonly RGB32UI: number;
  111889. readonly RGBA32UI: number;
  111890. readonly RGB10_A2UI: number;
  111891. readonly R11F_G11F_B10F: number;
  111892. readonly RGB9_E5: number;
  111893. readonly RGB10_A2: number;
  111894. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  111895. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  111896. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  111897. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  111898. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  111899. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  111900. 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;
  111901. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  111902. readonly TRANSFORM_FEEDBACK: number;
  111903. readonly INTERLEAVED_ATTRIBS: number;
  111904. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  111905. createTransformFeedback(): WebGLTransformFeedback;
  111906. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  111907. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  111908. beginTransformFeedback(primitiveMode: number): void;
  111909. endTransformFeedback(): void;
  111910. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  111911. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  111912. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  111913. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  111914. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  111915. }
  111916. interface ImageBitmap {
  111917. readonly width: number;
  111918. readonly height: number;
  111919. close(): void;
  111920. }
  111921. interface WebGLQuery extends WebGLObject {
  111922. }
  111923. declare var WebGLQuery: {
  111924. prototype: WebGLQuery;
  111925. new(): WebGLQuery;
  111926. };
  111927. interface WebGLSampler extends WebGLObject {
  111928. }
  111929. declare var WebGLSampler: {
  111930. prototype: WebGLSampler;
  111931. new(): WebGLSampler;
  111932. };
  111933. interface WebGLSync extends WebGLObject {
  111934. }
  111935. declare var WebGLSync: {
  111936. prototype: WebGLSync;
  111937. new(): WebGLSync;
  111938. };
  111939. interface WebGLTransformFeedback extends WebGLObject {
  111940. }
  111941. declare var WebGLTransformFeedback: {
  111942. prototype: WebGLTransformFeedback;
  111943. new(): WebGLTransformFeedback;
  111944. };
  111945. interface WebGLVertexArrayObject extends WebGLObject {
  111946. }
  111947. declare var WebGLVertexArrayObject: {
  111948. prototype: WebGLVertexArrayObject;
  111949. new(): WebGLVertexArrayObject;
  111950. };
  111951. // Type definitions for WebVR API
  111952. // Project: https://w3c.github.io/webvr/
  111953. // Definitions by: six a <https://github.com/lostfictions>
  111954. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  111955. interface VRDisplay extends EventTarget {
  111956. /**
  111957. * Dictionary of capabilities describing the VRDisplay.
  111958. */
  111959. readonly capabilities: VRDisplayCapabilities;
  111960. /**
  111961. * z-depth defining the far plane of the eye view frustum
  111962. * enables mapping of values in the render target depth
  111963. * attachment to scene coordinates. Initially set to 10000.0.
  111964. */
  111965. depthFar: number;
  111966. /**
  111967. * z-depth defining the near plane of the eye view frustum
  111968. * enables mapping of values in the render target depth
  111969. * attachment to scene coordinates. Initially set to 0.01.
  111970. */
  111971. depthNear: number;
  111972. /**
  111973. * An identifier for this distinct VRDisplay. Used as an
  111974. * association point in the Gamepad API.
  111975. */
  111976. readonly displayId: number;
  111977. /**
  111978. * A display name, a user-readable name identifying it.
  111979. */
  111980. readonly displayName: string;
  111981. readonly isConnected: boolean;
  111982. readonly isPresenting: boolean;
  111983. /**
  111984. * If this VRDisplay supports room-scale experiences, the optional
  111985. * stage attribute contains details on the room-scale parameters.
  111986. */
  111987. readonly stageParameters: VRStageParameters | null;
  111988. /**
  111989. * Passing the value returned by `requestAnimationFrame` to
  111990. * `cancelAnimationFrame` will unregister the callback.
  111991. * @param handle Define the hanle of the request to cancel
  111992. */
  111993. cancelAnimationFrame(handle: number): void;
  111994. /**
  111995. * Stops presenting to the VRDisplay.
  111996. * @returns a promise to know when it stopped
  111997. */
  111998. exitPresent(): Promise<void>;
  111999. /**
  112000. * Return the current VREyeParameters for the given eye.
  112001. * @param whichEye Define the eye we want the parameter for
  112002. * @returns the eye parameters
  112003. */
  112004. getEyeParameters(whichEye: string): VREyeParameters;
  112005. /**
  112006. * Populates the passed VRFrameData with the information required to render
  112007. * the current frame.
  112008. * @param frameData Define the data structure to populate
  112009. * @returns true if ok otherwise false
  112010. */
  112011. getFrameData(frameData: VRFrameData): boolean;
  112012. /**
  112013. * Get the layers currently being presented.
  112014. * @returns the list of VR layers
  112015. */
  112016. getLayers(): VRLayer[];
  112017. /**
  112018. * Return a VRPose containing the future predicted pose of the VRDisplay
  112019. * when the current frame will be presented. The value returned will not
  112020. * change until JavaScript has returned control to the browser.
  112021. *
  112022. * The VRPose will contain the position, orientation, velocity,
  112023. * and acceleration of each of these properties.
  112024. * @returns the pose object
  112025. */
  112026. getPose(): VRPose;
  112027. /**
  112028. * Return the current instantaneous pose of the VRDisplay, with no
  112029. * prediction applied.
  112030. * @returns the current instantaneous pose
  112031. */
  112032. getImmediatePose(): VRPose;
  112033. /**
  112034. * The callback passed to `requestAnimationFrame` will be called
  112035. * any time a new frame should be rendered. When the VRDisplay is
  112036. * presenting the callback will be called at the native refresh
  112037. * rate of the HMD. When not presenting this function acts
  112038. * identically to how window.requestAnimationFrame acts. Content should
  112039. * make no assumptions of frame rate or vsync behavior as the HMD runs
  112040. * asynchronously from other displays and at differing refresh rates.
  112041. * @param callback Define the eaction to run next frame
  112042. * @returns the request handle it
  112043. */
  112044. requestAnimationFrame(callback: FrameRequestCallback): number;
  112045. /**
  112046. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  112047. * Repeat calls while already presenting will update the VRLayers being displayed.
  112048. * @param layers Define the list of layer to present
  112049. * @returns a promise to know when the request has been fulfilled
  112050. */
  112051. requestPresent(layers: VRLayer[]): Promise<void>;
  112052. /**
  112053. * Reset the pose for this display, treating its current position and
  112054. * orientation as the "origin/zero" values. VRPose.position,
  112055. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  112056. * updated when calling resetPose(). This should be called in only
  112057. * sitting-space experiences.
  112058. */
  112059. resetPose(): void;
  112060. /**
  112061. * The VRLayer provided to the VRDisplay will be captured and presented
  112062. * in the HMD. Calling this function has the same effect on the source
  112063. * canvas as any other operation that uses its source image, and canvases
  112064. * created without preserveDrawingBuffer set to true will be cleared.
  112065. * @param pose Define the pose to submit
  112066. */
  112067. submitFrame(pose?: VRPose): void;
  112068. }
  112069. declare var VRDisplay: {
  112070. prototype: VRDisplay;
  112071. new(): VRDisplay;
  112072. };
  112073. interface VRLayer {
  112074. leftBounds?: number[] | Float32Array | null;
  112075. rightBounds?: number[] | Float32Array | null;
  112076. source?: HTMLCanvasElement | null;
  112077. }
  112078. interface VRDisplayCapabilities {
  112079. readonly canPresent: boolean;
  112080. readonly hasExternalDisplay: boolean;
  112081. readonly hasOrientation: boolean;
  112082. readonly hasPosition: boolean;
  112083. readonly maxLayers: number;
  112084. }
  112085. interface VREyeParameters {
  112086. /** @deprecated */
  112087. readonly fieldOfView: VRFieldOfView;
  112088. readonly offset: Float32Array;
  112089. readonly renderHeight: number;
  112090. readonly renderWidth: number;
  112091. }
  112092. interface VRFieldOfView {
  112093. readonly downDegrees: number;
  112094. readonly leftDegrees: number;
  112095. readonly rightDegrees: number;
  112096. readonly upDegrees: number;
  112097. }
  112098. interface VRFrameData {
  112099. readonly leftProjectionMatrix: Float32Array;
  112100. readonly leftViewMatrix: Float32Array;
  112101. readonly pose: VRPose;
  112102. readonly rightProjectionMatrix: Float32Array;
  112103. readonly rightViewMatrix: Float32Array;
  112104. readonly timestamp: number;
  112105. }
  112106. interface VRPose {
  112107. readonly angularAcceleration: Float32Array | null;
  112108. readonly angularVelocity: Float32Array | null;
  112109. readonly linearAcceleration: Float32Array | null;
  112110. readonly linearVelocity: Float32Array | null;
  112111. readonly orientation: Float32Array | null;
  112112. readonly position: Float32Array | null;
  112113. readonly timestamp: number;
  112114. }
  112115. interface VRStageParameters {
  112116. sittingToStandingTransform?: Float32Array;
  112117. sizeX?: number;
  112118. sizeY?: number;
  112119. }
  112120. interface Navigator {
  112121. getVRDisplays(): Promise<VRDisplay[]>;
  112122. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  112123. }
  112124. interface Window {
  112125. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  112126. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  112127. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  112128. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  112129. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  112130. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  112131. }
  112132. interface Gamepad {
  112133. readonly displayId: number;
  112134. }
  112135. interface XRDevice {
  112136. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  112137. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  112138. }
  112139. interface XRSession {
  112140. getInputSources(): Array<any>;
  112141. baseLayer: XRWebGLLayer;
  112142. requestFrameOfReference(type: string): Promise<void>;
  112143. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  112144. end(): Promise<void>;
  112145. requestAnimationFrame: Function;
  112146. addEventListener: Function;
  112147. }
  112148. interface XRSessionCreationOptions {
  112149. outputContext?: WebGLRenderingContext | null;
  112150. immersive?: boolean;
  112151. environmentIntegration?: boolean;
  112152. }
  112153. interface XRLayer {
  112154. getViewport: Function;
  112155. framebufferWidth: number;
  112156. framebufferHeight: number;
  112157. }
  112158. interface XRView {
  112159. projectionMatrix: Float32Array;
  112160. }
  112161. interface XRFrame {
  112162. getDevicePose: Function;
  112163. getInputPose: Function;
  112164. views: Array<XRView>;
  112165. baseLayer: XRLayer;
  112166. }
  112167. interface XRFrameOfReference {
  112168. }
  112169. interface XRWebGLLayer extends XRLayer {
  112170. framebuffer: WebGLFramebuffer;
  112171. }
  112172. declare var XRWebGLLayer: {
  112173. prototype: XRWebGLLayer;
  112174. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  112175. };